Commit 78f4b39a authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Finish cleaning of c-chat-message, still work to do in ChatMessage

parent 20690528
......@@ -1099,7 +1099,6 @@ void linphone_chat_message_set_file_transfer_information(LinphoneChatMessage *ms
LinphoneChatMessageDir linphone_chat_message_get_direction(const LinphoneChatMessage *msg);
SalOp * linphone_chat_message_get_sal_op(const LinphoneChatMessage *msg);
void linphone_chat_message_set_sal_op(LinphoneChatMessage *msg, SalOp *op);
void linphone_chat_message_set_chat_room(LinphoneChatMessage *msg, LinphoneChatRoom *room);
void linphone_chat_message_destroy(LinphoneChatMessage* msg);
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secured);
......
......@@ -105,7 +105,7 @@ LINPHONE_PUBLIC void linphone_chat_message_set_from_address(LinphoneChatMessage*
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(const LinphoneChatMessage* msg);
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(LinphoneChatMessage* msg);
/**
* Set destination of the message
......@@ -119,7 +119,7 @@ LINPHONE_PUBLIC void linphone_chat_message_set_to_address(LinphoneChatMessage* m
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(const LinphoneChatMessage* msg);
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(LinphoneChatMessage* msg);
/**
* Get the content type of a chat message.
......@@ -301,7 +301,7 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_peer_address(Li
*@param message #LinphoneChatMessage obj
*@return #LinphoneAddress
*/
LINPHONE_PUBLIC LinphoneAddress *linphone_chat_message_get_local_address(const LinphoneChatMessage* message);
LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_message_get_local_address(LinphoneChatMessage* message);
/**
* Add custom headers to the message.
......
This diff is collapsed.
......@@ -41,18 +41,23 @@ private:
ChatMessage::Direction direction = ChatMessage::Incoming;
ChatMessage::State state = ChatMessage::Idle;
unsigned int storageId;
// LinphoneAddress *from;
// LinphoneAddress *to;
std::shared_ptr<Address> from;
std::shared_ptr<Address> to;
time_t time = 0;
std::string id;
std::string appData;
std::string fileTransferFilePath;
bool isSecured = false;
bool isReadOnly = false;
bool isToBeStored = false;
std::list<std::shared_ptr<Content> > contents;
std::shared_ptr<Content> internalContent;
std::unordered_map<std::string, std::string> customHeaders;
std::shared_ptr<EventsDb> eventsDb;
std::shared_ptr<ErrorInfo> errorInfo;
belle_http_request_t *httpRequest;
SalOp *salOp;
SalCustomHeader *salCustomHeaders;
L_DECLARE_PUBLIC(ChatMessage);
};
......
This diff is collapsed.
......@@ -22,6 +22,8 @@
#include <list>
#include <memory>
#include "imdn.h"
#include "linphone/api/c-types.h"
#include "linphone/api/c-chat-message.h"
#include "object/object.h"
......@@ -62,7 +64,24 @@ public:
LinphoneChatMessage * getBackPtr();
std::shared_ptr<ChatRoom> getChatRoom () const;
void setChatRoom (std::shared_ptr<ChatRoom> cr);
// -----------------------------------------------------------------------------
// Methods
// -----------------------------------------------------------------------------
void updateState(State state);
void reSend();
void sendImdn();
void sendDeliveryNotification();
void sendDisplayNotification();
int uploadFile();
int downloadFile();
void cancelFileTransfer();
int putCharacter(uint32_t character);
// -----------------------------------------------------------------------------
// Getters & setters
// -----------------------------------------------------------------------------
Direction getDirection () const;
......@@ -89,25 +108,50 @@ public:
std::string getAppdata () const;
void setAppdata (const std::string &appData);
std::shared_ptr<Address> getFromAddress () const;
void setFromAddress(std::shared_ptr<Address> from);
std::shared_ptr<Address> getToAddress () const;
void setToAddress(std::shared_ptr<Address> to);
std::string getFileTransferFilepath() const;
void setFileTransferFilepath(const std::string &path);
bool isToBeStored() const;
void setIsToBeStored(bool store);
// -----------------------------------------------------------------------------
// Deprecated methods, only used for C wrapper
// -----------------------------------------------------------------------------
std::string getContentType() const;
void setContentType(std::string contentType);
std::string getText() const;
void setText(std::string text);
std::shared_ptr<Content> getFileTransferInformation() const;
void setFileTransferInformation(std::shared_ptr<Content> content);
unsigned int getStorageId() const;
void setStorageId(unsigned int id);
void setTime(time_t time);
// -----------------------------------------------------------------------------
belle_http_request_t *getHttpRequest() const;
void setHttpRequest(belle_http_request_t *request);
SalOp *getSalOp() const;
void setSalOp(SalOp *op);
std::shared_ptr<const Address> getFromAddress () const;
std::shared_ptr<const Address> getToAddress () const;
std::shared_ptr<const Address> getLocalAddress () const;
std::shared_ptr<const Address> getRemoteAddress () const;
SalCustomHeader *getSalCustomHeaders() const;
void setSalCustomHeaders(SalCustomHeader *headers);
void addSalCustomHeader(std::string name, std::string value);
void removeSalCustomHeader(std::string name);
std::string getSalCustomHeaderValue(std::string name);
// -----------------------------------------------------------------------------
std::shared_ptr<const ErrorInfo> getErrorInfo () const;
......
......@@ -593,7 +593,6 @@ void ChatRoom::compose () {
LinphoneChatMessage *ChatRoom::createFileTransferMessage (const LinphoneContent *initialContent) {
L_D(ChatRoom);
LinphoneChatMessage *msg = createMessage("");
linphone_chat_message_set_chat_room(msg, L_GET_C_BACK_PTR(this));
linphone_chat_message_set_text(msg, NULL);
linphone_chat_message_set_file_transfer_information(msg, linphone_content_copy(initialContent));
linphone_chat_message_set_outgoing(msg);
......@@ -612,7 +611,6 @@ LinphoneChatMessage *ChatRoom::createFileTransferMessage (const LinphoneContent
LinphoneChatMessage *ChatRoom::createMessage (const string &message) {
shared_ptr<ChatMessage> chatMessage = make_shared<ChatMessage>(static_pointer_cast<ChatRoom>(shared_from_this()));
LinphoneChatMessage *msg = chatMessage->getBackPtr();
linphone_chat_message_set_chat_room(msg, L_GET_C_BACK_PTR(this));
linphone_chat_message_set_state(msg, LinphoneChatMessageStateIdle);
linphone_chat_message_set_text(msg, message.empty() ? nullptr : ms_strdup(message.c_str()));
linphone_chat_message_set_content_type(msg, ms_strdup("text/plain"));
......
......@@ -741,7 +741,7 @@ static void file_transfer_2_messages_simultaneously(void) {
linphone_chat_room_send_chat_message(pauline_room,msg);
linphone_chat_room_send_chat_message(pauline_room,msg2);
if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1, 60000))) {
msg = linphone_chat_message_clone(marie->stat.last_received_chat_message);
msg = linphone_chat_message_ref(marie->stat.last_received_chat_message);
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2, 60000));
msg2 = marie->stat.last_received_chat_message;
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, unsigned int, "%u");
......
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