Skip to content

Commit

Permalink
Merge branch 'task/CHT-518_remove-connect' into 'develop'
Browse files Browse the repository at this point in the history
CHT-518. Remove connect

See merge request megachat/MEGAchat!1135
  • Loading branch information
jgandres committed Jan 19, 2022
2 parents 54f2b04 + 831476a commit 3b52c08
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 420 deletions.
101 changes: 0 additions & 101 deletions bindings/java/nz/mega/sdk/MegaChatApiJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,107 +406,6 @@ public int getInitState(){
return megaChatApi.getInitState();
}

/**
* Establish the connection with chat-related servers (chatd, presenced and Gelb).
*
* This function must be called only after calling:
* - MegaChatApi::init to initialize the chat engine
* - MegaApi::login to login in MEGA
* - MegaApi::fetchNodes to retrieve current state of the account
*
* At that point, the initialization state should be MegaChatApi::INIT_ONLINE_SESSION.
*
* The online status after connecting will be whatever was last used.
*
* The associated request type with this request is MegaChatRequest::TYPE_CONNECT
*
* @param listener MegaChatRequestListener to track this request
*/
public void connect(MegaChatRequestListenerInterface listener)
{
megaChatApi.connect(createDelegateRequestListener(listener));
}

/**
* Establish the connection with chat-related servers (chatd, presenced and Gelb).
*
* This function must be called only after calling:
* - MegaChatApi::init to initialize the chat engine
* - MegaApi::login to login in MEGA
* - MegaApi::fetchNodes to retrieve current state of the account
*
* At that point, the initialization state should be MegaChatApi::INIT_ONLINE_SESSION.
*
* The online status after connecting will be whatever was last used.
*
* The associated request type with this request is MegaChatRequest::TYPE_CONNECT
*
*/
public void connect(){
megaChatApi.connect();
}

/**
* Establish the connection with chat-related servers (chatd, presenced and Gelb).
*
* This function is intended to be used instead of MegaChatApi::connect when the connection
* is done by a service in background, which is launched without user-interaction. It avoids
* to notify to the server that this client is active, but actually the user is away.
*
* This function must be called only after calling:
* - MegaChatApi::init to initialize the chat engine
* - MegaApi::login to login in MEGA
* - MegaApi::fetchNodes to retrieve current state of the account
*
* At that point, the initialization state should be MegaChatApi::INIT_ONLINE_SESSION.
* The online status after connecting will be whatever was last used.
*
* The associated request type with this request is MegaChatRequest::TYPE_CONNECT
* Valid data in the MegaChatRequest object received on callbacks:
* - MegaChatRequest::getFlag - Returns true.
*
* @param listener MegaChatRequestListener to track this request
*/
public void connectInBackground(MegaChatRequestListenerInterface listener)
{
megaChatApi.connectInBackground(createDelegateRequestListener(listener));
}

/**
* Establish the connection with chat-related servers (chatd, presenced and Gelb).
*
* This function is intended to be used instead of MegaChatApi::connect when the connection
* is done by a service in background, which is launched without user-interaction. It avoids
* to notify to the server that this client is active, but actually the user is away.
*
* This function must be called only after calling:
* - MegaChatApi::init to initialize the chat engine
* - MegaApi::login to login in MEGA
* - MegaApi::fetchNodes to retrieve current state of the account
*
* At that point, the initialization state should be MegaChatApi::INIT_ONLINE_SESSION.
* The online status after connecting will be whatever was last used.
*
* The associated request type with this request is MegaChatRequest::TYPE_CONNECT
* Valid data in the MegaChatRequest object received on callbacks:
* - MegaChatRequest::getFlag - Returns true.
*/
public void connectInBackground()
{
megaChatApi.connectInBackground();
}

/**
* Disconnect from chat-related servers (chatd, presenced and Gelb).
*
* The associated request type with this request is MegaChatRequest::TYPE_DISCONNECT
*
* @param listener MegaChatRequestListener to track this request
*/
public void disconnect(MegaChatRequestListenerInterface listener){
megaChatApi.disconnect(createDelegateRequestListener(listener));
}

