mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
Move some code from ChatMessage to ChatMessagePrivate
This commit is contained in:
parent
c156730daa
commit
6ca6fb6d89
5 changed files with 266 additions and 269 deletions
|
|
@ -106,7 +106,7 @@ time_t linphone_chat_message_get_time(const LinphoneChatMessage *msg) {
|
|||
}
|
||||
|
||||
void linphone_chat_message_set_time(LinphoneChatMessage *msg, time_t time) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setTime(time);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setTime(time);
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_secured(LinphoneChatMessage *msg) {
|
||||
|
|
@ -134,7 +134,7 @@ void linphone_chat_message_set_outgoing(LinphoneChatMessage *msg) {
|
|||
}
|
||||
|
||||
unsigned int linphone_chat_message_get_storage_id(LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getStorageId();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getStorageId();
|
||||
}
|
||||
|
||||
LinphoneChatMessageState linphone_chat_message_get_state(const LinphoneChatMessage *msg) {
|
||||
|
|
@ -154,7 +154,7 @@ void linphone_chat_message_set_message_id(LinphoneChatMessage *msg, char *id) {
|
|||
}
|
||||
|
||||
void linphone_chat_message_set_storage_id(LinphoneChatMessage *msg, unsigned int id) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setStorageId(id);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setStorageId(id);
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_read(LinphoneChatMessage *msg) {
|
||||
|
|
@ -208,40 +208,40 @@ void linphone_chat_message_set_to_be_stored(LinphoneChatMessage *msg, bool_t to_
|
|||
}
|
||||
|
||||
belle_http_request_t * linphone_chat_message_get_http_request(LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getHttpRequest();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getHttpRequest();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_http_request(LinphoneChatMessage *msg, belle_http_request_t *request) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setHttpRequest(request);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setHttpRequest(request);
|
||||
}
|
||||
|
||||
SalOp * linphone_chat_message_get_sal_op(const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getSalOp();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalOp();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_sal_op(LinphoneChatMessage *msg, SalOp *op) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setSalOp(op);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setSalOp(op);
|
||||
}
|
||||
|
||||
SalCustomHeader * linphone_chat_message_get_sal_custom_headers(const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getSalCustomHeaders();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalCustomHeaders();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_sal_custom_headers(LinphoneChatMessage *msg, SalCustomHeader *header) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setSalCustomHeaders(header);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setSalCustomHeaders(header);
|
||||
}
|
||||
|
||||
void linphone_chat_message_add_custom_header(LinphoneChatMessage *msg, const char *header_name,
|
||||
const char *header_value) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->addSalCustomHeader(header_name, header_value);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->addSalCustomHeader(header_name, header_value);
|
||||
}
|
||||
|
||||
void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->removeSalCustomHeader(header_name);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->removeSalCustomHeader(header_name);
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_custom_header(LinphoneChatMessage *msg, const char *header_name) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getSalCustomHeaderValue(header_name).c_str();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalCustomHeaderValue(header_name).c_str();
|
||||
}
|
||||
|
||||
const LinphoneErrorInfo *linphone_chat_message_get_error_info(const LinphoneChatMessage *msg) {
|
||||
|
|
@ -276,12 +276,12 @@ void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMe
|
|||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->updateState((LinphonePrivate::ChatMessage::State) new_state);
|
||||
}
|
||||
void linphone_chat_message_send_imdn(LinphoneChatMessage *msg, ImdnType imdn_type, LinphoneReason reason) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->sendImdn(imdn_type, reason);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->sendImdn(imdn_type, reason);
|
||||
}
|
||||
|
||||
void linphone_chat_message_deactivate(LinphoneChatMessage *msg){
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->cancelFileTransfer();
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setChatRoom(nullptr);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setChatRoom(nullptr);
|
||||
}
|
||||
|
||||
void linphone_chat_message_send_delivery_notification(LinphoneChatMessage *msg, LinphoneReason reason) {
|
||||
|
|
@ -321,28 +321,28 @@ 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_CPP_PTR_FROM_C_OBJECT(msg)->getContentType().c_str();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().c_str();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setContentType(content_type);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setContentType(content_type);
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_text(const LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getText().c_str();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getText().c_str();
|
||||
}
|
||||
|
||||
int linphone_chat_message_set_text(LinphoneChatMessage *msg, const char* text) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setText(text);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setText(text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LinphoneContent *linphone_chat_message_get_file_transfer_information(LinphoneChatMessage *msg) {
|
||||
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getFileTransferInformation();
|
||||
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getFileTransferInformation();
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_file_transfer_information(LinphoneChatMessage *msg, LinphoneContent *content) {
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setFileTransferInformation(content);
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setFileTransferInformation(content);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -35,6 +35,45 @@ public:
|
|||
ChatMessagePrivate (const std::shared_ptr<ChatRoom> &room);
|
||||
virtual ~ChatMessagePrivate ();
|
||||
|
||||
void setChatRoom (std::shared_ptr<ChatRoom> chatRoom);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setTime(time_t time);
|
||||
|
||||
unsigned int getStorageId() const;
|
||||
void setStorageId(unsigned int id);
|
||||
|
||||
belle_http_request_t *getHttpRequest() const;
|
||||
void setHttpRequest(belle_http_request_t *request);
|
||||
|
||||
SalOp *getSalOp() const;
|
||||
void setSalOp(SalOp *op);
|
||||
|
||||
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);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Methods only used for C wrapper
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
std::string getContentType() const;
|
||||
void setContentType(std::string contentType);
|
||||
|
||||
std::string getText() const;
|
||||
void setText(std::string text);
|
||||
|
||||
LinphoneContent * getFileTransferInformation() const;
|
||||
void setFileTransferInformation(LinphoneContent *content);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void sendImdn(ImdnType imdnType, LinphoneReason reason);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ChatRoom> chatRoom;
|
||||
std::string externalBodyUrl;
|
||||
|
|
@ -62,6 +101,9 @@ private:
|
|||
std::string cContentType;
|
||||
std::string cText;
|
||||
LinphoneContent *cFileTransferInformation;
|
||||
|
||||
std::string createImdnXml(ImdnType imdnType, LinphoneReason reason);
|
||||
|
||||
L_DECLARE_PUBLIC(ChatMessage);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "modifier/multipart-chat-message-modifier.h"
|
||||
#include "modifier/cpim-chat-message-modifier.h"
|
||||
#include "chat-room.h"
|
||||
#include "chat-room-p.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -48,6 +48,196 @@ ChatMessagePrivate::~ChatMessagePrivate () {}
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatMessagePrivate::setChatRoom (shared_ptr<ChatRoom> cr) {
|
||||
chatRoom = cr;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setTime(time_t t) {
|
||||
time = t;
|
||||
}
|
||||
|
||||
unsigned int ChatMessagePrivate::getStorageId() const {
|
||||
return storageId;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setStorageId(unsigned int id) {
|
||||
storageId = id;
|
||||
}
|
||||
|
||||
belle_http_request_t *ChatMessagePrivate::getHttpRequest() const {
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setHttpRequest(belle_http_request_t *request) {
|
||||
httpRequest = request;
|
||||
}
|
||||
|
||||
SalOp *ChatMessagePrivate::getSalOp() const {
|
||||
return salOp;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setSalOp(SalOp *op) {
|
||||
salOp = op;
|
||||
}
|
||||
|
||||
SalCustomHeader *ChatMessagePrivate::getSalCustomHeaders() const {
|
||||
return salCustomHeaders;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setSalCustomHeaders(SalCustomHeader *headers) {
|
||||
salCustomHeaders = headers;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::addSalCustomHeader(string name, string value) {
|
||||
salCustomHeaders = sal_custom_header_append(salCustomHeaders, name.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::removeSalCustomHeader(string name) {
|
||||
salCustomHeaders = sal_custom_header_remove(salCustomHeaders, name.c_str());
|
||||
}
|
||||
|
||||
string ChatMessagePrivate::getSalCustomHeaderValue(string name) {
|
||||
return sal_custom_header_find(salCustomHeaders, name.c_str());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string ChatMessagePrivate::getContentType() const {
|
||||
return cContentType;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setContentType(string contentType) {
|
||||
cContentType = contentType;
|
||||
}
|
||||
|
||||
string ChatMessagePrivate::getText() const {
|
||||
return cText;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setText(string text) {
|
||||
cText = text;
|
||||
}
|
||||
|
||||
LinphoneContent * ChatMessagePrivate::getFileTransferInformation() const {
|
||||
return cFileTransferInformation;
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::setFileTransferInformation(LinphoneContent *content) {
|
||||
cFileTransferInformation = content;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string ChatMessagePrivate::createImdnXml(ImdnType imdnType, LinphoneReason reason) {
|
||||
/*xmlBufferPtr buf;
|
||||
xmlTextWriterPtr writer;
|
||||
int err;
|
||||
char *content = NULL;
|
||||
char *datetime = NULL;
|
||||
const char *message_id;
|
||||
|
||||
// Check that the chat message has a message id
|
||||
message_id = linphone_chat_message_get_message_id(cm);
|
||||
if (message_id == NULL) return NULL;
|
||||
|
||||
buf = xmlBufferCreate();
|
||||
if (buf == NULL) {
|
||||
ms_error("Error creating the XML buffer");
|
||||
return content;
|
||||
}
|
||||
writer = xmlNewTextWriterMemory(buf, 0);
|
||||
if (writer == NULL) {
|
||||
ms_error("Error creating the XML writer");
|
||||
return content;
|
||||
}
|
||||
|
||||
datetime = linphone_timestamp_to_rfc3339_string(linphone_chat_message_get_time(cm));
|
||||
err = xmlTextWriterStartDocument(writer, "1.0", "UTF-8", NULL);
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterStartElementNS(writer, NULL, (const xmlChar *)"imdn",
|
||||
(const xmlChar *)"urn:ietf:params:xml:ns:imdn");
|
||||
}
|
||||
if ((err >= 0) && (reason != LinphoneReasonNone)) {
|
||||
err = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)"xmlns", (const xmlChar *)"linphoneimdn", NULL, (const xmlChar *)"http://www.linphone.org/xsds/imdn.xsd");
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterWriteElement(writer, (const xmlChar *)"message-id", (const xmlChar *)message_id);
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterWriteElement(writer, (const xmlChar *)"datetime", (const xmlChar *)datetime);
|
||||
}
|
||||
if (err >= 0) {
|
||||
if (imdn_type == ImdnTypeDelivery) {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"delivery-notification");
|
||||
} else {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"display-notification");
|
||||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"status");
|
||||
}
|
||||
if (err >= 0) {
|
||||
if (reason == LinphoneReasonNone) {
|
||||
if (imdn_type == ImdnTypeDelivery) {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"delivered");
|
||||
} else {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"displayed");
|
||||
}
|
||||
} else {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"error");
|
||||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "delivered", "displayed" or "error" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if ((err >= 0) && (reason != LinphoneReasonNone)) {
|
||||
err = xmlTextWriterStartElementNS(writer, (const xmlChar *)"linphoneimdn", (const xmlChar *)"reason", NULL);
|
||||
if (err >= 0) {
|
||||
char codestr[16];
|
||||
snprintf(codestr, 16, "%d", linphone_reason_to_error_code(reason));
|
||||
err = xmlTextWriterWriteAttribute(writer, (const xmlChar *)"code", (const xmlChar *)codestr);
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterWriteString(writer, (const xmlChar *)linphone_reason_to_string(reason));
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "status" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "delivery-notification" or "display-notification" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "imdn" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterEndDocument(writer);
|
||||
}
|
||||
if (err > 0) {
|
||||
// xmlTextWriterEndDocument returns the size of the content.
|
||||
content = ms_strdup((char *)buf->content);
|
||||
}
|
||||
xmlFreeTextWriter(writer);
|
||||
xmlBufferFree(buf);
|
||||
ms_free(datetime);
|
||||
return content;*/
|
||||
return "";
|
||||
}
|
||||
|
||||
void ChatMessagePrivate::sendImdn(ImdnType imdnType, LinphoneReason reason) {
|
||||
string content = createImdnXml(imdnType, reason);
|
||||
chatRoom->getPrivate()->sendImdn(content, reason);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// =============================================================================
|
||||
// ChatMessage
|
||||
// =============================================================================
|
||||
|
|
@ -65,11 +255,6 @@ shared_ptr<ChatRoom> ChatMessage::getChatRoom () const {
|
|||
return d->chatRoom;
|
||||
}
|
||||
|
||||
void ChatMessage::setChatRoom (shared_ptr<ChatRoom> chatRoom) {
|
||||
L_D();
|
||||
d->chatRoom = chatRoom;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string ChatMessage::getExternalBodyUrl() const {
|
||||
|
|
@ -86,10 +271,6 @@ time_t ChatMessage::getTime () const {
|
|||
L_D();
|
||||
return d->time;
|
||||
}
|
||||
void ChatMessage::setTime(time_t time) {
|
||||
L_D();
|
||||
d->time = time;
|
||||
}
|
||||
|
||||
bool ChatMessage::isSecured () const {
|
||||
L_D();
|
||||
|
|
@ -223,90 +404,9 @@ void ChatMessage::setIsToBeStored(bool store) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string ChatMessage::getContentType() const {
|
||||
L_D();
|
||||
return d->cContentType;
|
||||
}
|
||||
|
||||
void ChatMessage::setContentType(string contentType) {
|
||||
L_D();
|
||||
d->cContentType = contentType;
|
||||
}
|
||||
|
||||
string ChatMessage::getText() const {
|
||||
L_D();
|
||||
return d->cText;
|
||||
}
|
||||
|
||||
void ChatMessage::setText(string text) {
|
||||
L_D();
|
||||
d->cText = text;
|
||||
}
|
||||
|
||||
LinphoneContent * ChatMessage::getFileTransferInformation() const {
|
||||
L_D();
|
||||
return d->cFileTransferInformation;
|
||||
}
|
||||
|
||||
void ChatMessage::setFileTransferInformation(LinphoneContent *content) {
|
||||
L_D();
|
||||
d->cFileTransferInformation = content;
|
||||
}
|
||||
|
||||
unsigned int ChatMessage::getStorageId() const {
|
||||
L_D();
|
||||
return d->storageId;
|
||||
}
|
||||
|
||||
void ChatMessage::setStorageId(unsigned int id) {
|
||||
L_D();
|
||||
d->storageId = id;
|
||||
}
|
||||
|
||||
belle_http_request_t *ChatMessage::getHttpRequest() const {
|
||||
L_D();
|
||||
return d->httpRequest;
|
||||
}
|
||||
|
||||
void ChatMessage::setHttpRequest(belle_http_request_t *request) {
|
||||
L_D();
|
||||
d->httpRequest = request;
|
||||
}
|
||||
|
||||
SalOp *ChatMessage::getSalOp() const {
|
||||
L_D();
|
||||
return d->salOp;
|
||||
}
|
||||
|
||||
void ChatMessage::setSalOp(SalOp *op) {
|
||||
L_D();
|
||||
d->salOp = op;
|
||||
}
|
||||
|
||||
SalCustomHeader *ChatMessage::getSalCustomHeaders() const {
|
||||
L_D();
|
||||
return d->salCustomHeaders;
|
||||
}
|
||||
|
||||
void ChatMessage::setSalCustomHeaders(SalCustomHeader *headers) {
|
||||
L_D();
|
||||
d->salCustomHeaders = headers;
|
||||
}
|
||||
|
||||
void ChatMessage::addSalCustomHeader(string name, string value) {
|
||||
L_D();
|
||||
d->salCustomHeaders = sal_custom_header_append(d->salCustomHeaders, name.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
void ChatMessage::removeSalCustomHeader(string name) {
|
||||
L_D();
|
||||
d->salCustomHeaders = sal_custom_header_remove(d->salCustomHeaders, name.c_str());
|
||||
}
|
||||
|
||||
string ChatMessage::getSalCustomHeaderValue(string name) {
|
||||
L_D();
|
||||
return sal_custom_header_find(d->salCustomHeaders, name.c_str());
|
||||
}
|
||||
|
||||
const LinphoneErrorInfo * ChatMessage::getErrorInfo() const {
|
||||
L_D();
|
||||
|
|
@ -399,18 +499,14 @@ void ChatMessage::send () {
|
|||
}
|
||||
|
||||
void ChatMessage::reSend() {
|
||||
//TODO
|
||||
/*LinphoneChatMessageState state = linphone_chat_message_get_state(msg);
|
||||
LinphoneChatRoom *cr;
|
||||
L_D();
|
||||
|
||||
if (state != LinphoneChatMessageStateNotDelivered) {
|
||||
ms_warning("Cannot resend chat message in state %s", linphone_chat_message_state_to_string(state));
|
||||
if (d->state != NotDelivered) {
|
||||
// ms_warning("Cannot resend chat message in state %s", linphone_chat_message_state_to_string(state));
|
||||
return;
|
||||
}
|
||||
|
||||
cr = linphone_chat_message_get_chat_room(msg);
|
||||
if (ref_msg) linphone_chat_message_ref(msg);
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->sendMessage(msg);*/
|
||||
d->chatRoom->sendMessage(L_GET_C_BACK_PTR(this));
|
||||
}
|
||||
|
||||
/*static void linphone_chat_message_process_io_error_upload(void *data, const belle_sip_io_error_event_t *event) {
|
||||
|
|
@ -453,125 +549,16 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
|
|||
}
|
||||
}*/
|
||||
|
||||
/*static char *linphone_chat_message_create_imdn_xml(LinphoneChatMessage *cm, ImdnType imdn_type, LinphoneReason reason) {
|
||||
xmlBufferPtr buf;
|
||||
xmlTextWriterPtr writer;
|
||||
int err;
|
||||
char *content = NULL;
|
||||
char *datetime = NULL;
|
||||
const char *message_id;
|
||||
|
||||
// Check that the chat message has a message id
|
||||
message_id = linphone_chat_message_get_message_id(cm);
|
||||
if (message_id == NULL) return NULL;
|
||||
|
||||
buf = xmlBufferCreate();
|
||||
if (buf == NULL) {
|
||||
ms_error("Error creating the XML buffer");
|
||||
return content;
|
||||
}
|
||||
writer = xmlNewTextWriterMemory(buf, 0);
|
||||
if (writer == NULL) {
|
||||
ms_error("Error creating the XML writer");
|
||||
return content;
|
||||
}
|
||||
|
||||
datetime = linphone_timestamp_to_rfc3339_string(linphone_chat_message_get_time(cm));
|
||||
err = xmlTextWriterStartDocument(writer, "1.0", "UTF-8", NULL);
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterStartElementNS(writer, NULL, (const xmlChar *)"imdn",
|
||||
(const xmlChar *)"urn:ietf:params:xml:ns:imdn");
|
||||
}
|
||||
if ((err >= 0) && (reason != LinphoneReasonNone)) {
|
||||
err = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)"xmlns", (const xmlChar *)"linphoneimdn", NULL, (const xmlChar *)"http://www.linphone.org/xsds/imdn.xsd");
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterWriteElement(writer, (const xmlChar *)"message-id", (const xmlChar *)message_id);
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterWriteElement(writer, (const xmlChar *)"datetime", (const xmlChar *)datetime);
|
||||
}
|
||||
if (err >= 0) {
|
||||
if (imdn_type == ImdnTypeDelivery) {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"delivery-notification");
|
||||
} else {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"display-notification");
|
||||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"status");
|
||||
}
|
||||
if (err >= 0) {
|
||||
if (reason == LinphoneReasonNone) {
|
||||
if (imdn_type == ImdnTypeDelivery) {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"delivered");
|
||||
} else {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"displayed");
|
||||
}
|
||||
} else {
|
||||
err = xmlTextWriterStartElement(writer, (const xmlChar *)"error");
|
||||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "delivered", "displayed" or "error" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if ((err >= 0) && (reason != LinphoneReasonNone)) {
|
||||
err = xmlTextWriterStartElementNS(writer, (const xmlChar *)"linphoneimdn", (const xmlChar *)"reason", NULL);
|
||||
if (err >= 0) {
|
||||
char codestr[16];
|
||||
snprintf(codestr, 16, "%d", linphone_reason_to_error_code(reason));
|
||||
err = xmlTextWriterWriteAttribute(writer, (const xmlChar *)"code", (const xmlChar *)codestr);
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterWriteString(writer, (const xmlChar *)linphone_reason_to_string(reason));
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "status" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "delivery-notification" or "display-notification" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if (err >= 0) {
|
||||
// Close the "imdn" element.
|
||||
err = xmlTextWriterEndElement(writer);
|
||||
}
|
||||
if (err >= 0) {
|
||||
err = xmlTextWriterEndDocument(writer);
|
||||
}
|
||||
if (err > 0) {
|
||||
// xmlTextWriterEndDocument returns the size of the content.
|
||||
content = ms_strdup((char *)buf->content);
|
||||
}
|
||||
xmlFreeTextWriter(writer);
|
||||
xmlBufferFree(buf);
|
||||
ms_free(datetime);
|
||||
return content;
|
||||
}*/
|
||||
|
||||
void ChatMessage::sendImdn(ImdnType imdnType, LinphoneReason reason) {
|
||||
//TODO
|
||||
/*char *content = linphone_chat_message_create_imdn_xml(cm, imdn_type, reason);
|
||||
if (content) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(linphone_chat_message_get_chat_room(cm))->sendImdn(content, reason);
|
||||
ms_free(content);
|
||||
}*/
|
||||
}
|
||||
|
||||
void ChatMessage::sendDeliveryNotification(LinphoneReason reason) {
|
||||
//TODO
|
||||
L_D();
|
||||
LinphoneCore *lc = d->chatRoom->getCore();
|
||||
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(lc);
|
||||
if (linphone_im_notif_policy_get_send_imdn_delivered(policy)) {
|
||||
d->sendImdn(ImdnTypeDelivery, reason);
|
||||
}
|
||||
/*LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(cm);
|
||||
LinphoneCore *lc = linphone_chat_room_get_core(cr);
|
||||
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(lc);
|
||||
if (linphone_im_notif_policy_get_send_imdn_delivered(policy) == TRUE) {
|
||||
linphone_chat_message_send_imdn(cm, ImdnTypeDelivery, reason);
|
||||
}*/
|
||||
*/
|
||||
}
|
||||
|
||||
void ChatMessage::sendDisplayNotification() {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ public:
|
|||
void updateState(State state);
|
||||
void send();
|
||||
void reSend();
|
||||
void sendImdn(ImdnType imdnType, LinphoneReason reason);
|
||||
void sendDeliveryNotification(LinphoneReason reason);
|
||||
void sendDisplayNotification();
|
||||
int uploadFile();
|
||||
|
|
@ -131,39 +130,6 @@ public:
|
|||
std::string getCustomHeaderValue (const std::string &headerName) const;
|
||||
void addCustomHeader (const std::string &headerName, const std::string &headerValue);
|
||||
void removeCustomHeader (const std::string &headerName);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Deprecated methods, only used for C wrapper
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setChatRoom (std::shared_ptr<ChatRoom> chatRoom);
|
||||
|
||||
std::string getContentType() const;
|
||||
void setContentType(std::string contentType);
|
||||
|
||||
std::string getText() const;
|
||||
void setText(std::string text);
|
||||
|
||||
LinphoneContent * getFileTransferInformation() const;
|
||||
void setFileTransferInformation(LinphoneContent *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);
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
explicit ChatMessage (ChatMessagePrivate &p);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
class ChatRoomPrivate;
|
||||
|
||||
class ChatRoom : public Object, public ConferenceInterface {
|
||||
friend class ChatMessagePrivate;
|
||||
|
||||
public:
|
||||
L_DECLARE_ENUM(State, L_ENUM_VALUES_CHAT_ROOM_STATE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue