mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-06 21:33:08 +00:00
Add IsComposingMessage class.
This commit is contained in:
parent
536d4d324a
commit
75c981df03
8 changed files with 163 additions and 30 deletions
|
|
@ -35,7 +35,9 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
call/remote-conference-call.h
|
||||
chat/chat-message/chat-message-p.h
|
||||
chat/chat-message/chat-message.h
|
||||
chat/chat-message/is-composing-message.h
|
||||
chat/chat-message/notification-message.h
|
||||
chat/chat-message/notification-message-p.h
|
||||
chat/chat-room/abstract-chat-room-p.h
|
||||
chat/chat-room/abstract-chat-room.h
|
||||
chat/chat-room/basic-chat-room-p.h
|
||||
|
|
@ -191,6 +193,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
|
|||
call/local-conference-call.cpp
|
||||
call/remote-conference-call.cpp
|
||||
chat/chat-message/chat-message.cpp
|
||||
chat/chat-message/is-composing-message.cpp
|
||||
chat/chat-message/notification-message.cpp
|
||||
chat/chat-room/abstract-chat-room.cpp
|
||||
chat/chat-room/basic-chat-room.cpp
|
||||
|
|
|
|||
46
src/chat/chat-message/is-composing-message.cpp
Normal file
46
src/chat/chat-message/is-composing-message.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* is-composing-message.cpp
|
||||
* Copyright (C) 2010-2018 Belledonne Communications SARL
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "chat/chat-message/notification-message-p.h"
|
||||
#include "chat/chat-message/is-composing-message.h"
|
||||
#include "sip-tools/sip-headers.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
IsComposingMessage::IsComposingMessage (
|
||||
const shared_ptr<AbstractChatRoom> &chatRoom,
|
||||
IsComposing &isComposingHandler,
|
||||
bool isComposing
|
||||
) : NotificationMessage(*new NotificationMessagePrivate(chatRoom, ChatMessage::Direction::Outgoing)) {
|
||||
L_D();
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::ImIsComposing);
|
||||
content->setBody(isComposingHandler.marshal(isComposing));
|
||||
addContent(content);
|
||||
d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent);
|
||||
d->addSalCustomHeader("Expires", "0");
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
51
src/chat/chat-message/is-composing-message.h
Normal file
51
src/chat/chat-message/is-composing-message.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* is-composing-message.h
|
||||
* Copyright (C) 2010-2018 Belledonne Communications SARL
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _L_IS_COMPOSING_MESSAGE_H_
|
||||
#define _L_IS_COMPOSING_MESSAGE_H_
|
||||
|
||||
#include "chat/chat-message/notification-message.h"
|
||||
#include "chat/notification/is-composing.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class LINPHONE_PUBLIC IsComposingMessage : public NotificationMessage {
|
||||
public:
|
||||
friend class ChatRoomPrivate;
|
||||
|
||||
L_OVERRIDE_SHARED_FROM_THIS(IsComposingMessage);
|
||||
|
||||
virtual ~IsComposingMessage () = default;
|
||||
|
||||
private:
|
||||
IsComposingMessage (
|
||||
const std::shared_ptr<AbstractChatRoom> &chatRoom,
|
||||
IsComposing &isComposingHandler,
|
||||
bool isComposing
|
||||
);
|
||||
|
||||
L_DECLARE_PRIVATE(NotificationMessage);
|
||||
L_DISABLE_COPY(IsComposingMessage);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _L_IS_COMPOSING_MESSAGE_H_
|
||||
46
src/chat/chat-message/notification-message-p.h
Normal file
46
src/chat/chat-message/notification-message-p.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* notification-message-p.h
|
||||
* Copyright (C) 2010-2018 Belledonne Communications SARL
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _L_NOTIFICATION_MESSAGE_P_H_
|
||||
#define _L_NOTIFICATION_MESSAGE_P_H_
|
||||
|
||||
#include "chat/chat-message/chat-message-p.h"
|
||||
#include "chat/chat-message/notification-message.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class NotificationMessagePrivate : public ChatMessagePrivate {
|
||||
friend class IsComposingMessage;
|
||||
|
||||
private:
|
||||
NotificationMessagePrivate(const std::shared_ptr<AbstractChatRoom> &cr, ChatMessage::Direction dir)
|
||||
: ChatMessagePrivate(cr, dir) {}
|
||||
|
||||
void setDisplayNotificationRequired (bool value) override {}
|
||||
void setNegativeDeliveryNotificationRequired (bool value) override {}
|
||||
void setPositiveDeliveryNotificationRequired (bool value) override {}
|
||||
|
||||
L_DECLARE_PUBLIC(NotificationMessage);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _L_NOTIFICATION_MESSAGE_P_H_
|
||||
|
|
@ -17,8 +17,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "chat/chat-message/chat-message-p.h"
|
||||
#include "chat/chat-message/notification-message.h"
|
||||
#include "chat/chat-message/notification-message-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -26,22 +25,13 @@ using namespace std;
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class NotificationMessagePrivate : public ChatMessagePrivate {
|
||||
private:
|
||||
NotificationMessagePrivate(const std::shared_ptr<AbstractChatRoom> &cr, ChatMessage::Direction dir)
|
||||
: ChatMessagePrivate(cr, dir) {}
|
||||
|
||||
void setDisplayNotificationRequired (bool value) override {}
|
||||
void setNegativeDeliveryNotificationRequired (bool value) override {}
|
||||
void setPositiveDeliveryNotificationRequired (bool value) override {}
|
||||
|
||||
L_DECLARE_PUBLIC(NotificationMessage);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NotificationMessage::NotificationMessage (const shared_ptr<AbstractChatRoom> &chatRoom, ChatMessage::Direction direction) :
|
||||
ChatMessage(*new NotificationMessagePrivate(chatRoom, direction)) {
|
||||
NotificationMessage(*new NotificationMessagePrivate(chatRoom, direction)) {
|
||||
}
|
||||
|
||||
NotificationMessage::NotificationMessage (NotificationMessagePrivate &p) : ChatMessage(p) {
|
||||
L_D();
|
||||
d->displayNotificationRequired = false;
|
||||
d->negativeDeliveryNotificationRequired = false;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ public:
|
|||
|
||||
void setToBeStored (bool value) override;
|
||||
|
||||
protected:
|
||||
explicit NotificationMessage (NotificationMessagePrivate &p);
|
||||
|
||||
private:
|
||||
NotificationMessage (const std::shared_ptr<AbstractChatRoom> &chatRoom, ChatMessage::Direction direction);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public:
|
|||
void removeTransientEvent (const std::shared_ptr<EventLog> &eventLog) override;
|
||||
|
||||
std::shared_ptr<ChatMessage> createChatMessage (ChatMessage::Direction direction);
|
||||
std::shared_ptr<ChatMessage> createIsComposingMessage ();
|
||||
std::shared_ptr<ChatMessage> createNotificationMessage (ChatMessage::Direction direction);
|
||||
std::list<std::shared_ptr<ChatMessage>> findChatMessages (const std::string &messageId) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@
|
|||
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "chat/chat-message/chat-message-p.h"
|
||||
#include "chat/chat-message/is-composing-message.h"
|
||||
#include "chat/chat-message/notification-message.h"
|
||||
#include "chat/chat-room/chat-room-p.h"
|
||||
#include "core/core-p.h"
|
||||
#include "sip-tools/sip-headers.h"
|
||||
#include "logger/logger.h"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -77,20 +77,8 @@ void ChatRoomPrivate::sendIsComposingNotification () {
|
|||
if (!linphone_im_notif_policy_get_send_is_composing(policy))
|
||||
return;
|
||||
|
||||
string payload = isComposingHandler->marshal(isComposing);
|
||||
if (payload.empty())
|
||||
return;
|
||||
|
||||
Content *content = new Content();
|
||||
content->setContentType(ContentType::ImIsComposing);
|
||||
content->setBody(payload);
|
||||
|
||||
shared_ptr<ChatMessage> chatMessage = createNotificationMessage(ChatMessage::Direction::Outgoing);
|
||||
chatMessage->addContent(content);
|
||||
chatMessage->getPrivate()->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent);
|
||||
chatMessage->getPrivate()->addSalCustomHeader("Expires", "0");
|
||||
|
||||
chatMessage->getPrivate()->send();
|
||||
auto isComposingMsg = createIsComposingMessage();
|
||||
isComposingMsg->getPrivate()->send();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -121,6 +109,11 @@ shared_ptr<ChatMessage> ChatRoomPrivate::createChatMessage (ChatMessage::Directi
|
|||
return shared_ptr<ChatMessage>(new ChatMessage(q->getSharedFromThis(), direction));
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoomPrivate::createIsComposingMessage () {
|
||||
L_Q();
|
||||
return shared_ptr<ChatMessage>(new IsComposingMessage(q->getSharedFromThis(), *isComposingHandler.get(), isComposing));
|
||||
}
|
||||
|
||||
shared_ptr<ChatMessage> ChatRoomPrivate::createNotificationMessage (ChatMessage::Direction direction) {
|
||||
L_Q();
|
||||
return shared_ptr<ChatMessage>(new NotificationMessage(q->getSharedFromThis(), direction));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue