diff --git a/coreapi/misc.c b/coreapi/misc.c index e7e0a0d9e..77e0ff2ef 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -940,14 +940,20 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log){ bool_t call_logs_sqlite_db_found = FALSE; + // TODO: This is a workaround that has to be removed ASAP // Do not add calls made to the conference factory in the history char *to = linphone_address_as_string(call_log->to); const char *conference_factory_uri = linphone_core_get_conference_factory_uri(lc); - if (strcmp(conference_factory_uri, to) == 0) { - ms_free(to); + if (conference_factory_uri && (strcmp(conference_factory_uri, to) == 0)) { + bctbx_free(to); return; } - ms_free(to); + if (strstr(to, "chatroom-") == to) { + bctbx_free(to); + return; + } + bctbx_free(to); + // End of workaround #ifdef SQLITE_STORAGE_ENABLED if (lc->logs_db) { diff --git a/src/chat/chat-room/basic-chat-room-p.h b/src/chat/chat-room/basic-chat-room-p.h index 2429431bf..a87164730 100644 --- a/src/chat/chat-room/basic-chat-room-p.h +++ b/src/chat/chat-room/basic-chat-room-p.h @@ -35,6 +35,7 @@ private: void onChatMessageReceived (const std::shared_ptr &chatMessage) override; std::string subject; + std::list> participants; L_DECLARE_PUBLIC(BasicChatRoom); }; diff --git a/src/chat/chat-room/basic-chat-room.cpp b/src/chat/chat-room/basic-chat-room.cpp index 7b580914c..edaef84c1 100644 --- a/src/chat/chat-room/basic-chat-room.cpp +++ b/src/chat/chat-room/basic-chat-room.cpp @@ -42,7 +42,10 @@ BasicChatRoom::BasicChatRoom ( BasicChatRoomPrivate &p, const std::shared_ptr &core, const ChatRoomId &chatRoomId -) : ChatRoom(p, core, chatRoomId) {} +) : ChatRoom(p, core, chatRoomId) { + L_D(); + d->participants.push_back(make_shared(getPeerAddress())); +} BasicChatRoom::CapabilitiesMask BasicChatRoom::getCapabilities () const { return static_cast(Capabilities::Basic); @@ -87,8 +90,9 @@ int BasicChatRoom::getNbParticipants () const { return 1; } -list> BasicChatRoom::getParticipants () const { - return { make_shared(getPeerAddress()) }; +const list> &BasicChatRoom::getParticipants () const { + L_D(); + return d->participants; } void BasicChatRoom::setParticipantAdminStatus (shared_ptr &, bool) { diff --git a/src/chat/chat-room/basic-chat-room.h b/src/chat/chat-room/basic-chat-room.h index 283a2ad80..bf777e4c8 100644 --- a/src/chat/chat-room/basic-chat-room.h +++ b/src/chat/chat-room/basic-chat-room.h @@ -48,7 +48,7 @@ public: std::shared_ptr getMe () const override; int getNbParticipants () const override; - std::list> getParticipants () const override; + const std::list> &getParticipants () const override; void setParticipantAdminStatus (std::shared_ptr &participant, bool isAdmin) override; diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index a1d67734a..9ce0202b2 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -200,7 +200,7 @@ int ClientGroupChatRoom::getNbParticipants () const { return RemoteConference::getNbParticipants(); } -list> ClientGroupChatRoom::getParticipants () const { +const list> &ClientGroupChatRoom::getParticipants () const { return RemoteConference::getParticipants(); } diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index 28ef3ffdd..9e55d915f 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -65,7 +65,7 @@ public: std::shared_ptr getMe () const override; int getNbParticipants () const override; - std::list> getParticipants () const override; + const std::list> &getParticipants () const override; void setParticipantAdminStatus (std::shared_ptr &participant, bool isAdmin) override; diff --git a/src/chat/chat-room/server-group-chat-room-stub.cpp b/src/chat/chat-room/server-group-chat-room-stub.cpp index e0ffc5ef9..5abf436d2 100644 --- a/src/chat/chat-room/server-group-chat-room-stub.cpp +++ b/src/chat/chat-room/server-group-chat-room-stub.cpp @@ -113,7 +113,7 @@ int ServerGroupChatRoom::getNbParticipants () const { return 0; } -list> ServerGroupChatRoom::getParticipants () const { +const list> &ServerGroupChatRoom::getParticipants () const { return LocalConference::getParticipants(); } diff --git a/src/chat/chat-room/server-group-chat-room.h b/src/chat/chat-room/server-group-chat-room.h index 73d0295de..9c8fc9d8a 100644 --- a/src/chat/chat-room/server-group-chat-room.h +++ b/src/chat/chat-room/server-group-chat-room.h @@ -55,7 +55,7 @@ public: std::shared_ptr getMe () const override; int getNbParticipants () const override; - std::list> getParticipants () const override; + const std::list> &getParticipants () const override; void setParticipantAdminStatus (std::shared_ptr &participant, bool isAdmin) override; diff --git a/src/conference/conference-interface.h b/src/conference/conference-interface.h index fd08fc0c3..db6b505c9 100644 --- a/src/conference/conference-interface.h +++ b/src/conference/conference-interface.h @@ -44,7 +44,7 @@ public: virtual const IdentityAddress &getConferenceAddress () const = 0; virtual std::shared_ptr getMe () const = 0; virtual int getNbParticipants () const = 0; - virtual std::list> getParticipants () const = 0; + virtual const std::list> &getParticipants () const = 0; virtual const std::string &getSubject () const = 0; virtual void join () = 0; virtual void leave () = 0; diff --git a/src/conference/conference.cpp b/src/conference/conference.cpp index 52991d8b8..7c930cc24 100644 --- a/src/conference/conference.cpp +++ b/src/conference/conference.cpp @@ -88,7 +88,7 @@ int Conference::getNbParticipants () const { return static_cast(d->participants.size()); } -list> Conference::getParticipants () const { +const list> &Conference::getParticipants () const { L_D(); return d->participants; } diff --git a/src/conference/conference.h b/src/conference/conference.h index f7a723cd4..467dde80c 100644 --- a/src/conference/conference.h +++ b/src/conference/conference.h @@ -55,7 +55,7 @@ public: const IdentityAddress &getConferenceAddress () const override; std::shared_ptr getMe () const override; int getNbParticipants () const override; - std::list> getParticipants () const override; + const std::list> &getParticipants () const override; const std::string &getSubject () const override; void join () override; void leave () override; diff --git a/src/conference/local-conference.cpp b/src/conference/local-conference.cpp index 45c3707c5..cbaeef2db 100644 --- a/src/conference/local-conference.cpp +++ b/src/conference/local-conference.cpp @@ -42,6 +42,7 @@ void LocalConference::addParticipant (const IdentityAddress &addr, const CallSes if (participant) return; participant = make_shared(addr); + participant->getPrivate()->createSession(*this, params, hasMedia, this); d->participants.push_back(participant); if (!d->activeParticipant) d->activeParticipant = participant; diff --git a/src/conference/session/call-session-p.h b/src/conference/session/call-session-p.h index c850459ea..6f7e0fc3f 100644 --- a/src/conference/session/call-session-p.h +++ b/src/conference/session/call-session-p.h @@ -37,6 +37,7 @@ public: int computeDuration () const; virtual void initializeParamsAccordingToIncomingCallParams (); virtual void setState (LinphoneCallState newState, const std::string &message); + void startIncomingNotification (); bool startPing (); void setPingTime (int value) { pingTime = value; } diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index fe11ac162..36519991b 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -177,6 +177,27 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess } } +void CallSessionPrivate::startIncomingNotification () { + L_Q(); + if (listener) + listener->onIncomingCallSessionStarted(q->getSharedFromThis()); + + setState(LinphoneCallIncomingReceived, "Incoming CallSession"); + + /* From now on, the application is aware of the call and supposed to take background task or already submitted notification to the user. + * We can then drop our background task. */ +#if 0 + if (call->bg_task_id!=0) { + sal_end_background_task(call->bg_task_id); + call->bg_task_id=0; + } +#endif + + if (state == LinphoneCallIncomingReceived) { + handleIncomingReceivedStateInIncomingNotification(); + } +} + bool CallSessionPrivate::startPing () { if (core->sip_conf.ping_with_options) { /* Defer the start of the call after the OPTIONS ping for outgoing call or @@ -850,23 +871,7 @@ void CallSession::startIncomingNotification () { return; } - if (d->listener) - d->listener->onIncomingCallSessionStarted(getSharedFromThis()); - - d->setState(LinphoneCallIncomingReceived, "Incoming CallSession"); - - /* From now on, the application is aware of the call and supposed to take background task or already submitted notification to the user. - * We can then drop our background task. */ -#if 0 - if (call->bg_task_id!=0) { - sal_end_background_task(call->bg_task_id); - call->bg_task_id=0; - } -#endif - - if (d->state == LinphoneCallIncomingReceived) { - d->handleIncomingReceivedStateInIncomingNotification(); - } + d->startIncomingNotification(); } int CallSession::startInvite (const Address *destination, const string &subject, const Content *content) { diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 74def1064..806dd4297 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -610,7 +610,7 @@ float MediaSessionPrivate::aggregateQualityRatings (float audioRating, float vid void MediaSessionPrivate::setState (LinphoneCallState newState, const string &message) { L_Q(); /* Take a ref on the session otherwise it might get destroyed during the call to setState */ - shared_ptr session = q->getSharedFromThis(); + shared_ptr sessionRef = q->getSharedFromThis(); CallSessionPrivate::setState(newState, message); updateReportingCallState(); } @@ -2092,7 +2092,7 @@ void MediaSessionPrivate::handleIceEvents (OrtpEvent *ev) { updateLocalMediaDescriptionFromIce(); op->set_local_media_description(localDesc); deferIncomingNotification = false; - static_cast(q)->startIncomingNotification(); + startIncomingNotification(); break; default: break;