Commit 935e4296 authored by Ronan's avatar Ronan

fix(Core): clean some dirty code...

parent da407f79
......@@ -28,8 +28,6 @@
#include "c-wrapper/c-wrapper.h"
using namespace LinphonePrivate;
static void _linphone_auth_info_uninit(LinphoneAuthInfo *obj);
static void _linphone_auth_info_copy(LinphoneAuthInfo *dst, const LinphoneAuthInfo *src);
......@@ -438,7 +436,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
/* retry pending authentication operations */
for(l=elem=lc->sal->get_pending_auths();elem!=NULL;elem=elem->next){
SalOp *op=(SalOp*)elem->data;
LinphonePrivate::SalOp *op= static_cast<LinphonePrivate::SalOp*>(elem->data);
LinphoneAuthInfo *ai;
const SalAuthInfo *req_sai=op->get_auth_requested();
ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain, FALSE);
......
......@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "sal_impl.h"
#include "sal/sal.h"
using namespace LinphonePrivate;
SalReason _sal_reason_from_sip_code(int code) {
if (code>=100 && code<300) return SalReasonNone;
......@@ -82,13 +80,12 @@ SalReason _sal_reason_from_sip_code(int code) {
}
const SalErrorInfo *sal_error_info_none(void){
static SalErrorInfo none={
static const SalErrorInfo none = {
SalReasonNone,
(char *)"Ok",
200,
NULL,
NULL,
NULL
};
return &none;
}
......@@ -122,7 +119,7 @@ void sal_error_info_set(SalErrorInfo *ei, SalReason reason, const char *protocol
else{
ei->reason=reason;
if (code == 0) {
code = to_sip_code(reason);
code = LinphonePrivate::to_sip_code(reason);
}
}
ei->protocol_code=code;
......@@ -134,4 +131,4 @@ void sal_error_info_set(SalErrorInfo *ei, SalReason reason, const char *protocol
ei->full_string=ms_strdup_printf("%s %s",ei->status_string,ei->warnings);
else ei->full_string=ms_strdup(ei->status_string);
}
}
\ No newline at end of file
}
......@@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/core.h"
#include "private.h"
using namespace LinphonePrivate;
LinphoneCardDavContext* linphone_carddav_context_new(LinphoneFriendList *lfl) {
LinphoneCardDavContext *carddav_context = NULL;
......@@ -69,7 +67,7 @@ static void linphone_carddav_client_to_server_sync_done(LinphoneCardDavContext *
if (!success) {
ms_error("[carddav] CardDAV client to server sync failure: %s", msg);
}
if (cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, success, msg);
}
......@@ -82,7 +80,7 @@ static void linphone_carddav_server_to_client_sync_done(LinphoneCardDavContext *
} else {
ms_error("[carddav] CardDAV server to client sync failure: %s", msg);
}
if (cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, success, msg);
}
......@@ -120,7 +118,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(cdc->friend_list->lc->vcard_context, vCard->vcard);
LinphoneFriend *lf = NULL;
bctbx_list_t *local_friend = NULL;
if (lvc) {
// Compute downloaded vCards' URL and save it (+ eTag)
char *vCard_name = strrchr(vCard->url, '/');
......@@ -134,7 +132,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
linphone_vcard_unref(lvc); /*ref is now owned by friend*/
if (lf) {
local_friend = bctbx_list_find_custom(friends, (int (*)(const void*, const void*))find_matching_friend, lf);
if (local_friend) {
LinphoneFriend *lf2 = (LinphoneFriend *)local_friend->data;
lf->storage_id = lf2->storage_id;
......@@ -144,7 +142,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
lf->presence_received = lf2->presence_received;
lf->lc = lf2->lc;
lf->friend_list = lf2->friend_list;
if (cdc->contact_updated_cb) {
ms_debug("Contact updated: %s", linphone_friend_get_name(lf));
cdc->contact_updated_cb(cdc, lf, lf2);
......@@ -224,7 +222,7 @@ static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, bctbx_l
bctbx_list_t *friends = cdc->friend_list->friends;
bctbx_list_t *friends_to_remove = NULL;
bctbx_list_t *temp_list = NULL;
while (friends) {
LinphoneFriend *lf = (LinphoneFriend *)friends->data;
if (lf) {
......@@ -260,7 +258,7 @@ static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, bctbx_l
friends_to_remove = bctbx_list_next(friends_to_remove);
}
temp_list = bctbx_list_free_with_data(temp_list, (void (*)(void *))linphone_friend_unref);
linphone_carddav_pull_vcards(cdc, vCards);
bctbx_list_free_with_data(vCards, (void (*)(void *))linphone_carddav_response_free);
}
......@@ -340,22 +338,22 @@ static void linphone_carddav_query_free(LinphoneCardDavQuery *query) {
if (!query) {
return;
}
if (query->http_request_listener) {
belle_sip_object_unref(query->http_request_listener);
query->http_request_listener = NULL;
}
// Context will be freed later (in sync_done)
query->context = NULL;
if (query->url) {
ms_free(query->url);
}
if (query->body) {
ms_free(query->body);
}
ms_free(query);
}
......@@ -380,7 +378,7 @@ static bool_t is_query_client_to_server_sync(LinphoneCardDavQuery *query) {
static void process_response_from_carddav_request(void *data, const belle_http_response_event_t *event) {
LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)data;
if (event->response) {
int code = belle_http_response_get_status_code(event->response);
if (code == 207 || code == 200 || code == 201 || code == 204) {
......@@ -471,7 +469,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au
const char *realm = belle_sip_auth_event_get_realm(event);
belle_generic_uri_t *uri = belle_generic_uri_parse(query->url);
const char *domain = belle_generic_uri_get_host(uri);
if (cdc->auth_info) {
belle_sip_auth_event_set_username(event, cdc->auth_info->username);
belle_sip_auth_event_set_passwd(event, cdc->auth_info->passwd);
......@@ -479,7 +477,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au
} else {
LinphoneCore *lc = cdc->friend_list->lc;
const bctbx_list_t *auth_infos = linphone_core_get_auth_info_list(lc);
ms_debug("Looking for auth info for domain %s and realm %s", domain, realm);
while (auth_infos) {
LinphoneAuthInfo *auth_info = (LinphoneAuthInfo *)auth_infos->data;
......@@ -494,7 +492,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au
}
auth_infos = bctbx_list_next(auth_infos);
}
if (!auth_infos) {
ms_error("[carddav] Authentication requested during CardDAV request sending, and username/password weren't provided");
if (is_query_client_to_server_sync(query)) {
......@@ -525,7 +523,7 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
return;
}
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), NULL);
if (!req) {
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, "Could not create belle_http_request_t");
......@@ -535,7 +533,7 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
linphone_carddav_query_free(query);
return;
}
ua = ms_strdup_printf("%s/%s", linphone_core_get_user_agent(cdc->friend_list->lc), linphone_core_get_version());
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("User-Agent", ua));
ms_free(ua);
......@@ -546,12 +544,12 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
} else if (strcmp(query->method, "PUT")) {
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("If-None-Match", "*"));
}
if (query->body) {
bh = belle_sip_memory_body_handler_new_copy_from_buffer(query->body, strlen(query->body), NULL, NULL);
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), bh ? BELLE_SIP_BODY_HANDLER(bh) : NULL);
}
cbs.process_response = process_response_from_carddav_request;
cbs.process_io_error = process_io_error_from_carddav_request;
cbs.process_auth_requested = process_auth_requested_from_carddav_request;
......@@ -575,7 +573,7 @@ static char* generate_url_from_server_address_and_uid(const char *server_url) {
char *result = NULL;
if (server_url) {
char *uuid = reinterpret_cast<char *>(ms_malloc(64));
if (Sal::generate_uuid(uuid, 64) == 0) {
if (LinphonePrivate::Sal::generate_uuid(uuid, 64) == 0) {
char *url = reinterpret_cast<char *>(ms_malloc(300));
snprintf(url, 300, "%s/linphone-%s.vcf", server_url, uuid);
ms_debug("Generated url is %s", url);
......@@ -594,7 +592,7 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf)
if (!linphone_vcard_get_uid(lvc)) {
linphone_vcard_generate_unique_id(lvc);
}
if (!linphone_vcard_get_url(lvc)) {
char *url = generate_url_from_server_address_and_uid(cdc->friend_list->uri);
if (url) {
......@@ -609,7 +607,7 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf)
return;
}
}
query = linphone_carddav_create_put_query(cdc, lvc);
query->user_data = linphone_friend_ref(lf);
linphone_carddav_send_query(query);
......@@ -620,11 +618,11 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf)
} else {
msg = "Unknown error";
}
if (msg) {
ms_error("[carddav] %s", msg);
}
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, msg);
}
......@@ -647,7 +645,7 @@ void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc && linphone_vcard_get_uid(lvc) && linphone_vcard_get_etag(lvc)) {
LinphoneCardDavQuery *query = NULL;
if (!linphone_vcard_get_url(lvc)) {
char *url = generate_url_from_server_address_and_uid(cdc->friend_list->uri);
if (url) {
......@@ -662,7 +660,7 @@ void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *
return;
}
}
query = linphone_carddav_create_delete_query(cdc, lvc);
linphone_carddav_send_query(query);
} else {
......@@ -674,11 +672,11 @@ void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *
} else if (!linphone_vcard_get_etag(lvc)) {
msg = "LinphoneVcard doesn't have an eTag";
}
if (msg) {
ms_error("[carddav] %s", msg);
}
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, msg);
}
......@@ -739,7 +737,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query(
LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)ms_new0(LinphoneCardDavQuery, 1);
char *body = (char *)ms_malloc((bctbx_list_size(vcards) + 1) * 300 * sizeof(char));
bctbx_list_t *iterator = vcards;
query->context = cdc;
query->depth = "1";
query->ifmatch = NULL;
......@@ -760,7 +758,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query(
strcat(body, "</card:addressbook-multiget>");
query->body = ms_strdup(body);
ms_free(body);
return query;
}
......
......@@ -43,7 +43,6 @@
#include "content/content-type.h"
using namespace std;
using namespace LinphonePrivate;
void linphone_core_disable_chat(LinphoneCore *lc, LinphoneReason deny_reason) {
lc->chat_deny_code = deny_reason;
......@@ -156,7 +155,7 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c
return _linphone_core_get_or_create_chat_room(lc, to);
}
int linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *sal_msg) {
int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op, const SalMessage *sal_msg) {
LinphoneAddress *addr = linphone_address_new(sal_msg->from);
linphone_address_clean(addr);
LinphoneChatRoom *cr = linphone_core_get_chat_room(lc, addr);
......
......@@ -43,6 +43,7 @@
#include "c-wrapper/c-wrapper.h"
using namespace std;
using namespace LinphonePrivate;
const char *linphone_online_status_to_string(LinphoneOnlineStatus ss){
......
......@@ -23,8 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
using namespace LinphonePrivate;
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriendListCbs);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriendListCbs, belle_sip_object_t,
......@@ -796,7 +794,10 @@ LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFrien
return NULL;
}
LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe(const LinphoneFriendList *list, SalOp *op) {
LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe (
const LinphoneFriendList *list,
LinphonePrivate::SalOp *op
) {
const bctbx_list_t *elem;
for (elem = list->friends; elem != NULL; elem = bctbx_list_next(elem)) {
LinphoneFriend *lf = (LinphoneFriend *)bctbx_list_get_data(elem);
......@@ -805,7 +806,10 @@ LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe(const Linphon
return NULL;
}
LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe(const LinphoneFriendList *list, SalOp *op) {
LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe (
const LinphoneFriendList *list,
LinphonePrivate::SalOp *op
) {
const bctbx_list_t *elem;
for (elem = list->friends; elem != NULL; elem = bctbx_list_next(elem)) {
LinphoneFriend *lf = (LinphoneFriend *)bctbx_list_get_data(elem);
......
......@@ -28,8 +28,6 @@
#include "c-wrapper/c-wrapper.h"
using namespace LinphonePrivate;
struct _LinphoneInfoMessage{
belle_sip_object_t base;
LinphoneContent *content;
......@@ -98,7 +96,11 @@ SalCustomHeader *linphone_info_message_get_headers (const LinphoneInfoMessage *i
return im->headers;
}
void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, SalBodyHandler *body_handler){
void linphone_core_notify_info_message (
LinphoneCore* lc,
LinphonePrivate::SalOp *op,
SalBodyHandler *body_handler
) {
LinphoneCall *call=(LinphoneCall*)op->get_user_pointer();
if (call){
LinphoneInfoMessage *info=linphone_core_create_info_message(lc);
......
......@@ -130,10 +130,6 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName);
#include "enum.h"
#include "contact_providers_priv.h"
using namespace LinphonePrivate;
const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
static void toggle_video_preview(LinphoneCore *lc, bool_t val);
......@@ -147,6 +143,8 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val);
#define HOLD_MUSIC_WAV "toy-mono.wav"
#define HOLD_MUSIC_MKV "dont_wait_too_long.mkv"
using namespace LinphonePrivate;
extern Sal::Callbacks linphone_sal_callbacks;
......@@ -3454,7 +3452,7 @@ static void linphone_transfer_routes_to_op(bctbx_list_t *routes, SalOp *op){
void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy){
bctbx_list_t *routes=NULL;
const char *identity;
if (proxy){
identity=linphone_proxy_config_get_identity(proxy);
if (linphone_proxy_config_get_privacy(proxy)!=LinphonePrivacyDefault) {
......@@ -3479,7 +3477,7 @@ void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const Linphon
op->set_to(addr);
ms_free(addr);
}
op->set_from(identity);
op->set_sent_custom_header(headers);
op->set_realm(linphone_proxy_config_get_realm(proxy));
......
......@@ -32,7 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define VCARD_MD5_HASH_SIZE 16
using namespace std;
using namespace LinphonePrivate;
struct _LinphoneVcardContext {
shared_ptr<belcard::BelCardParser> parser;
......@@ -368,7 +367,7 @@ bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
if (linphone_vcard_get_uid(vCard)) {
return FALSE;
}
if (Sal::generate_uuid(uuid, sizeof(uuid)) == 0) {
if (LinphonePrivate::Sal::generate_uuid(uuid, sizeof(uuid)) == 0) {
char vcard_uuid[sizeof(uuid)+4];
snprintf(vcard_uuid, sizeof(vcard_uuid), "urn:%s", uuid);
linphone_vcard_set_uid(vCard, vcard_uuid);
......
......@@ -19,7 +19,7 @@
#ifndef _C_CHAT_MESSAGE_H_
#define _C_CHAT_MESSAGE_H_
#include "linphone/api/c-types.h"
#include "linphone/api/c-chat-message-cbs.h"
......@@ -38,13 +38,13 @@ typedef enum _LinphoneChatMessageDir{
LinphoneChatMessageIncoming,
LinphoneChatMessageOutgoing
} LinphoneChatMessageDir;
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup chatmessage
* @{
......@@ -94,6 +94,13 @@ LINPHONE_PUBLIC time_t linphone_chat_message_get_time(const LinphoneChatMessage*
**/
LINPHONE_PUBLIC bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage* msg);
/**
* Get origin of the message
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(LinphoneChatMessage* msg);
/**
* Set origin of the message
* @param[in] message #LinphoneChatMessage obj
......@@ -102,11 +109,11 @@ LINPHONE_PUBLIC bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage* ms
LINPHONE_PUBLIC void linphone_chat_message_set_from_address(LinphoneChatMessage* msg, const LinphoneAddress* from);
/**
* Get origin of the message
* Get destination of the message
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(LinphoneChatMessage* msg);
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(LinphoneChatMessage* msg);
/**
* Set destination of the message
......@@ -115,13 +122,6 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(Li
*/
LINPHONE_PUBLIC void linphone_chat_message_set_to_address(LinphoneChatMessage* msg, const LinphoneAddress* addr);
/**
* Get destination of the message
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(LinphoneChatMessage* msg);
/**
* Get the content type of a chat message.
* @param[in] message LinphoneChatMessage object
......
......@@ -35,7 +35,6 @@
// =============================================================================
using namespace std;
using namespace LinphonePrivate;
static void _linphone_chat_message_constructor (LinphoneChatMessage *msg);
static void _linphone_chat_message_destructor (LinphoneChatMessage *msg);
......@@ -57,9 +56,9 @@ static void _linphone_chat_message_constructor (LinphoneChatMessage *msg) {
static void _linphone_chat_message_destructor (LinphoneChatMessage *msg) {
linphone_chat_message_cbs_unref(msg->cbs);
msg->cbs = nullptr;
if (msg->from)
if (msg->from)
linphone_address_unref(msg->from);
if (msg->to)
if (msg->to)
linphone_address_unref(msg->to);
if (msg->contentTypeCache)
ms_free(msg->contentTypeCache);
......@@ -123,7 +122,7 @@ void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secur
}
bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage *msg) {
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isOutgoing();
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getDirection() == LinphonePrivate::ChatMessage::Direction::Outgoing;
}
LinphoneChatMessageDir linphone_chat_message_get_direction(const LinphoneChatMessage *msg) {
......@@ -151,11 +150,11 @@ void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessa
}
const char* linphone_chat_message_get_message_id(const LinphoneChatMessage *msg) {
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getId().c_str();
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getImdnMessageId().c_str();
}
void linphone_chat_message_set_message_id(LinphoneChatMessage *msg, char *id) {
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setId(L_C_TO_STRING(id));
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setImdnMessageId(L_C_TO_STRING(id));
}
void linphone_chat_message_set_storage_id(LinphoneChatMessage *msg, unsigned int id) {
......@@ -174,12 +173,6 @@ void linphone_chat_message_set_appdata(LinphoneChatMessage *msg, const char *dat
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setAppdata(L_C_TO_STRING(data));
}
void linphone_chat_message_set_from_address(LinphoneChatMessage *msg, const LinphoneAddress *from) {
LinphonePrivate::Address addr;
if (from) addr = LinphonePrivate::Address(linphone_address_as_string(from));
else L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setFromAddress(addr);
}
const LinphoneAddress *linphone_chat_message_get_from_address(LinphoneChatMessage *msg) {
if (msg->from)
linphone_address_unref(msg->from);
......@@ -187,10 +180,10 @@ const LinphoneAddress *linphone_chat_message_get_from_address(LinphoneChatMessag
return msg->from;
}
void linphone_chat_message_set_to_address(LinphoneChatMessage *msg, const LinphoneAddress *to) {
void linphone_chat_message_set_from_address(LinphoneChatMessage *msg, const LinphoneAddress *from) {
LinphonePrivate::Address addr;
if (to) addr = LinphonePrivate::Address(linphone_address_as_string(to));
else L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setToAddress(addr);
if (from) addr = LinphonePrivate::Address(linphone_address_as_string(from));
else L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setFromAddress(addr);
}
const LinphoneAddress *linphone_chat_message_get_to_address(LinphoneChatMessage *msg) {
......@@ -200,6 +193,12 @@ const LinphoneAddress *linphone_chat_message_get_to_address(LinphoneChatMessage
return msg->to;
}
void linphone_chat_message_set_to_address(LinphoneChatMessage *msg, const LinphoneAddress *to) {
LinphonePrivate::Address addr;
if (to) addr = LinphonePrivate::Address(linphone_address_as_string(to));
else L_GET_CPP_PTR_FROM_C_OBJECT(msg)->setToAddress(addr);
}
const char *linphone_chat_message_get_file_transfer_filepath(LinphoneChatMessage *msg) {
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getFileTransferFilepath());
}
......@@ -216,11 +215,11 @@ void linphone_chat_message_set_http_request(LinphoneChatMessage *msg, belle_http
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setHttpRequest(request);
}
SalOp * linphone_chat_message_get_sal_op(const LinphoneChatMessage *msg) {
LinphonePrivate::SalOp * linphone_chat_message_get_sal_op(const LinphoneChatMessage *msg) {
return L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalOp();
}
void linphone_chat_message_set_sal_op(LinphoneChatMessage *msg, SalOp *op) {
void linphone_chat_message_set_sal_op(LinphoneChatMessage *msg, LinphonePrivate::SalOp *op) {
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setSalOp(op);
}
......@@ -330,7 +329,7 @@ const char * linphone_chat_message_get_content_type(LinphoneChatMessage *msg) {
}
void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type) {
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setContentType(ContentType(L_C_TO_STRING(content_type)));
L_GET_PRIVATE_FROM_C_OBJECT(msg)->setContentType(LinphonePrivate::ContentType(L_C_TO_STRING(content_type)));
}
const char *linphone_chat_message_get_text(LinphoneChatMessage *msg) {
......@@ -359,9 +358,8 @@ const LinphoneAddress *linphone_chat_message_get_peer_address(LinphoneChatMessag
}
const LinphoneAddress *linphone_chat_message_get_local_address(LinphoneChatMessage *msg) {
if (L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isOutgoing()) {
if (L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getDirection() == LinphonePrivate::ChatMessage::Direction::Outgoing)
return linphone_chat_message_get_from_address(msg);
}
return linphone_chat_message_get_to_address(msg);
}
......
......@@ -1100,7 +1100,7 @@ void ChatMessagePrivate::send() {
}
linphone_address_unref(addr);
}
q->setFromAddress(identity);
q->setFromAddress(Address(identity));
}
}
}
......@@ -1203,7 +1203,7 @@ void ChatMessagePrivate::send() {
}
//End of TODO Remove
q->setId(op->get_call_id()); /* must be known at that time */
q->setImdnMessageId(op->get_call_id()); /* must be known at that time */
if (call && linphone_call_get_op(call) == op) {
/* In this case, chat delivery status is not notified, so unrefing chat message right now */
......@@ -1212,7 +1212,7 @@ void ChatMessagePrivate::send() {
}
/* If operation failed, we should not change message state */
if (q->isOutgoing()) {
if (q->getDirection() == ChatMessage::Direction::Outgoing) {
setIsReadOnly(true);
setState(ChatMessage::State::InProgress);
}
......@@ -1226,12 +1226,6 @@ void ChatMessagePrivate::send() {
ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &room) : Object(*new ChatMessagePrivate(room)) {}
ChatMessage::ChatMessage (ChatMessagePrivate &p) : Object(p) {}
LinphoneChatMessage * ChatMessage::getBackPtr() {
return L_GET_C_BACK_PTR(this);
}
shared_ptr<ChatRoom> ChatMessage::getChatRoom () const {
L_D();
return d->chatRoom;
......@@ -1269,27 +1263,17 @@ ChatMessage::Direction ChatMessage::getDirection () const {
return d->direction;
}
bool ChatMessage::isOutgoing () const {
L_D();
return d->direction == Direction::Outgoing;
}
bool ChatMessage::isIncoming () const {
L_D();
return d->direction == Direction::Incoming;
}
ChatMessage::State ChatMessage::getState() const {
L_D();
return d->state;
}
const string& ChatMessage::getId () const {
const string& ChatMessage::getImdnMessageId () const {
L_D();
return d->id;
}
void ChatMessage::setId (const string& id) {
void ChatMessage::setImdnMessageId (const string& id) {
L_D();
d->id = id;
}
......@@ -1325,11 +1309,6 @@ void ChatMessage::setFromAddress(Address from) {
d->from = from;
}
void ChatMessage::setFromAddress(const string& from) {
L_D();
d->from = Address(from);
}
const Address& ChatMessage::getToAddress () const {
L_D();
return d->to;
......@@ -1340,11 +1319,6 @@ void ChatMessage::setToAddress(Address to) {
d->to = to;
}
void ChatMessage::setToAddress(const string& to) {
L_D();
d->to = Address(to);
}
const string& ChatMessage::getFileTransferFilepath() const {
L_D();
return d->fileTransferFilePath;
......
......@@ -34,7 +34,6 @@ LINPHONE_BEGIN_NAMESPACE
class Address;
class ChatRoom;
class Content;
class ErrorInfo;
class ChatMessagePrivate;
class LINPHONE_PUBLIC ChatMessage : public Object {
......@@ -49,73 +48,46 @@ public:
L_DECLARE_ENUM(Direction, L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION);
ChatMessage (const std::shared_ptr<ChatRoom> &chatRoom);
virtual ~ChatMessage () = default;
LinphoneChatMessage *getBackPtr ();
std::shared_ptr<ChatRoom> getChatRoom () const;
// -----------------------------------------------------------------------------
// Methods
// -----------------------------------------------------------------------------
void store ();
void updateState (State state);
void reSend ();
void sendDeliveryNotification (LinphoneReason reason);
void sendDisplayNotification ();