From 098660726fb189c58cde0b4e7f143ea8591a2afa Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 10 Nov 2017 15:27:06 +0100 Subject: [PATCH] feat(ChatRoom): add a chat room identifier object --- src/CMakeLists.txt | 2 + src/chat/chat-room/chat-room-id.cpp | 67 +++++++++++++++++++++++++++++ src/chat/chat-room/chat-room-id.h | 47 ++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 src/chat/chat-room/chat-room-id.cpp create mode 100644 src/chat/chat-room/chat-room-id.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f633fc847..f90b0134d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES chat/chat-message/chat-message.h chat/chat-room/basic-chat-room-p.h chat/chat-room/basic-chat-room.h + chat/chat-room/chat-room-id.h chat/chat-room/chat-room-p.h chat/chat-room/chat-room.h chat/chat-room/client-group-chat-room-p.h @@ -159,6 +160,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES call/call.cpp chat/chat-message/chat-message.cpp chat/chat-room/basic-chat-room.cpp + chat/chat-room/chat-room-id.cpp chat/chat-room/chat-room.cpp chat/chat-room/client-group-chat-room.cpp chat/chat-room/real-time-text-chat-room.cpp diff --git a/src/chat/chat-room/chat-room-id.cpp b/src/chat/chat-room/chat-room-id.cpp new file mode 100644 index 000000000..9887f1229 --- /dev/null +++ b/src/chat/chat-room/chat-room-id.cpp @@ -0,0 +1,67 @@ +/* + * chat-room-id.cpp + * Copyright (C) 2010-2017 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 "object/clonable-object-p.h" + +#include "chat-room-id.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +class ChatRoomIdPrivate : public ClonableObjectPrivate { +public: + SimpleAddress peerAddress; + SimpleAddress localAddress; +}; + +// ----------------------------------------------------------------------------- + +ChatRoomId::ChatRoomId ( + const SimpleAddress &peerAddress, + const SimpleAddress &localAddress +) : ClonableObject(*new ChatRoomIdPrivate) { + L_D(); + d->peerAddress = peerAddress; + d->localAddress = localAddress; +} + +bool ChatRoomId::operator== (const ChatRoomId &chatRoomId) const { + L_D(); + const ChatRoomIdPrivate *dChatRoomId = chatRoomId.getPrivate(); + return d->peerAddress == dChatRoomId->peerAddress && d->localAddress == dChatRoomId->localAddress; +} + +bool ChatRoomId::operator!= (const ChatRoomId &chatRoomId) const { + return !(*this == chatRoomId); +} + +const SimpleAddress &ChatRoomId::getPeerAddress () const { + L_D(); + return d->peerAddress; +} + +const SimpleAddress &ChatRoomId::getLocalAddress () const { + L_D(); + return d->localAddress; +} + +LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-room/chat-room-id.h b/src/chat/chat-room/chat-room-id.h new file mode 100644 index 000000000..3ab346e01 --- /dev/null +++ b/src/chat/chat-room/chat-room-id.h @@ -0,0 +1,47 @@ +/* + * chat-room-id.h + * Copyright (C) 2010-2017 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 _CHAT_ROOM_ID_H_ +#define _CHAT_ROOM_ID_H_ + +#include "address/simple-address.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class ChatRoomIdPrivate; + +class LINPHONE_PUBLIC ChatRoomId : public ClonableObject { +public: + ChatRoomId (const SimpleAddress &peerAddress, const SimpleAddress &localAddress); + + bool operator== (const ChatRoomId &chatRoomId) const; + bool operator!= (const ChatRoomId &chatRoomId) const; + + const SimpleAddress &getPeerAddress () const; + const SimpleAddress &getLocalAddress () const; + +private: + L_DECLARE_PRIVATE(ChatRoomId); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _CHAT_ROOM_ID_H_