mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
fix update of last notify id in chat room + recover it when creating chat room from db
This commit is contained in:
parent
9a5f620c51
commit
afaa84610d
5 changed files with 20 additions and 12 deletions
|
|
@ -102,7 +102,8 @@ ClientGroupChatRoom::ClientGroupChatRoom (
|
|||
const IdentityAddress &peerAddress,
|
||||
shared_ptr<Participant> &me,
|
||||
const string &subject,
|
||||
list<shared_ptr<Participant>> &&participants
|
||||
list<shared_ptr<Participant>> &&participants,
|
||||
unsigned int lastNotifyId
|
||||
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(peerAddress, me->getAddress())),
|
||||
RemoteConference(core, me->getAddress(), nullptr) {
|
||||
L_D();
|
||||
|
|
@ -117,6 +118,7 @@ RemoteConference(core, me->getAddress(), nullptr) {
|
|||
|
||||
getMe()->getPrivate()->setAdmin(me->isAdmin());
|
||||
|
||||
dConference->eventHandler->setLastNotify(lastNotifyId);
|
||||
dConference->eventHandler->subscribe(getChatRoomId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ public:
|
|||
const IdentityAddress &peerAddress,
|
||||
std::shared_ptr<Participant> &me,
|
||||
const std::string &subject,
|
||||
std::list<std::shared_ptr<Participant>> &&participants
|
||||
std::list<std::shared_ptr<Participant>> &&participants,
|
||||
unsigned int lastNotifyId
|
||||
);
|
||||
|
||||
std::shared_ptr<Core> getCore () const;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ Object(*new RemoteConferenceEventHandlerPrivate) {
|
|||
L_D();
|
||||
xercesc::XMLPlatformUtils::Initialize();
|
||||
d->conf = remoteConference;
|
||||
// TODO : d->lastNotify = lastNotify
|
||||
}
|
||||
|
||||
RemoteConferenceEventHandler::~RemoteConferenceEventHandler () {
|
||||
|
|
@ -182,13 +181,16 @@ RemoteConferenceEventHandler::~RemoteConferenceEventHandler () {
|
|||
void RemoteConferenceEventHandler::subscribe (const ChatRoomId &chatRoomId) {
|
||||
L_D();
|
||||
d->chatRoomId = chatRoomId;
|
||||
LinphoneAddress *lAddr = linphone_address_new(d->chatRoomId.getPeerAddress().asString().c_str());
|
||||
const string &peerAddress = d->chatRoomId.getPeerAddress().asString();
|
||||
LinphoneAddress *lAddr = linphone_address_new(peerAddress.c_str());
|
||||
d->lev = linphone_core_create_subscribe(d->conf->getCore()->getCCore(), lAddr, "conference", 600);
|
||||
d->lev->op->set_from(d->chatRoomId.getLocalAddress().asString().c_str());
|
||||
linphone_event_add_custom_header(d->lev, "Last-Notify-Version", Utils::toString(d->lastNotify).c_str());
|
||||
const string &lastNotify = Utils::toString(d->lastNotify);
|
||||
linphone_event_add_custom_header(d->lev, "Last-Notify-Version", lastNotify.c_str());
|
||||
linphone_address_unref(lAddr);
|
||||
linphone_event_set_internal(d->lev, TRUE);
|
||||
linphone_event_set_user_data(d->lev, this);
|
||||
lInfo() << "Subscribing to chat room: " << peerAddress << "with last notify: " << lastNotify;
|
||||
linphone_event_send_subscribe(d->lev, nullptr);
|
||||
}
|
||||
|
||||
|
|
@ -234,9 +236,14 @@ unsigned int RemoteConferenceEventHandler::getLastNotify () const {
|
|||
return d->lastNotify;
|
||||
};
|
||||
|
||||
void RemoteConferenceEventHandler::resetLastNotify () {
|
||||
void RemoteConferenceEventHandler::setLastNotify (unsigned int lastNotify) {
|
||||
L_D();
|
||||
d->lastNotify = 0;
|
||||
d->lastNotify = lastNotify;
|
||||
}
|
||||
|
||||
void RemoteConferenceEventHandler::resetLastNotify () {
|
||||
setLastNotify(0);
|
||||
}
|
||||
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public:
|
|||
const ChatRoomId &getChatRoomId () const;
|
||||
|
||||
unsigned int getLastNotify () const;
|
||||
void setLastNotify (unsigned int lastNotify);
|
||||
void resetLastNotify ();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
soci::session *session = dbSession.getBackendSession<soci::session>();
|
||||
*session << "INSERT INTO conference_notified_event (event_id, notify_id)"
|
||||
" VALUES (:eventId, :notifyId)", soci::use(eventId), soci::use(lastNotifyId);
|
||||
*session << "UPDATE chat_room SET last_notify_id = :lastNotifyId WHERE peer_sip_address_id = :chatRoomId",
|
||||
*session << "UPDATE chat_room SET last_notify_id = :lastNotifyId WHERE id = :chatRoomId",
|
||||
soci::use(lastNotifyId), soci::use(curChatRoomId);
|
||||
|
||||
if (chatRoomId)
|
||||
|
|
@ -1650,9 +1650,6 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
string subject = row.get<string>(6);
|
||||
unsigned int lastNotifyId = static_cast<unsigned int>(row.get<int>(7, 0));
|
||||
|
||||
// TODO: Use me.
|
||||
(void)lastNotifyId;
|
||||
|
||||
if (capabilities & static_cast<int>(ChatRoom::Capabilities::Basic)) {
|
||||
chatRoom = core->getPrivate()->createBasicChatRoom(
|
||||
chatRoomId,
|
||||
|
|
@ -1687,7 +1684,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
continue;
|
||||
}
|
||||
|
||||
chatRoom = make_shared<ClientGroupChatRoom>(core, chatRoomId.getPeerAddress(), me, subject, move(participants));
|
||||
chatRoom = make_shared<ClientGroupChatRoom>(core, chatRoomId.getPeerAddress(), me, subject, move(participants), lastNotifyId);
|
||||
}
|
||||
|
||||
if (!chatRoom)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue