forked from mirrors/linphone-iphone
feat(MainDb): save chat room read only state
This commit is contained in:
parent
7c2ce9d173
commit
71757bbce7
8 changed files with 30 additions and 7 deletions
|
|
@ -51,6 +51,10 @@ BasicChatRoom::CapabilitiesMask BasicChatRoom::getCapabilities () const {
|
|||
return static_cast<CapabilitiesMask>(Capabilities::Basic);
|
||||
}
|
||||
|
||||
bool BasicChatRoom::isReadOnly () const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BasicChatRoom::canHandleParticipants () const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class LINPHONE_PUBLIC BasicChatRoom : public ChatRoom {
|
|||
|
||||
public:
|
||||
CapabilitiesMask getCapabilities () const override;
|
||||
bool isReadOnly () const override;
|
||||
|
||||
const IdentityAddress &getConferenceAddress () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public:
|
|||
time_t getLastUpdateTime () const;
|
||||
|
||||
virtual CapabilitiesMask getCapabilities () const = 0;
|
||||
virtual bool isReadOnly () const = 0;
|
||||
|
||||
std::shared_ptr<ChatMessage> getLastMessageInHistory () const;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ ClientGroupChatRoom::ClientGroupChatRoom (
|
|||
shared_ptr<Participant> &me,
|
||||
const string &subject,
|
||||
list<shared_ptr<Participant>> &&participants,
|
||||
unsigned int lastNotifyId
|
||||
unsigned int lastNotifyId,
|
||||
bool isReadOnly
|
||||
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(peerAddress, me->getAddress())),
|
||||
RemoteConference(core, me->getAddress(), nullptr) {
|
||||
L_D();
|
||||
|
|
@ -114,7 +115,7 @@ RemoteConference(core, me->getAddress(), nullptr) {
|
|||
dConference->subject = subject;
|
||||
dConference->participants = move(participants);
|
||||
|
||||
d->state = ChatRoom::State::Created;
|
||||
d->state = isReadOnly ? ChatRoom::State::Created : ChatRoom::State::Terminated;
|
||||
|
||||
getMe()->getPrivate()->setAdmin(me->isAdmin());
|
||||
|
||||
|
|
@ -130,6 +131,10 @@ ClientGroupChatRoom::CapabilitiesMask ClientGroupChatRoom::getCapabilities () co
|
|||
return static_cast<CapabilitiesMask>(Capabilities::Conference);
|
||||
}
|
||||
|
||||
bool ClientGroupChatRoom::isReadOnly () const {
|
||||
return getState() == State::Created;
|
||||
}
|
||||
|
||||
bool ClientGroupChatRoom::canHandleParticipants () const {
|
||||
return RemoteConference::canHandleParticipants();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,12 +45,14 @@ public:
|
|||
std::shared_ptr<Participant> &me,
|
||||
const std::string &subject,
|
||||
std::list<std::shared_ptr<Participant>> &&participants,
|
||||
unsigned int lastNotifyId
|
||||
unsigned int lastNotifyId,
|
||||
bool isReadOnly
|
||||
);
|
||||
|
||||
std::shared_ptr<Core> getCore () const;
|
||||
|
||||
CapabilitiesMask getCapabilities () const override;
|
||||
bool isReadOnly () const override;
|
||||
|
||||
const IdentityAddress &getConferenceAddress () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,10 @@ int ServerGroupChatRoom::getCapabilities () const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool ServerGroupChatRoom::isReadOnly () const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ServerGroupChatRoom::canHandleParticipants () const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public:
|
|||
ServerGroupChatRoom (const std::shared_ptr<Core> &core, SalCallOp *op);
|
||||
|
||||
CapabilitiesMask getCapabilities () const override;
|
||||
bool isReadOnly () const override;
|
||||
|
||||
const IdentityAddress &getConferenceAddress () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -247,11 +247,12 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
const tm &creationTime = Utils::getTimeTAsTm(chatRoom->getCreationTime());
|
||||
const int &capabilities = static_cast<int>(chatRoom->getCapabilities());
|
||||
const string &subject = chatRoom->getSubject();
|
||||
const int &flags = chatRoom->isReadOnly();
|
||||
*session << "INSERT INTO chat_room ("
|
||||
" peer_sip_address_id, local_sip_address_id, creation_time, last_update_time, capabilities, subject"
|
||||
") VALUES (:peerSipAddressId, :localSipAddressId, :creationTime, :lastUpdateTime, :capabilities, :subject)",
|
||||
") VALUES (:peerSipAddressId, :localSipAddressId, :creationTime, :lastUpdateTime, :capabilities, :subject, :flags)",
|
||||
soci::use(peerSipAddressId), soci::use(localSipAddressId), soci::use(creationTime), soci::use(creationTime),
|
||||
soci::use(capabilities), soci::use(subject);
|
||||
soci::use(capabilities), soci::use(subject), soci::use(flags);
|
||||
|
||||
id = q->getLastInsertId();
|
||||
|
||||
|
|
@ -898,6 +899,8 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
|
||||
" last_notify_id INT UNSIGNED,"
|
||||
|
||||
" flags INT UNSIGNED DEFAULT 0,"
|
||||
|
||||
" UNIQUE (peer_sip_address_id, local_sip_address_id),"
|
||||
|
||||
" FOREIGN KEY (peer_sip_address_id)"
|
||||
|
|
@ -1718,7 +1721,8 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
list<shared_ptr<ChatRoom>> MainDb::getChatRooms () const {
|
||||
static const string query = "SELECT chat_room.id, peer_sip_address.value, local_sip_address.value, creation_time, last_update_time, capabilities, subject, last_notify_id"
|
||||
static const string query = "SELECT chat_room.id, peer_sip_address.value, local_sip_address.value, "
|
||||
"creation_time, last_update_time, capabilities, subject, last_notify_id, flags"
|
||||
" FROM chat_room, sip_address AS peer_sip_address, sip_address AS local_sip_address"
|
||||
" WHERE chat_room.peer_sip_address_id = peer_sip_address.id AND chat_room.local_sip_address_id = local_sip_address.id"
|
||||
" ORDER BY last_update_time DESC";
|
||||
|
|
@ -1797,7 +1801,8 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
me,
|
||||
subject,
|
||||
move(participants),
|
||||
lastNotifyId
|
||||
lastNotifyId,
|
||||
!!row.get<int>(8, 0)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue