diff --git a/coreapi/chat.c b/coreapi/chat.c
index 8e9f2b59b..1fd40d017 100644
--- a/coreapi/chat.c
+++ b/coreapi/chat.c
@@ -570,14 +570,6 @@ const LinphoneAddress *linphone_chat_message_get_peer_address(LinphoneChatMessag
return linphone_chat_room_get_peer_address(msg->chat_room);
}
-void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud) {
- msg->message_userdata = ud;
-}
-
-void *linphone_chat_message_get_user_data(const LinphoneChatMessage *msg) {
- return msg->message_userdata;
-}
-
const char *linphone_chat_message_get_external_body_url(const LinphoneChatMessage *msg) {
return msg->external_body_url;
}
@@ -775,15 +767,6 @@ static void _linphone_chat_message_destroy(LinphoneChatMessage *msg) {
}
}
-LinphoneChatMessage *linphone_chat_message_ref(LinphoneChatMessage *msg) {
- belle_sip_object_ref(msg);
- return msg;
-}
-
-void linphone_chat_message_unref(LinphoneChatMessage *msg) {
- belle_sip_object_unref(msg);
-}
-
void linphone_chat_message_deactivate(LinphoneChatMessage *msg){
if (msg->file_transfer_information != NULL) {
_linphone_chat_message_cancel_file_transfer(msg, FALSE);
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 54af30490..a2b7662f5 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -77,6 +77,7 @@ set(C_API_HEADER_FILES
c-address.h
c-api.h
c-callbacks.h
+ c-chat-message.h
c-chat-room.h
c-chat-room-cbs.h
c-event-log.h
diff --git a/include/linphone/api/c-api.h b/include/linphone/api/c-api.h
index 009498b29..6f6433104 100644
--- a/include/linphone/api/c-api.h
+++ b/include/linphone/api/c-api.h
@@ -20,6 +20,7 @@
#define _C_API_H_
#include "linphone/api/c-address.h"
+#include "linphone/api/c-chat-message.h"
#include "linphone/api/c-chat-room.h"
#include "linphone/api/c-event-log.h"
#include "linphone/api/c-participant.h"
diff --git a/include/linphone/api/c-chat-message.h b/include/linphone/api/c-chat-message.h
new file mode 100644
index 000000000..bced0fb36
--- /dev/null
+++ b/include/linphone/api/c-chat-message.h
@@ -0,0 +1,70 @@
+/*
+ * c-chat-message.h
+ * Copyright (C) 2017 Belledonne Communications SARL
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+ #ifndef _C_CHAT_MESSAGE_H_
+ #define _C_CHAT_MESSAGE_H_
+
+ #include "linphone/api/c-types.h"
+
+ // =============================================================================
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif // ifdef __cplusplus
+
+ /**
+ * @addtogroup chatmessage
+ * @{
+ */
+
+/**
+ * Acquire a reference to the chat message.
+ * @param[in] cr The chat message.
+ * @return The same chat message.
+**/
+LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_message_ref(LinphoneChatMessage *msg);
+
+/**
+ * Release reference to the chat message.
+ * @param[in] cr The chat message.
+**/
+LINPHONE_PUBLIC void linphone_chat_message_unref(LinphoneChatMessage *msg);
+
+/**
+ * Retrieve the user pointer associated with the chat message.
+ * @param[in] cr The chat message.
+ * @return The user pointer associated with the chat message.
+**/
+LINPHONE_PUBLIC void *linphone_chat_message_get_user_data(const LinphoneChatMessage *msg);
+
+/**
+ * Assign a user pointer to the chat message.
+ * @param[in] cr The chat message.
+ * @param[in] ud The user pointer to associate with the chat message.
+**/
+LINPHONE_PUBLIC void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud);
+
+ /**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif // ifdef __cplusplus
+
+#endif // ifndef _C_CHAT_MESSAGE_H_
\ No newline at end of file
diff --git a/include/linphone/chat.h b/include/linphone/chat.h
index e84c70bae..9444da7f6 100644
--- a/include/linphone/chat.h
+++ b/include/linphone/chat.h
@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/callbacks.h"
#include "linphone/types.h"
#include "linphone/api/c-types.h"
+#include "linphone/api/c-chat-message.h"
#include "linphone/api/c-chat-room.h"
#include "linphone/api/c-chat-room-cbs.h"
@@ -58,19 +59,6 @@ LINPHONE_PUBLIC LinphoneChatMessageState linphone_chat_message_get_state(const L
**/
LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_message_clone(const LinphoneChatMessage* message);
-/**
- * Acquire a reference to the chat message.
- * @param msg the chat message
- * @return the same chat message
-**/
-LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_message_ref(LinphoneChatMessage *msg);
-
-/**
- * Release reference to the chat message.
- * @param msg the chat message.
-**/
-LINPHONE_PUBLIC void linphone_chat_message_unref(LinphoneChatMessage *msg);
-
/**
* Destroys a LinphoneChatMessage.
**/
@@ -250,16 +238,6 @@ LINPHONE_PUBLIC const char* linphone_chat_message_get_text(const LinphoneChatMes
*/
LINPHONE_PUBLIC time_t linphone_chat_message_get_time(const LinphoneChatMessage* message);
-/**
- * User pointer get function
- */
-LINPHONE_PUBLIC void* linphone_chat_message_get_user_data(const LinphoneChatMessage* message);
-
-/**
- *User pointer set function
- */
-LINPHONE_PUBLIC void linphone_chat_message_set_user_data(LinphoneChatMessage* message,void*);
-
/**
* Returns the chatroom this message belongs to.
**/
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c089e0040..bb16db6da 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -99,6 +99,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
address/address.cpp
c-wrapper/api/c-address.cpp
c-wrapper/api/c-call-params.cpp
+ c-wrapper/api/c-chat-message.cpp
c-wrapper/api/c-chat-room.cpp
c-wrapper/api/c-chat-room-cbs.cpp
c-wrapper/api/c-event-log.cpp
diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp
new file mode 100644
index 000000000..265222519
--- /dev/null
+++ b/src/c-wrapper/api/c-chat-message.cpp
@@ -0,0 +1,52 @@
+/*
+ * c-chat-message.cpp
+ * Copyright (C) 2017 Belledonne Communications SARL
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+ #include "linphone/chat.h"
+ #include "linphone/wrapper_utils.h"
+ #include "private.h"
+
+ #include "c-wrapper/c-tools.h"
+ #include "chat/chat-message.h"
+ #include "chat/chat-message-p.h"
+
+ using namespace std;
+
+ #define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj, ChatMessage, ChatMessage)
+ #define GET_CPP_PRIVATE_PTR(obj) L_GET_PRIVATE_FROM_C_STRUCT(obj, ChatMessage, ChatMessage)
+
+ /*******************************************************************************
+ * Reference and user data handling functions *
+ ******************************************************************************/
+
+LinphoneChatMessage *linphone_chat_message_ref(LinphoneChatMessage *msg) {
+ belle_sip_object_ref(msg);
+ return msg;
+}
+
+void linphone_chat_message_unref(LinphoneChatMessage *msg) {
+ belle_sip_object_unref(msg);
+}
+
+void * linphone_chat_message_get_user_data(const LinphoneChatMessage *msg) {
+ return L_GET_USER_DATA_FROM_C_STRUCT(msg, ChatMessage, ChatMessage);
+}
+
+void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud) {
+ L_SET_USER_DATA_FROM_C_STRUCT(msg, ud, ChatMessage, ChatMessage);
+}
\ No newline at end of file