fix(ChatMessage): use L_DECLARE_ENUM to declare direction

This commit is contained in:
Ronan Abhamon 2017-10-11 11:56:17 +02:00
parent 6cdd92ef8a
commit 7f32ae8582
5 changed files with 63 additions and 58 deletions

View file

@ -137,6 +137,12 @@ typedef struct _LinphoneChatMessageEvent LinphoneChatMessageEvent;
*/
L_DECLARE_C_ENUM(ChatMessageState, L_ENUM_VALUES_CHAT_MESSAGE_STATE);
/**
* LinphoneChatMessageDirection is used to indicate if a message is outgoing or incoming.
* @ingroup chatroom
*/
L_DECLARE_C_ENUM(ChatMessageDirection, L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION);
L_DECLARE_C_ENUM(ChatRoomState, L_ENUM_VALUES_CHAT_ROOM_STATE);
L_DECLARE_C_ENUM(EventLogType, L_ENUM_VALUES_EVENT_LOG_TYPE);

View file

@ -32,4 +32,8 @@
F(DeliveredToUser) \
F(Displayed)
#define L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION(F) \
F(Incoming) \
F(Outgoing)
#endif // ifndef _CHAT_MESSAGE_ENUMS_H_

View file

@ -1124,7 +1124,7 @@ void ChatMessagePrivate::send() {
//TODO Remove : This won't be necessary once we store the contentsList
string clearTextMessage;
ContentType clearTextContentType;
if (!getText().empty()) {
clearTextMessage = getText().c_str();
}
@ -1271,12 +1271,12 @@ ChatMessage::Direction ChatMessage::getDirection () const {
bool ChatMessage::isOutgoing () const {
L_D();
return d->direction == Outgoing;
return d->direction == Direction::Outgoing;
}
bool ChatMessage::isIncoming () const {
L_D();
return d->direction == Incoming;
return d->direction == Direction::Incoming;
}
ChatMessage::State ChatMessage::getState() const {
@ -1556,7 +1556,7 @@ int ChatMessage::putCharacter(uint32_t character) {
lDebug() << "New line sent, forge a message with content " << d->rttMessage.c_str();
d->setTime(ms_time(0));
d->state = State::Displayed;
d->direction = Outgoing;
d->direction = Direction::Outgoing;
setFromAddress(LinphonePrivate::Address(linphone_address_as_string(linphone_address_new(linphone_core_get_identity(lc)))));
linphone_chat_message_store(L_GET_C_BACK_PTR(this));
d->rttMessage = "";

View file

@ -33,7 +33,6 @@ LINPHONE_BEGIN_NAMESPACE
class Address;
class ChatRoom;
class ChatRoomPrivate;
class Content;
class ErrorInfo;
class ChatMessagePrivate;
@ -46,96 +45,92 @@ class LINPHONE_PUBLIC ChatMessage : public Object {
public:
L_OVERRIDE_SHARED_FROM_THIS(ChatMessage);
enum Direction {
Incoming,
Outgoing
};
L_DECLARE_ENUM(State, L_ENUM_VALUES_CHAT_MESSAGE_STATE);
L_DECLARE_ENUM(Direction, L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION);
ChatMessage(const std::shared_ptr<ChatRoom> &room);
virtual ~ChatMessage() = default;
ChatMessage (const std::shared_ptr<ChatRoom> &chatRoom);
virtual ~ChatMessage () = default;
LinphoneChatMessage * getBackPtr();
LinphoneChatMessage *getBackPtr ();
std::shared_ptr<ChatRoom> getChatRoom() const;
std::shared_ptr<ChatRoom> getChatRoom () const;
// -----------------------------------------------------------------------------
// Methods
// -----------------------------------------------------------------------------
void store();
void store ();
void updateState(State state);
void updateState (State state);
void reSend();
void reSend ();
void sendDeliveryNotification(LinphoneReason reason);
void sendDeliveryNotification (LinphoneReason reason);
void sendDisplayNotification();
void sendDisplayNotification ();
int uploadFile();
int uploadFile ();
int downloadFile();
int downloadFile ();
void cancelFileTransfer();
void cancelFileTransfer ();
int putCharacter(uint32_t character);
int putCharacter (uint32_t character);
// -----------------------------------------------------------------------------
// Getters & setters
// -----------------------------------------------------------------------------
Direction getDirection() const;
bool isOutgoing() const;
bool isIncoming() const;
Direction getDirection () const;
bool isOutgoing () const;
bool isIncoming () const;
const std::string& getExternalBodyUrl() const;
void setExternalBodyUrl(const std::string &url);
const std::string &getExternalBodyUrl () const;
void setExternalBodyUrl (const std::string &url);
time_t getTime() const;
time_t getTime () const;
bool isSecured() const;
void setIsSecured(bool isSecured);
bool isSecured () const;
void setIsSecured (bool isSecured);
State getState() const;
State getState () const;
const std::string& getId() const;
void setId(const std::string&);
const std::string &getId () const;
void setId (const std::string &);
bool isRead() const;
bool isRead () const;
const std::string& getAppdata() const;
void setAppdata(const std::string &appData);
const std::string &getAppdata () const;
void setAppdata (const std::string &appData);
const Address& getFromAddress() const;
void setFromAddress(Address from);
void setFromAddress(const std::string& from);
const Address &getFromAddress () const;
void setFromAddress (Address from);
void setFromAddress (const std::string &from);
const Address& getToAddress() const;
void setToAddress(Address to);
void setToAddress(const std::string& to);
const Address &getToAddress () const;
void setToAddress (Address to);
void setToAddress (const std::string &to);
const std::string& getFileTransferFilepath() const;
void setFileTransferFilepath(const std::string &path);
const std::string &getFileTransferFilepath () const;
void setFileTransferFilepath (const std::string &path);
const LinphoneErrorInfo * getErrorInfo() const;
const LinphoneErrorInfo *getErrorInfo () const;
bool isReadOnly() const;
bool isReadOnly () const;
const std::list<Content>& getContents() const;
void addContent(const Content& content);
void removeContent(const Content& content);
const std::list<Content> &getContents () const;
void addContent (const Content &content);
void removeContent (const Content &content);
const Content& getInternalContent() const;
void setInternalContent(const Content& content);
const Content &getInternalContent () const;
void setInternalContent (const Content &content);
std::string getCustomHeaderValue(const std::string &headerName) const;
void addCustomHeader(const std::string &headerName, const std::string &headerValue);
void removeCustomHeader(const std::string &headerName);
std::string getCustomHeaderValue (const std::string &headerName) const;
void addCustomHeader (const std::string &headerName, const std::string &headerValue);
void removeCustomHeader (const std::string &headerName);
protected:
explicit ChatMessage(ChatMessagePrivate &p);
explicit ChatMessage (ChatMessagePrivate &p);
private:
L_DECLARE_PRIVATE(ChatMessage);

View file

@ -280,7 +280,7 @@ int ChatRoomPrivate::createChatMessageFromDb (int argc, char **argv, char **colN
message->addContent(content);
Address peer(peerAddress.asString());
if (atoi(argv[3]) == ChatMessage::Direction::Incoming) {
if (atoi(argv[3]) == static_cast<int>(ChatMessage::Direction::Incoming)) {
message->getPrivate()->setDirection(ChatMessage::Direction::Incoming);
message->setFromAddress(peer);
} else {
@ -552,7 +552,7 @@ void ChatRoom::compose () {
shared_ptr<ChatMessage> ChatRoom::createFileTransferMessage (const LinphoneContent *initialContent) {
L_D();
shared_ptr<ChatMessage> chatMessage = createMessage();
/* TODO
Content content;
content.setContentType(ContentType::FileTransfer);