/**
* Returns the current state of the connection
*
Expand Down
8 changes: 0 additions & 8 deletions examples/megaclc/megaclc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,6 @@ struct MegaclChatListener : public c::MegaChatRequestListener
{
switch (request->getType())
{
case c::MegaChatRequest::TYPE_CONNECT:
if (check_err("Connect", e))
{
conlock(cout) << "Connection state " << api->getConnectionState() << endl;
}
break;

case c::MegaChatRequest::TYPE_SET_ONLINE_STATUS:
if (check_err("SetChatStatus", e))
Expand Down Expand Up @@ -976,7 +970,6 @@ void MegaclcListener::onRequestFinish(m::MegaApi* api, m::MegaRequest *request,
{
conlock(cout) << "Connecting to chat servers" << endl;
guard.unlock();
g_chatApi->connect(&g_chatListener);

setprompt(COMMAND);
}
Expand Down Expand Up @@ -1404,7 +1397,6 @@ void exec_initanonymous(ac::ACState& s)
if (g_chatApi->getInitState() == c::MegaChatApi::INIT_NOT_DONE)
{
g_chatApi->initAnonymous();
g_chatApi->connect(&g_chatListener);
}
else
{
Expand Down
14 changes: 14 additions & 0 deletions examples/qtmegachatapi/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,10 @@ void MainWindow::onChatInitStateUpdate(megachat::MegaChatApi *, int newState)
setWindowTitle(auxTitle);
}

std::unique_ptr<MegaUserList> contactList(mMegaApi->getContacts());
addOrUpdateContactControllersItems(contactList.get());
reorderAppContactList();

//Update chatListItems in chatControllers
updateChatControllersItems();

Expand All @@ -1160,6 +1164,16 @@ void MainWindow::onChatInitStateUpdate(megachat::MegaChatApi *, int newState)

//Update my user info tooltip
updateToolTipMyInfo();

if (newState == MegaChatApi::INIT_ONLINE_SESSION)
{
//Fetch alias attr
mMegaApi->getUserAttribute(::mega::MegaApi::USER_ATTR_ALIAS);
if (mApp->getJoinAsGuest())
{
mMegaChatApi->openChatPreview(mApp->getChatLink().c_str());
}
}
}
}

Expand Down
32 changes: 0 additions & 32 deletions examples/qtmegachatapi/MegaChatApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ bool MegaChatApplication::initAnonymous(std::string chatlink)
mSid = NULL;

mMainWin->setWindowTitle("Anonymous mode");
mMegaChatApi->connect();
mMegaChatApi->openChatPreview(chatlink.c_str());
connect(mMainWin, SIGNAL(onAnonymousLogout()), this, SLOT(onAnonymousLogout()));
mMainWin->show();
Expand Down Expand Up @@ -578,11 +577,6 @@ void MegaChatApplication::onRequestFinish(MegaApi *api, MegaRequest *request, Me

mMegaApi->getPushNotificationSettings();
mMegaApi->fetchTimeZone();

if (mMegaChatApi->getConnectionState() == MegaChatApi::DISCONNECTED)
{
mMegaChatApi->connect();
}
}
else
{
Expand Down Expand Up @@ -722,11 +716,6 @@ void MegaChatApplication::onRequestFinish(MegaApi *api, MegaRequest *request, Me
assert(!mSid);
mSid = request->getSessionKey();
saveSid(mSid);

if (mMegaChatApi->getConnectionState() == MegaChatApi::DISCONNECTED)
{
mMegaChatApi->connect();
}
}
else // --> request->getParamType() == 4
{
Expand Down Expand Up @@ -781,27 +770,6 @@ void MegaChatApplication::onRequestFinish(MegaChatApi *, MegaChatRequest *reques

switch (reqType)
{
case MegaChatRequest::TYPE_CONNECT:
if (error != MegaChatError::ERROR_OK)
{
QMessageBox::critical(nullptr, tr("Chat Connection"), tr("Error stablishing connection: ").append(e->getErrorString()));
init();
}
else
{
MegaUserList *contactList = mMegaApi->getContacts();
mMainWin->addOrUpdateContactControllersItems(contactList);
mMainWin->reorderAppContactList();
//Fetch alias attr
mMegaApi->getUserAttribute(::mega::MegaApi::USER_ATTR_ALIAS);
delete contactList;

if (mJoinAsGuest)
{
mMegaChatApi->openChatPreview(getChatLink().c_str());
}
}
break;
case MegaChatRequest::TYPE_LOGOUT:
if (error == MegaChatError::ERROR_OK)
{
Expand Down
Loading

0 comments on commit 3b52c08

Please sign in to comment.