mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
fix(Core): load correctly chat rooms
This commit is contained in:
parent
2f97587d53
commit
b64ae8a57b
5 changed files with 28 additions and 12 deletions
|
|
@ -31,6 +31,7 @@ class ChatRoomPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ChatRoom : public Object, public ConferenceInterface {
|
||||
friend class Core;
|
||||
friend class CorePrivate;
|
||||
friend class ChatMessage;
|
||||
friend class ChatMessagePrivate;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public:
|
|||
void insertChatRoomWithDb (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
void deleteChatRoomWithDb (const std::string &peerAddress);
|
||||
|
||||
std::shared_ptr<ChatRoom> createChatRoom (const Address &peerAddress, bool isRtt);
|
||||
|
||||
private:
|
||||
void insertChatRoom (const std::shared_ptr<ChatRoom> &chatRoom);
|
||||
void deleteChatRoom (const std::string &peerAddress);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,21 @@ static inline Address getCleanedPeerAddress (const Address &peerAddress) {
|
|||
// CorePrivate: ChatRoom.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<ChatRoom> CorePrivate::createChatRoom (const Address &peerAddress, bool isRtt) {
|
||||
shared_ptr<ChatRoom> chatRoom;
|
||||
|
||||
if (isRtt)
|
||||
chatRoom = ObjectFactory::create<RealTimeTextChatRoom>(cCore, peerAddress);
|
||||
else
|
||||
chatRoom = ObjectFactory::create<BasicChatRoom>(cCore, peerAddress);
|
||||
|
||||
ChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
dChatRoom->setState(ChatRoom::State::Instantiated);
|
||||
dChatRoom->setState(ChatRoom::State::Created);
|
||||
|
||||
return chatRoom;
|
||||
}
|
||||
|
||||
void CorePrivate::insertChatRoom (const shared_ptr<ChatRoom> &chatRoom) {
|
||||
L_ASSERT(chatRoom);
|
||||
L_ASSERT(chatRoom->getState() == ChatRoom::State::Created);
|
||||
|
|
@ -169,14 +184,7 @@ shared_ptr<ChatRoom> Core::getOrCreateBasicChatRoom (const Address &peerAddress,
|
|||
if (chatRoom)
|
||||
return chatRoom;
|
||||
|
||||
if (isRtt)
|
||||
chatRoom = ObjectFactory::create<RealTimeTextChatRoom>(d->cCore, peerAddress);
|
||||
else
|
||||
chatRoom = ObjectFactory::create<BasicChatRoom>(d->cCore, peerAddress);
|
||||
|
||||
chatRoom->getPrivate()->setState(ChatRoom::State::Instantiated);
|
||||
chatRoom->getPrivate()->setState(ChatRoom::State::Created);
|
||||
|
||||
chatRoom = d->createChatRoom(peerAddress, isRtt);
|
||||
d->insertChatRoomWithDb(chatRoom);
|
||||
|
||||
return chatRoom;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class CorePrivate;
|
|||
|
||||
class LINPHONE_PUBLIC Core : public Object {
|
||||
friend class ClientGroupChatRoom;
|
||||
friend class MainDb;
|
||||
|
||||
public:
|
||||
L_OVERRIDE_SHARED_FROM_THIS(Core);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include "conference/participant.h"
|
||||
#include "content/content-type.h"
|
||||
#include "content/content.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core-p.h"
|
||||
#include "db/session/db-session-provider.h"
|
||||
#include "event-log/event-log-p.h"
|
||||
#include "event-log/events.h"
|
||||
|
|
@ -1035,7 +1035,7 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
|
|||
tm lastUpdateDate = row.get<tm>(2);
|
||||
int capabilities = row.get<int>(3);
|
||||
string subject = row.get<string>(4);
|
||||
unsigned int lastNotifyId = row.get<unsigned int>(5);
|
||||
unsigned int lastNotifyId = static_cast<unsigned int>(row.get<int>(5, 0));
|
||||
|
||||
// TODO: Use me.
|
||||
(void)creationDate;
|
||||
|
|
@ -1045,7 +1045,7 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
|
|||
|
||||
shared_ptr<ChatRoom> chatRoom;
|
||||
if (capabilities & static_cast<int>(ChatRoom::Capabilities::Basic)) {
|
||||
chatRoom = d->core ? d->core->getOrCreateBasicChatRoom(
|
||||
chatRoom = d->core ? d->core->getPrivate()->createChatRoom(
|
||||
Address(sipAddress),
|
||||
capabilities & static_cast<int>(ChatRoom::Capabilities::RealTimeText)
|
||||
) : nullptr;
|
||||
|
|
@ -1066,7 +1066,11 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
|
|||
|
||||
void MainDb::insertChatRoom (const string &peerAddress, int capabilities) {
|
||||
L_D();
|
||||
d->insertChatRoom(d->insertSipAddress(peerAddress), capabilities, Utils::getLongAsTm(0));
|
||||
d->insertChatRoom(
|
||||
d->insertSipAddress(peerAddress),
|
||||
capabilities,
|
||||
Utils::getLongAsTm(static_cast<long>(time(0)))
|
||||
);
|
||||
}
|
||||
|
||||
void MainDb::deleteChatRoom (const string &peerAddress) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue