Commit 6e786d69 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added ChatRoom::isEmpty method

parent f83c0538
...@@ -169,6 +169,13 @@ LINPHONE_PUBLIC void linphone_chat_room_delete_history(LinphoneChatRoom *cr); ...@@ -169,6 +169,13 @@ LINPHONE_PUBLIC void linphone_chat_room_delete_history(LinphoneChatRoom *cr);
*/ */
LINPHONE_PUBLIC int linphone_chat_room_get_history_size(LinphoneChatRoom *cr); LINPHONE_PUBLIC int linphone_chat_room_get_history_size(LinphoneChatRoom *cr);
/**
* Returns whether or not a #LinphoneChatRoom has at least one #LinphoneChatMessage or not.
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation
* @return true if there are no #LinphoneChatMessage, false otherwise.
*/
LINPHONE_PUBLIC bool_t linphone_chat_room_is_empty (LinphoneChatRoom *cr);
/** /**
* Gets nb_message most recent messages from cr chat room, sorted from oldest to most recent. * Gets nb_message most recent messages from cr chat room, sorted from oldest to most recent.
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which messages should be retrieved * @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which messages should be retrieved
......
...@@ -208,6 +208,10 @@ int linphone_chat_room_get_history_size (LinphoneChatRoom *cr) { ...@@ -208,6 +208,10 @@ int linphone_chat_room_get_history_size (LinphoneChatRoom *cr) {
return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChatMessageCount(); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChatMessageCount();
} }
bool_t linphone_chat_room_is_empty (LinphoneChatRoom *cr) {
return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->isEmpty();
}
void linphone_chat_room_delete_message (LinphoneChatRoom *cr, LinphoneChatMessage *msg) { void linphone_chat_room_delete_message (LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
shared_ptr<LinphonePrivate::EventLog> event = LinphonePrivate::MainDb::getEventFromKey( shared_ptr<LinphonePrivate::EventLog> event = LinphonePrivate::MainDb::getEventFromKey(
L_GET_PRIVATE_FROM_C_OBJECT(msg)->dbKey L_GET_PRIVATE_FROM_C_OBJECT(msg)->dbKey
......
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
virtual void deleteHistory () = 0; virtual void deleteHistory () = 0;
virtual std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const = 0; virtual std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const = 0;
virtual bool isEmpty () const = 0;
virtual int getChatMessageCount () const = 0; virtual int getChatMessageCount () const = 0;
virtual int getUnreadChatMessageCount () const = 0; virtual int getUnreadChatMessageCount () const = 0;
......
...@@ -464,6 +464,10 @@ shared_ptr<ChatMessage> ChatRoom::getLastChatMessageInHistory () const { ...@@ -464,6 +464,10 @@ shared_ptr<ChatMessage> ChatRoom::getLastChatMessageInHistory () const {
return getCore()->getPrivate()->mainDb->getLastChatMessage(getConferenceId()); return getCore()->getPrivate()->mainDb->getLastChatMessage(getConferenceId());
} }
bool ChatRoom::isEmpty () const {
return getCore()->getPrivate()->mainDb->getLastChatMessage(getConferenceId()) == nullptr;
}
int ChatRoom::getChatMessageCount () const { int ChatRoom::getChatMessageCount () const {
return getCore()->getPrivate()->mainDb->getChatMessageCount(getConferenceId()); return getCore()->getPrivate()->mainDb->getChatMessageCount(getConferenceId());
} }
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
void deleteHistory () override; void deleteHistory () override;
std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const override; std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const override;
bool isEmpty () const override;
int getChatMessageCount () const override; int getChatMessageCount () const override;
int getUnreadChatMessageCount () const override; int getUnreadChatMessageCount () const override;
......
...@@ -140,6 +140,11 @@ shared_ptr<ChatMessage> ProxyChatRoom::getLastChatMessageInHistory () const { ...@@ -140,6 +140,11 @@ shared_ptr<ChatMessage> ProxyChatRoom::getLastChatMessageInHistory () const {
return d->chatRoom->getLastChatMessageInHistory(); return d->chatRoom->getLastChatMessageInHistory();
} }
bool ProxyChatRoom::isEmpty () const {
L_D();
return d->chatRoom->isEmpty();
}
int ProxyChatRoom::getChatMessageCount () const { int ProxyChatRoom::getChatMessageCount () const {
L_D(); L_D();
return d->chatRoom->getChatMessageCount(); return d->chatRoom->getChatMessageCount();
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
void deleteHistory () override; void deleteHistory () override;
std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const override; std::shared_ptr<ChatMessage> getLastChatMessageInHistory () const override;
bool isEmpty () const override;
int getChatMessageCount () const override; int getChatMessageCount () const override;
int getUnreadChatMessageCount () const override; int getUnreadChatMessageCount () const override;
......
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