Commit 1c1ad846 authored by Benjamin REIS's avatar Benjamin REIS

fix testers

parent 2fad0db4
......@@ -2178,10 +2178,9 @@ static void _linphone_core_conference_subscribe_received(LinphoneCore *lc, Linph
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))
));
if (chatRoom) {
linphone_event_accept_subscription(lev);
if (chatRoom)
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRoom))->subscribeReceived(lev);
} else
else
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
}
......
......@@ -384,7 +384,7 @@ void linphone_configure_op(LinphoneCore *lc, LinphonePrivate::SalOp *op, const L
void linphone_configure_op_with_proxy(LinphoneCore *lc, LinphonePrivate::SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy);
LinphoneContent * linphone_content_new(void);
LinphoneContent * linphone_content_copy(const LinphoneContent *ref);
SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content);
SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content, bool parseMultipart = true);
SalReason linphone_reason_to_sal(LinphoneReason reason);
LinphoneReason linphone_reason_from_sal(SalReason reason);
void linphone_error_info_to_sal(const LinphoneErrorInfo* ei, SalErrorInfo* sei);
......
......@@ -211,7 +211,7 @@ const char *linphone_content_get_key(const LinphoneContent *content) {
const LinphonePrivate::FileTransferContent *ftc = static_cast<const LinphonePrivate::FileTransferContent *>(c);
content->key = ms_strdup(ftc->getFileKeyAsString());
}
return content->key;
}
......@@ -259,7 +259,7 @@ static LinphoneContent * linphone_content_new_with_body_handler(SalBodyHandler *
linphone_content_set_string_buffer(content, body);
belle_sip_free(body);
}
belle_sip_list_t *headers = (belle_sip_list_t *)sal_body_handler_get_headers(body_handler);
while (headers) {
belle_sip_header_t *cHeader = BELLE_SIP_HEADER(headers->data);
......@@ -297,13 +297,13 @@ LinphoneContent * linphone_content_from_sal_body_handler(SalBodyHandler *body_ha
return NULL;
}
SalBodyHandler * sal_body_handler_from_content(const LinphoneContent *content) {
SalBodyHandler * sal_body_handler_from_content(const LinphoneContent *content, bool parseMultipart) {
if (content == NULL) return NULL;
SalBodyHandler *body_handler;
LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType();
if (contentType.isMultipart()) {
if (contentType.isMultipart() && parseMultipart) {
size_t size = linphone_content_get_size(content);
char *buffer = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str());
const char *boundary = L_STRING_TO_C(contentType.getParameter("boundary").getValue());
......
......@@ -258,7 +258,8 @@ ClientGroupChatRoom::ClientGroupChatRoom (
AbstractChatRoom::CapabilitiesMask capabilities,
const string &subject,
list<shared_ptr<Participant>> &&participants,
unsigned int lastNotifyId
unsigned int lastNotifyId,
bool hasBeenLeft
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, chatRoomId),
RemoteConference(core, me->getAddress(), nullptr) {
L_D();
......@@ -276,7 +277,8 @@ RemoteConference(core, me->getAddress(), nullptr) {
dConference->eventHandler->setChatRoomId(chatRoomId);
dConference->eventHandler->setLastNotify(lastNotifyId);
getCore()->getPrivate()->remoteListEventHandler->addHandler(dConference->eventHandler.get());
if (!hasBeenLeft)
getCore()->getPrivate()->remoteListEventHandler->addHandler(dConference->eventHandler.get());
}
ClientGroupChatRoom::~ClientGroupChatRoom () {
......@@ -498,8 +500,7 @@ void ClientGroupChatRoom::leave () {
L_D();
L_D_T(RemoteConference, dConference);
dConference->eventHandler->unsubscribe();
dConference->eventHandler->getPrivate()->lev = nullptr;
shared_ptr<CallSession> session = dConference->focus->getPrivate()->getSession();
if (session)
session->terminate();
......@@ -534,7 +535,7 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
L_D();
L_D_T(RemoteConference, dConference);
dConference->eventHandler->unsubscribe();
dConference->eventHandler->getPrivate()->lev = nullptr;
dConference->eventHandler->resetLastNotify();
d->setState(ChatRoom::State::Terminated);
d->addEvent(make_shared<ConferenceEvent>(
......
......@@ -54,7 +54,8 @@ public:
AbstractChatRoom::CapabilitiesMask capabilities,
const std::string &subject,
std::list<std::shared_ptr<Participant>> &&participants,
unsigned int lastNotifyId
unsigned int lastNotifyId,
bool hasBeenLeft = false
);
~ClientGroupChatRoom ();
......
......@@ -410,6 +410,7 @@ void LocalConferenceEventHandler::subscribeReceived (LinphoneEvent *lev, bool on
bctbx_free(addrStr);
if (!participant) {
lError() << "received SUBSCRIBE corresponds to no participant of the conference; " << d->conf->getConferenceAddress().asString() << ", no NOTIFY sent.";
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
return;
}
......@@ -418,16 +419,18 @@ void LocalConferenceEventHandler::subscribeReceived (LinphoneEvent *lev, bool on
IdentityAddress contactAddr(contactAddrStr);
bctbx_free(contactAddrStr);
shared_ptr<ParticipantDevice> device = participant->getPrivate()->findDevice(contactAddr);
if (!device) {
if (!device || (device->getState() != ParticipantDevice::State::Present && device->getState() != ParticipantDevice::State::Joining)) {
lError() << "received SUBSCRIBE for conference: " << d->conf->getConferenceAddress().asString()
<< "device sending subscribe: " << contactAddr.asString() << " is not known, no NOTIFY sent.";
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
return;
}
linphone_event_accept_subscription(lev);
if (linphone_event_get_subscription_state(lev) == LinphoneSubscriptionActive) {
unsigned int lastNotify = static_cast<unsigned int>(Utils::stoi(linphone_event_get_custom_header(lev, "Last-Notify-Version")));
device->setConferenceSubscribeEvent(lev);
if (lastNotify == 0) {
if (lastNotify == 0 || (device->getState() == ParticipantDevice::State::Joining)) {
lInfo() << "Sending initial notify of conference:" << d->conf->getConferenceAddress().asString() << " to: " << device->getAddress().asString();
d->notifyFullState(d->createNotifyFullState(static_cast<int>(d->lastNotify), oneToOne), device);
} else if (lastNotify < d->lastNotify) {
......
......@@ -54,8 +54,6 @@ namespace {
void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, const LinphoneContent *body) {
LinphoneSubscriptionState subscriptionState = linphone_event_get_subscription_state(lev);
if (subscriptionState != LinphoneSubscriptionIncomingReceived && subscriptionState != LinphoneSubscriptionTerminated)
return;
const string &xmlBody = string(linphone_content_get_string_buffer(body));
if (xmlBody.empty()) {
......@@ -63,6 +61,11 @@ void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, con
return;
}
linphone_event_accept_subscription(lev);
if (subscriptionState != LinphoneSubscriptionIncomingReceived && subscriptionState != LinphoneSubscriptionTerminated)
return;
const LinphoneAddress *lAddr = linphone_event_get_from(lev);
char *addrStr = linphone_address_as_string(lAddr);
IdentityAddress participantAddr(addrStr);
......@@ -110,7 +113,7 @@ void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, con
continue;
}
shared_ptr<ParticipantDevice> device = participant->getPrivate()->findDevice(deviceAddr);
if (!device) {
if (!device || (device->getState() != ParticipantDevice::State::Present && device->getState() != ParticipantDevice::State::Joining)) {
lError() << "Received subscribe for unknown device: " << deviceAddr << " for participant: "
<< participantAddr << " for chat room: " << chatRoomId;
continue;
......@@ -134,6 +137,7 @@ void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, con
char token[17];
belle_sip_random_token(token, sizeof(token));
content->addHeader("Content-Id", token);
content->addHeader("Content-Length", Utils::toString(notifyBody.size()));
contents.push_back(content);
// Add entry into the Rlmi content of the notify body
......@@ -146,11 +150,8 @@ void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev, con
}
}
if (noContent) {
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
if (noContent)
return;
}
linphone_event_accept_subscription(lev);
Xsd::Rlmi::List list("", 0, TRUE);
list.setResource(resources);
......
......@@ -32,6 +32,7 @@
LINPHONE_BEGIN_NAMESPACE
class RemoteConferenceEventHandlerPrivate : public ObjectPrivate, public CoreListener {
friend class ClientGroupChatRoom;
private:
void simpleNotifyReceived (const std::string &xmlBody);
void subscribe ();
......
......@@ -31,6 +31,7 @@ class RemoteConference;
class RemoteConferenceEventHandlerPrivate;
class RemoteConferenceEventHandler : public Object {
friend class ClientGroupChatRoom;
public:
RemoteConferenceEventHandler (RemoteConference *remoteConference);
~RemoteConferenceEventHandler ();
......
......@@ -76,7 +76,15 @@ void RemoteConferenceListEventHandler::subscribe () {
Xsd::ResourceLists::ResourceLists rl = Xsd::ResourceLists::ResourceLists();
Xsd::ResourceLists::ListType l = Xsd::ResourceLists::ListType();
for (const auto &handler : handlers) {
Address addr = handler->getChatRoomId().getPeerAddress();
const ChatRoomId &chatRoomId = handler->getChatRoomId();
shared_ptr<AbstractChatRoom> cr = getCore()->findChatRoom(chatRoomId);
if (!cr)
continue;
if (cr->hasBeenLeft())
continue;
Address addr = chatRoomId.getPeerAddress();
addr.setUriParam("Last-Notify", Utils::toString(handler->getLastNotify()));
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asStringUriOnly());
l.getEntry().push_back(entry);
......
......@@ -62,8 +62,9 @@ Content ContentManager::contentListToMultipart (const list<Content *> &contents,
for (Content *content : contents) {
LinphoneContent *cContent = L_GET_C_BACK_PTR(content);
SalBodyHandler *sbh = sal_body_handler_from_content(cContent);
SalBodyHandler *sbh = sal_body_handler_ref(sal_body_handler_from_content(cContent, false));
belle_sip_multipart_body_handler_add_part(mpbh, BELLE_SIP_BODY_HANDLER(sbh));
sal_body_handler_unref(sbh);
linphone_content_unref(cContent);
}
......
......@@ -2399,7 +2399,8 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
capabilities,
subject,
move(participants),
lastNotifyId
lastNotifyId,
hasBeenLeft
);
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
dChatRoom->setState(ChatRoom::State::Instantiated);
......
......@@ -1543,7 +1543,7 @@ static void group_chat_room_reinvited_after_removed_base (bool_t offline_when_re
coresManagerList = bctbx_list_append(coresManagerList, laure);
}
if (!offline_when_reinvited)
BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateTerminated, initialLaureStats.number_of_LinphoneChatRoomStateTerminated + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateTerminated, initialLaureStats.number_of_LinphoneChatRoomStateTerminated + 1, 5000));
wait_for_list(coresList,0, 1, 2000);
initialLaureStats = laure->stat;
......
127.0.0.1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org sipv4.example.org conf.example.org
::1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org
188.165.46.90 tunnel.wildcard2.linphone.org
64:ff9b::94.23.19.176 sipv4-nat64.example.org
64:ff9b::94.23.19.176 sipv4-nat64.example.org
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