Commit 4511ad79 authored by Benjamin REIS's avatar Benjamin REIS

add background task to client group chat room

parent 6c88e6be
......@@ -22,6 +22,7 @@
#include "chat/chat-room/chat-room-p.h"
#include "client-group-chat-room.h"
#include "utils/background-task.h"
// =============================================================================
......@@ -53,6 +54,7 @@ private:
ChatRoomListener *chatRoomListener = this;
ClientGroupChatRoom::CapabilitiesMask capabilities = ClientGroupChatRoom::Capabilities::Conference;
bool deletionOnTerminationEnabled = false;
BackgroundTask bgTask;
L_DECLARE_PUBLIC(ClientGroupChatRoom);
};
......
......@@ -168,7 +168,11 @@ ClientGroupChatRoom::ClientGroupChatRoom (
const string &subject
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(), me)),
RemoteConference(core, me, nullptr) {
L_D();
L_D_T(RemoteConference, dConference);
d->bgTask.setName("Client group chat room refer received");
IdentityAddress focusAddr(uri);
dConference->focus = make_shared<Participant>(focusAddr);
dConference->focus->getPrivate()->addDevice(focusAddr);
......@@ -207,11 +211,11 @@ shared_ptr<Core> ClientGroupChatRoom::getCore () const {
}
void ClientGroupChatRoom::allowCpim (bool value) {
}
void ClientGroupChatRoom::allowMultipart (bool value) {
}
bool ClientGroupChatRoom::canHandleCpim () const {
......@@ -390,6 +394,7 @@ void ClientGroupChatRoom::join () {
shared_ptr<CallSession> session = dConference->focus->getPrivate()->getSession();
if (!session && ((getState() == ChatRoom::State::Instantiated) || (getState() == ChatRoom::State::Terminated))) {
d->bgTask.start();
session = d->createSession();
session->startInvite(nullptr, "", nullptr);
d->setState(ChatRoom::State::CreationPending);
......@@ -400,6 +405,7 @@ void ClientGroupChatRoom::leave () {
L_D();
L_D_T(RemoteConference, dConference);
d->bgTask.start();
dConference->eventHandler->unsubscribe();
shared_ptr<CallSession> session = dConference->focus->getPrivate()->getSession();
......@@ -471,6 +477,7 @@ void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
d->chatRoomId
));
#endif
d->bgTask.stop();
}
void ClientGroupChatRoom::onParticipantAdded (const shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {
......
......@@ -30,6 +30,11 @@ static void notifier (void *context) {
}
void BackgroundTask::start () {
if (mName.empty()) {
lError() << "No name was set on background task.";
return;
}
unsigned long newId = sal_begin_background_task(mName.c_str(), notifier, this);
lInfo() << "Starting background task [" << newId << "] with name : [" << mName << "].";
stop();
......@@ -45,4 +50,9 @@ void BackgroundTask::stop () {
mId = 0;
}
void BackgroundTask::handleTimeout () {
lWarning() << "Background task [" << mId << "] with name : [" << mName << "] has expired before completion...";
stop();
}
LINPHONE_END_NAMESPACE
......@@ -30,11 +30,16 @@ LINPHONE_BEGIN_NAMESPACE
class BackgroundTask {
public:
BackgroundTask () = default;
BackgroundTask (const std::string &name) : mName(name) {}
virtual ~BackgroundTask () {
stop();
}
void setName (const std::string &name) {
mName = name;
}
void start ();
void stop ();
......@@ -42,7 +47,7 @@ public:
return mName;
}
virtual void handleTimeout () {}
virtual void handleTimeout ();
private:
std::string mName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment