forked from mirrors/linphone-iphone
Fixes related to ChatRoom & ChatMessage
This commit is contained in:
parent
54d828c4d4
commit
20703484ff
6 changed files with 72 additions and 62 deletions
|
|
@ -94,7 +94,9 @@ LinphoneChatRoom *linphone_chat_message_get_chat_room(const LinphoneChatMessage
|
|||
}
|
||||
|
||||
const char *linphone_chat_message_get_external_body_url(const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getExternalBodyUrl().c_str();
|
||||
const string& external_body_url = L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getExternalBodyUrl();
|
||||
if (external_body_url.empty()) return NULL;
|
||||
return external_body_url.c_str();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_external_body_url(LinphoneChatMessage *msg, const char *url) {
|
||||
|
|
@ -162,7 +164,9 @@ bool_t linphone_chat_message_is_read(LinphoneChatMessage *msg) {
|
|||
}
|
||||
|
||||
const char *linphone_chat_message_get_appdata(const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getAppdata().c_str();
|
||||
const string& appData = L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getAppdata();
|
||||
if (appData.empty()) return NULL;
|
||||
return appData.c_str();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_appdata(LinphoneChatMessage *msg, const char *data) {
|
||||
|
|
@ -192,7 +196,9 @@ const LinphoneAddress *linphone_chat_message_get_to_address(LinphoneChatMessage
|
|||
}
|
||||
|
||||
const char *linphone_chat_message_get_file_transfer_filepath(LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getFileTransferFilepath().c_str();
|
||||
const string& path = L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getFileTransferFilepath();
|
||||
if (path.empty()) return NULL;
|
||||
return path.c_str();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_file_transfer_filepath(LinphoneChatMessage *msg, const char *filepath) {
|
||||
|
|
@ -241,7 +247,9 @@ void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const
|
|||
}
|
||||
|
||||
const char *linphone_chat_message_get_custom_header(LinphoneChatMessage *msg, const char *header_name) {
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalCustomHeaderValue(header_name).c_str();
|
||||
const string& header = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalCustomHeaderValue(header_name);
|
||||
if (header.empty()) return NULL;
|
||||
return header.c_str();
|
||||
}
|
||||
|
||||
const LinphoneErrorInfo *linphone_chat_message_get_error_info(const LinphoneChatMessage *msg) {
|
||||
|
|
@ -321,7 +329,9 @@ void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChat
|
|||
// =============================================================================
|
||||
|
||||
const char * linphone_chat_message_get_content_type(const LinphoneChatMessage *msg) {
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().c_str();
|
||||
const string& contentType = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType();
|
||||
if (contentType.empty()) return NULL;
|
||||
return contentType.c_str();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type) {
|
||||
|
|
@ -329,7 +339,9 @@ void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char
|
|||
}
|
||||
|
||||
const char *linphone_chat_message_get_text(const LinphoneChatMessage *msg) {
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getText().c_str();
|
||||
const string& text = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getText();
|
||||
if (text.empty()) return NULL;
|
||||
return text.c_str();
|
||||
}
|
||||
|
||||
int linphone_chat_message_set_text(LinphoneChatMessage *msg, const char* text) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,9 @@ void linphone_chat_room_remove_transient_message (LinphoneChatRoom *cr, Linphone
|
|||
}
|
||||
|
||||
void linphone_chat_room_send_message (LinphoneChatRoom *cr, const char *msg) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->sendMessage(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(msg));
|
||||
LinphoneChatMessage *message = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(msg);
|
||||
ms_error("%s / %s", linphone_chat_message_get_text(message), linphone_chat_message_get_content_type(message));
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->sendMessage(message);
|
||||
}
|
||||
|
||||
bool_t linphone_chat_room_is_remote_composing (const LinphoneChatRoom *cr) {
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ public:
|
|||
// Methods only used for C wrapper
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
std::string getContentType() const;
|
||||
void setContentType(std::string contentType);
|
||||
const std::string& getContentType() const;
|
||||
void setContentType(const std::string& contentType);
|
||||
|
||||
std::string getText() const;
|
||||
void setText(std::string text);
|
||||
const std::string& getText() const;
|
||||
void setText(const std::string& text);
|
||||
|
||||
LinphoneContent * getFileTransferInformation() const;
|
||||
void setFileTransferInformation(LinphoneContent *content);
|
||||
|
|
@ -104,11 +104,11 @@ private:
|
|||
std::shared_ptr<Address> from;
|
||||
std::shared_ptr<Address> to;
|
||||
time_t time = 0;
|
||||
std::string id;
|
||||
std::string appData;
|
||||
std::string fileTransferFilePath;
|
||||
std::string externalBodyUrl;
|
||||
std::string rttMessage;
|
||||
std::string id = "";
|
||||
std::string appData = "";
|
||||
std::string fileTransferFilePath = "";
|
||||
std::string externalBodyUrl = "";
|
||||
std::string rttMessage = "";
|
||||
bool isSecured = false;
|
||||
bool isReadOnly = false;
|
||||
bool isToBeStored = false;
|
||||
|
|
@ -116,16 +116,16 @@ private:
|
|||
std::shared_ptr<Content> internalContent;
|
||||
std::unordered_map<std::string, std::string> customHeaders;
|
||||
std::shared_ptr<EventsDb> eventsDb;
|
||||
mutable LinphoneErrorInfo * errorInfo;
|
||||
belle_http_request_t *httpRequest;
|
||||
belle_http_request_listener_t *httpListener;
|
||||
SalOp *salOp;
|
||||
SalCustomHeader *salCustomHeaders;
|
||||
mutable LinphoneErrorInfo * errorInfo = NULL;
|
||||
belle_http_request_t *httpRequest = NULL;
|
||||
belle_http_request_listener_t *httpListener = NULL;
|
||||
SalOp *salOp = NULL;
|
||||
SalCustomHeader *salCustomHeaders = NULL;
|
||||
unsigned long backgroundTaskId;
|
||||
// Used for compatibility with previous C API
|
||||
std::string cContentType;
|
||||
std::string cText;
|
||||
LinphoneContent *cFileTransferInformation;
|
||||
std::string cContentType = "";
|
||||
std::string cText = "";
|
||||
LinphoneContent *cFileTransferInformation = NULL;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ using namespace std;
|
|||
// =============================================================================
|
||||
|
||||
ChatMessagePrivate::ChatMessagePrivate (const shared_ptr<ChatRoom> &room)
|
||||
: chatRoom(room) {}
|
||||
: chatRoom(room) {
|
||||
}
|
||||
|
||||
ChatMessagePrivate::~ChatMessagePrivate () {}
|
||||
|
||||
|
|
@ -132,19 +133,19 @@ string ChatMessagePrivate::getSalCustomHeaderValue(string name) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string ChatMessagePrivate::getContentType() const {
|
||||
const string& ChatMessagePrivate::getContentType() const {
|
||||
return cContentType;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setContentType(string contentType) {
|
||||
void ChatMessagePrivate::setContentType(const string& contentType) {
|
||||
cContentType = contentType;
|
||||
}
|
||||
|
||||
string ChatMessagePrivate::getText() const {
|
||||
const string& ChatMessagePrivate::getText() const {
|
||||
return cText;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setText(string text) {
|
||||
void ChatMessagePrivate::setText(const string& text) {
|
||||
cText = text;
|
||||
}
|
||||
|
||||
|
|
@ -876,7 +877,7 @@ shared_ptr<ChatRoom> ChatMessage::getChatRoom () const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string ChatMessage::getExternalBodyUrl() const {
|
||||
const string& ChatMessage::getExternalBodyUrl() const {
|
||||
L_D();
|
||||
return d->externalBodyUrl;
|
||||
}
|
||||
|
|
@ -921,12 +922,12 @@ ChatMessage::State ChatMessage::getState() const {
|
|||
return d->state;
|
||||
}
|
||||
|
||||
string ChatMessage::getId () const {
|
||||
const string& ChatMessage::getId () const {
|
||||
L_D();
|
||||
return d->id;
|
||||
}
|
||||
|
||||
void ChatMessage::setId (string id) {
|
||||
void ChatMessage::setId (const string& id) {
|
||||
L_D();
|
||||
d->id = id;
|
||||
}
|
||||
|
|
@ -941,7 +942,7 @@ bool ChatMessage::isRead() const {
|
|||
return d->state == Delivered || d->state == Displayed || d->state == DeliveredToUser;
|
||||
}
|
||||
|
||||
string ChatMessage::getAppdata () const {
|
||||
const string& ChatMessage::getAppdata () const {
|
||||
L_D();
|
||||
return d->appData;
|
||||
}
|
||||
|
|
@ -972,7 +973,7 @@ void ChatMessage::setToAddress(shared_ptr<Address> to) {
|
|||
d->to = to;
|
||||
}
|
||||
|
||||
string ChatMessage::getFileTransferFilepath() const {
|
||||
const string& ChatMessage::getFileTransferFilepath() const {
|
||||
L_D();
|
||||
return d->fileTransferFilePath;
|
||||
}
|
||||
|
|
@ -1035,7 +1036,7 @@ string ChatMessage::getCustomHeaderValue (const string &headerName) const {
|
|||
} catch (const exception &) {
|
||||
// Key doesn't exist.
|
||||
}
|
||||
return "";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ChatMessage::addCustomHeader (const string &headerName, const string &headerValue) {
|
||||
|
|
@ -1080,8 +1081,6 @@ void ChatMessage::send () {
|
|||
ccmm.encode(d);
|
||||
}
|
||||
|
||||
// TODO.
|
||||
|
||||
d->isReadOnly = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public:
|
|||
bool isOutgoing () const;
|
||||
bool isIncoming () const;
|
||||
|
||||
std::string getExternalBodyUrl() const;
|
||||
const std::string& getExternalBodyUrl() const;
|
||||
void setExternalBodyUrl(const std::string &url);
|
||||
|
||||
time_t getTime () const;
|
||||
|
|
@ -97,12 +97,12 @@ public:
|
|||
|
||||
State getState() const;
|
||||
|
||||
std::string getId () const;
|
||||
void setId (std::string);
|
||||
const std::string& getId () const;
|
||||
void setId (const std::string&);
|
||||
|
||||
bool isRead() const;
|
||||
|
||||
std::string getAppdata () const;
|
||||
const std::string& getAppdata () const;
|
||||
void setAppdata (const std::string &appData);
|
||||
|
||||
std::shared_ptr<Address> getFromAddress () const;
|
||||
|
|
@ -111,7 +111,7 @@ public:
|
|||
std::shared_ptr<Address> getToAddress () const;
|
||||
void setToAddress(std::shared_ptr<Address> to);
|
||||
|
||||
std::string getFileTransferFilepath() const;
|
||||
const std::string& getFileTransferFilepath() const;
|
||||
void setFileTransferFilepath(const std::string &path);
|
||||
|
||||
bool isToBeStored() const;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include "imdn.h"
|
||||
#include "logger/logger.h"
|
||||
|
||||
#include "chat-message.h"
|
||||
#include "chat-message-p.h"
|
||||
#include "chat-room.h"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -592,31 +592,28 @@ void ChatRoom::compose () {
|
|||
|
||||
LinphoneChatMessage *ChatRoom::createFileTransferMessage (const LinphoneContent *initialContent) {
|
||||
L_D();
|
||||
LinphoneChatMessage *msg = createMessage("");
|
||||
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);
|
||||
LinphoneAddress *peer = linphone_address_new(d->peerAddress.asString().c_str());
|
||||
linphone_chat_message_set_to_address(msg, peer);
|
||||
linphone_address_unref(peer);
|
||||
linphone_chat_message_set_from_address(msg, linphone_address_new(linphone_core_get_identity(d->core)));
|
||||
/* This will be set to application/vnd.gsma.rcs-ft-http+xml when we will transfer the xml reply from server to the peers */
|
||||
linphone_chat_message_set_content_type(msg, NULL);
|
||||
/* This will store the http request during file upload to the server */
|
||||
linphone_chat_message_set_http_request(msg, NULL);
|
||||
linphone_chat_message_set_time(msg, ms_time(0));
|
||||
|
||||
shared_ptr<ChatMessage> chatMessage = make_shared<ChatMessage>(static_pointer_cast<ChatRoom>(shared_from_this()));
|
||||
|
||||
chatMessage->getPrivate()->setTime(ms_time(0));
|
||||
chatMessage->getPrivate()->setContentType("text/plain");
|
||||
chatMessage->getPrivate()->setDirection(ChatMessage::Direction::Outgoing);
|
||||
chatMessage->getPrivate()->setFileTransferInformation(linphone_content_copy(initialContent));
|
||||
chatMessage->setToAddress(make_shared<Address>(d->peerAddress.asString().c_str()));
|
||||
chatMessage->setFromAddress(make_shared<Address>(linphone_core_get_identity(d->core)));
|
||||
|
||||
LinphoneChatMessage *msg = chatMessage->getBackPtr();
|
||||
return msg;
|
||||
}
|
||||
|
||||
LinphoneChatMessage *ChatRoom::createMessage (const string &message) {
|
||||
shared_ptr<ChatMessage> chatMessage = make_shared<ChatMessage>(static_pointer_cast<ChatRoom>(shared_from_this()));
|
||||
|
||||
chatMessage->getPrivate()->setTime(ms_time(0));
|
||||
chatMessage->getPrivate()->setContentType("text/plain");
|
||||
chatMessage->getPrivate()->setText(message);
|
||||
|
||||
LinphoneChatMessage *msg = chatMessage->getBackPtr();
|
||||
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"));
|
||||
linphone_chat_message_set_file_transfer_information(msg, nullptr);
|
||||
linphone_chat_message_set_http_request(msg, NULL);
|
||||
linphone_chat_message_set_time(msg, ms_time(0));
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue