mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
add time managment to confernce event notification
This commit is contained in:
parent
bf9fba4293
commit
ebe1a5f12f
8 changed files with 63 additions and 48 deletions
|
|
@ -257,7 +257,7 @@ void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) {
|
|||
d->setState(ChatRoom::State::Terminated);
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantAdded (const Address &addr) {
|
||||
void ClientGroupChatRoom::onParticipantAdded (time_t tm, const Address &addr) {
|
||||
L_D_T(RemoteConference, dConference);
|
||||
|
||||
if (isMe(addr))
|
||||
|
|
@ -278,7 +278,7 @@ void ClientGroupChatRoom::onParticipantAdded (const Address &addr) {
|
|||
cb(cr, L_GET_C_BACK_PTR(participant));
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantRemoved (const Address &addr) {
|
||||
void ClientGroupChatRoom::onParticipantRemoved (time_t tm, const Address &addr) {
|
||||
L_D_T(RemoteConference, dConference);
|
||||
|
||||
shared_ptr<Participant> participant = findParticipant(addr);
|
||||
|
|
@ -297,7 +297,7 @@ void ClientGroupChatRoom::onParticipantRemoved (const Address &addr) {
|
|||
dConference->participants.remove(participant);
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantSetAdmin (const Address &addr, bool isAdmin) {
|
||||
void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) {
|
||||
shared_ptr<Participant> participant;
|
||||
if (isMe(addr))
|
||||
participant = getMe();
|
||||
|
|
@ -317,7 +317,7 @@ void ClientGroupChatRoom::onParticipantSetAdmin (const Address &addr, bool isAdm
|
|||
cb(cr, L_GET_C_BACK_PTR(participant), isAdmin);
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onSubjectChanged (const std::string &subject) {
|
||||
void ClientGroupChatRoom::onSubjectChanged (time_t tm, const std::string &subject) {
|
||||
RemoteConference::setSubject(subject);
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
|
|
@ -327,7 +327,7 @@ void ClientGroupChatRoom::onSubjectChanged (const std::string &subject) {
|
|||
cb(cr, subject.c_str());
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantDeviceAdded (const Address &addr, const Address &gruu) {
|
||||
void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) {
|
||||
shared_ptr<Participant> participant;
|
||||
if (isMe(addr))
|
||||
participant = getMe();
|
||||
|
|
@ -340,7 +340,7 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (const Address &addr, const A
|
|||
participant->getPrivate()->addDevice(gruu);
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantDeviceRemoved (const Address &addr, const Address &gruu) {
|
||||
void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) {
|
||||
shared_ptr<Participant> participant;
|
||||
if (isMe(addr))
|
||||
participant = getMe();
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ private:
|
|||
/* ConferenceListener */
|
||||
void onConferenceCreated (const Address &addr) override;
|
||||
void onConferenceTerminated (const Address &addr) override;
|
||||
void onParticipantAdded (const Address &addr) override;
|
||||
void onParticipantRemoved (const Address &addr) override;
|
||||
void onParticipantSetAdmin (const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (const std::string &subject) override;
|
||||
void onParticipantDeviceAdded (const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (const Address &addr, const Address &gruu) override;
|
||||
void onParticipantAdded (time_t tm, const Address &addr) override;
|
||||
void onParticipantRemoved (time_t tm, const Address &addr) override;
|
||||
void onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (time_t tm, const std::string &subject) override;
|
||||
void onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) override;
|
||||
|
||||
private:
|
||||
/* CallSessionListener */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef _CONFERENCE_LISTENER_H_
|
||||
#define _CONFERENCE_LISTENER_H_
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
#include "linphone/utils/general.h"
|
||||
|
|
@ -34,12 +35,12 @@ class ConferenceListener {
|
|||
public:
|
||||
virtual void onConferenceCreated (const Address &addr) = 0;
|
||||
virtual void onConferenceTerminated (const Address &addr) = 0;
|
||||
virtual void onParticipantAdded (const Address &addr) = 0;
|
||||
virtual void onParticipantRemoved (const Address &addr) = 0;
|
||||
virtual void onParticipantSetAdmin (const Address &addr, bool isAdmin) = 0;
|
||||
virtual void onSubjectChanged (const std::string &subject) = 0;
|
||||
virtual void onParticipantDeviceAdded (const Address &addr, const Address &gruu) = 0;
|
||||
virtual void onParticipantDeviceRemoved (const Address &addr, const Address &gruu) = 0;
|
||||
virtual void onParticipantAdded (time_t tm, const Address &addr) = 0;
|
||||
virtual void onParticipantRemoved (time_t tm, const Address &addr) = 0;
|
||||
virtual void onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) = 0;
|
||||
virtual void onSubjectChanged (time_t tm, const std::string &subject) = 0;
|
||||
virtual void onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) = 0;
|
||||
virtual void onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) = 0;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "conference/local-conference.h"
|
||||
#include "conference/participant-p.h"
|
||||
#include "linphone/utils/utils.h"
|
||||
|
|
@ -68,6 +70,13 @@ void LocalConferenceEventHandlerPrivate::notifyAll (const string ¬ify) {
|
|||
string LocalConferenceEventHandlerPrivate::createNotify (ConferenceType confInfo) {
|
||||
lastNotify = lastNotify + 1;
|
||||
confInfo.setVersion(lastNotify);
|
||||
if (!confInfo.getConferenceDescription()) {
|
||||
ConferenceDescriptionType description = ConferenceDescriptionType();
|
||||
confInfo.setConferenceDescription(description);
|
||||
}
|
||||
|
||||
time_t result = time(nullptr);
|
||||
confInfo.getConferenceDescription()->setFreeText(Utils::toString(static_cast<long>(result)));
|
||||
|
||||
stringstream notify;
|
||||
Xsd::XmlSchema::NamespaceInfomap map;
|
||||
|
|
|
|||
|
|
@ -73,11 +73,15 @@ void RemoteConferenceEventHandler::notifyReceived (string xmlBody) {
|
|||
lInfo() << "NOTIFY received for conference " << d->confAddress.asString();
|
||||
istringstream data(xmlBody);
|
||||
unique_ptr<ConferenceType> confInfo = parseConferenceInfo(data, Xsd::XmlSchema::Flags::dont_validate);
|
||||
time_t tm = time(nullptr);
|
||||
if (confInfo->getConferenceDescription()->getFreeText().present())
|
||||
tm = static_cast<time_t>(Utils::stoll(confInfo->getConferenceDescription()->getFreeText().get()));
|
||||
|
||||
Address cleanedConfAddress = d->confAddress;
|
||||
cleanedConfAddress.setPort(0);
|
||||
if (confInfo->getEntity() == cleanedConfAddress.asString()) {
|
||||
if (confInfo->getConferenceDescription().present() && confInfo->getConferenceDescription().get().getSubject().present())
|
||||
d->listener->onSubjectChanged(confInfo->getConferenceDescription().get().getSubject().get());
|
||||
d->listener->onSubjectChanged(tm, confInfo->getConferenceDescription().get().getSubject().get());
|
||||
|
||||
if (confInfo->getVersion().present())
|
||||
d->lastNotify = confInfo->getVersion().get();
|
||||
|
|
@ -91,7 +95,7 @@ void RemoteConferenceEventHandler::notifyReceived (string xmlBody) {
|
|||
Address addr(cAddrStr);
|
||||
bctbx_free(cAddrStr);
|
||||
if (user.getState() == "deleted")
|
||||
d->listener->onParticipantRemoved(addr);
|
||||
d->listener->onParticipantRemoved(tm, addr);
|
||||
else {
|
||||
bool isAdmin = false;
|
||||
if (user.getRoles()) {
|
||||
|
|
@ -103,17 +107,17 @@ void RemoteConferenceEventHandler::notifyReceived (string xmlBody) {
|
|||
}
|
||||
}
|
||||
if (user.getState() == "full")
|
||||
d->listener->onParticipantAdded(addr);
|
||||
d->listener->onParticipantSetAdmin(addr, isAdmin);
|
||||
d->listener->onParticipantAdded(tm, addr);
|
||||
d->listener->onParticipantSetAdmin(tm, addr, isAdmin);
|
||||
for (const auto &endpoint : user.getEndpoint()) {
|
||||
if (!endpoint.getEntity().present())
|
||||
break;
|
||||
|
||||
Address gruu(endpoint.getEntity().get());
|
||||
if (endpoint.getState() == "deleted")
|
||||
d->listener->onParticipantDeviceRemoved(addr, gruu);
|
||||
d->listener->onParticipantDeviceRemoved(tm, addr, gruu);
|
||||
else if (endpoint.getState() == "full")
|
||||
d->listener->onParticipantDeviceAdded(addr, gruu);
|
||||
d->listener->onParticipantDeviceAdded(tm, addr, gruu);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,16 +89,16 @@ void RemoteConference::onConferenceTerminated (const Address &addr) {
|
|||
d->eventHandler->unsubscribe();
|
||||
}
|
||||
|
||||
void RemoteConference::onParticipantAdded (const Address &addr) {}
|
||||
void RemoteConference::onParticipantAdded (time_t tm, const Address &addr) {}
|
||||
|
||||
void RemoteConference::onParticipantRemoved (const Address &addr) {}
|
||||
void RemoteConference::onParticipantRemoved (time_t tm, const Address &addr) {}
|
||||
|
||||
void RemoteConference::onParticipantSetAdmin (const Address &addr, bool isAdmin) {}
|
||||
void RemoteConference::onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) {}
|
||||
|
||||
void RemoteConference::onSubjectChanged (const std::string &subject) {}
|
||||
void RemoteConference::onSubjectChanged (time_t tm, const std::string &subject) {}
|
||||
|
||||
void RemoteConference::onParticipantDeviceAdded (const Address &addr, const Address &gruu) {}
|
||||
void RemoteConference::onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) {}
|
||||
|
||||
void RemoteConference::onParticipantDeviceRemoved (const Address &addr, const Address &gruu) {}
|
||||
void RemoteConference::onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) {}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ protected:
|
|||
/* ConferenceListener */
|
||||
void onConferenceCreated (const Address &addr) override;
|
||||
void onConferenceTerminated (const Address &addr) override;
|
||||
void onParticipantAdded (const Address &addr) override;
|
||||
void onParticipantRemoved (const Address &addr) override;
|
||||
void onParticipantSetAdmin (const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (const std::string &subject) override;
|
||||
void onParticipantDeviceAdded (const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (const Address &addr, const Address &gruu) override;
|
||||
void onParticipantAdded (time_t tm, const Address &addr) override;
|
||||
void onParticipantRemoved (time_t tm, const Address &addr) override;
|
||||
void onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (time_t tm, const std::string &subject) override;
|
||||
void onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) override;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(RemoteConference);
|
||||
|
|
|
|||
|
|
@ -447,12 +447,13 @@ public:
|
|||
private:
|
||||
void onConferenceCreated (const Address &addr) override;
|
||||
void onConferenceTerminated (const Address &addr) override;
|
||||
void onParticipantAdded (const Address &addr) override;
|
||||
void onParticipantRemoved (const Address &addr) override;
|
||||
void onParticipantSetAdmin (const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged(const string &subject) override;
|
||||
void onParticipantDeviceAdded(const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved(const Address &addr, const Address &gruu) override;
|
||||
void onParticipantAdded (time_t tm, const Address &addr) override;
|
||||
void onParticipantRemoved (time_t tm, const Address &addr) override;
|
||||
void onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (time_t tm, const string &subject) override;
|
||||
void onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) override;
|
||||
|
||||
public:
|
||||
RemoteConferenceEventHandler *handler;
|
||||
map<string, bool> participants;
|
||||
|
|
@ -472,33 +473,33 @@ void ConferenceEventTester::onConferenceCreated (const Address &addr) {}
|
|||
|
||||
void ConferenceEventTester::onConferenceTerminated (const Address &addr) {}
|
||||
|
||||
void ConferenceEventTester::onParticipantAdded (const Address &addr) {
|
||||
void ConferenceEventTester::onParticipantAdded (time_t tm, const Address &addr) {
|
||||
participants.insert(pair<string, bool>(addr.asString(), FALSE));
|
||||
participantDevices.insert(pair<string, int>(addr.asString(), 0));
|
||||
}
|
||||
void ConferenceEventTester::onParticipantRemoved (const Address &addr) {
|
||||
void ConferenceEventTester::onParticipantRemoved (time_t tm, const Address &addr) {
|
||||
participants.erase(addr.asString());
|
||||
participantDevices.erase(addr.asString());
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onParticipantSetAdmin (const Address &addr, bool isAdmin) {
|
||||
void ConferenceEventTester::onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) {
|
||||
auto it = participants.find(addr.asString());
|
||||
if (it != participants.end())
|
||||
it->second = isAdmin;
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onSubjectChanged(const string &subject) {
|
||||
void ConferenceEventTester::onSubjectChanged(time_t tm, const string &subject) {
|
||||
confSubject = subject;
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onParticipantDeviceAdded (const Address &addr, const Address &gruu) {
|
||||
void ConferenceEventTester::onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) {
|
||||
auto it = participantDevices.find(addr.asString());
|
||||
if (it != participantDevices.end())
|
||||
it->second++;
|
||||
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onParticipantDeviceRemoved (const Address &addr, const Address &gruu) {
|
||||
void ConferenceEventTester::onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) {
|
||||
auto it = participantDevices.find(addr.asString());
|
||||
if (it != participantDevices.end() && it->second > 0)
|
||||
it->second--;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue