Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
5e3ff318
Commit
5e3ff318
authored
Apr 11, 2014
by
Simon Morlat
Browse files
add ref count to LinphoneChatMessage
parent
643d3963
Changes
3
Hide whitespace changes
Inline
Side-by-side
coreapi/chat.c
View file @
5e3ff318
...
...
@@ -32,6 +32,18 @@
#define COMPOSING_DEFAULT_REFRESH_TIMEOUT 60
#define COMPOSING_DEFAULT_REMOTE_REFRESH_TIMEOUT 120
static
void
_linphone_chat_message_destroy
(
LinphoneChatMessage
*
msg
);
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES
(
LinphoneChatMessage
);
BELLE_SIP_INSTANCIATE_VPTR
(
LinphoneChatMessage
,
belle_sip_object_t
,
(
belle_sip_object_destroy_t
)
_linphone_chat_message_destroy
,
NULL
,
// clone
NULL
,
// marshal
FALSE
);
/**
* @addtogroup chatroom
* @{
...
...
@@ -406,7 +418,7 @@ const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr)
* @return a new #LinphoneChatMessage
*/
LinphoneChatMessage
*
linphone_chat_room_create_message
(
LinphoneChatRoom
*
cr
,
const
char
*
message
)
{
LinphoneChatMessage
*
msg
=
ms
_new
0
(
LinphoneChatMessage
,
1
);
LinphoneChatMessage
*
msg
=
belle_sip_object
_new
(
LinphoneChatMessage
);
msg
->
chat_room
=
(
LinphoneChatRoom
*
)
cr
;
msg
->
message
=
message
?
ms_strdup
(
message
)
:
NULL
;
msg
->
is_read
=
TRUE
;
...
...
@@ -429,7 +441,7 @@ LinphoneChatMessage* linphone_chat_room_create_message_2(
LinphoneChatMessageState
state
,
time_t
time
,
bool_t
is_read
,
bool_t
is_incoming
)
{
LinphoneCore
*
lc
=
linphone_chat_room_get_lc
(
cr
);
LinphoneChatMessage
*
msg
=
ms
_new
0
(
LinphoneChatMessage
,
1
);
LinphoneChatMessage
*
msg
=
belle_sip_object
_new
(
LinphoneChatMessage
);
msg
->
chat_room
=
(
LinphoneChatRoom
*
)
cr
;
msg
->
message
=
message
?
ms_strdup
(
message
)
:
NULL
;
msg
->
external_body_url
=
external_body_url
?
ms_strdup
(
external_body_url
)
:
NULL
;
...
...
@@ -803,14 +815,40 @@ LinphoneChatMessage* linphone_chat_message_clone(const LinphoneChatMessage* msg)
/**
* Destroys a LinphoneChatMessage.
**/
void
linphone_chat_message_destroy
(
LinphoneChatMessage
*
msg
)
{
void
linphone_chat_message_destroy
(
LinphoneChatMessage
*
msg
){
belle_sip_object_unref
(
msg
);
}
/**
* Destroys a LinphoneChatMessage.
**/
static
void
_linphone_chat_message_destroy
(
LinphoneChatMessage
*
msg
)
{
if
(
msg
->
op
)
sal_op_release
(
msg
->
op
);
if
(
msg
->
message
)
ms_free
(
msg
->
message
);
if
(
msg
->
external_body_url
)
ms_free
(
msg
->
external_body_url
);
if
(
msg
->
from
)
linphone_address_destroy
(
msg
->
from
);
if
(
msg
->
to
)
linphone_address_destroy
(
msg
->
to
);
if
(
msg
->
custom_headers
)
sal_custom_header_free
(
msg
->
custom_headers
);
ms_free
(
msg
);
}
/**
* Acquire a reference to the chat message.
* @param msg the chat message
* @return the same chat message
**/
LinphoneChatMessage
*
linphone_chat_message_ref
(
LinphoneChatMessage
*
msg
){
belle_sip_object_ref
(
msg
);
return
msg
;
}
/**
* Release reference to the chat message.
* @param msg the chat message.
**/
void
linphone_chat_message_unref
(
LinphoneChatMessage
*
msg
){
belle_sip_object_unref
(
msg
);
}
/**
...
...
coreapi/linphonecore.h
View file @
5e3ff318
...
...
@@ -1067,6 +1067,8 @@ LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *ms
LINPHONE_PUBLIC
const
char
*
linphone_chat_message_state_to_string
(
const
LinphoneChatMessageState
state
);
LINPHONE_PUBLIC
LinphoneChatMessageState
linphone_chat_message_get_state
(
const
LinphoneChatMessage
*
message
);
LINPHONE_PUBLIC
LinphoneChatMessage
*
linphone_chat_message_clone
(
const
LinphoneChatMessage
*
message
);
LINPHONE_PUBLIC
LinphoneChatMessage
*
linphone_chat_message_ref
(
LinphoneChatMessage
*
msg
);
LINPHONE_PUBLIC
void
linphone_chat_message_unref
(
LinphoneChatMessage
*
msg
);
LINPHONE_PUBLIC
void
linphone_chat_message_destroy
(
LinphoneChatMessage
*
msg
);
LINPHONE_PUBLIC
void
linphone_chat_message_set_from
(
LinphoneChatMessage
*
message
,
const
LinphoneAddress
*
from
);
LINPHONE_PUBLIC
const
LinphoneAddress
*
linphone_chat_message_get_from
(
const
LinphoneChatMessage
*
message
);
...
...
coreapi/private.h
View file @
5e3ff318
...
...
@@ -132,6 +132,7 @@ typedef enum _LinphoneChatMessageDir{
}
LinphoneChatMessageDir
;
struct
_LinphoneChatMessage
{
belle_sip_object_t
base
;
LinphoneChatRoom
*
chat_room
;
LinphoneChatMessageDir
dir
;
char
*
message
;
...
...
@@ -149,6 +150,8 @@ struct _LinphoneChatMessage {
SalOp
*
op
;
};
BELLE_SIP_DECLARE_VPTR
(
LinphoneChatMessage
);
typedef
struct
StunCandidate
{
char
addr
[
64
];
int
port
;
...
...
@@ -862,7 +865,8 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(linphone,10000)
BELLE_SIP_TYPE_ID
(
LinphoneContactSearch
),
BELLE_SIP_TYPE_ID
(
LinphoneContactProvider
),
BELLE_SIP_TYPE_ID
(
LinphoneLDAPContactProvider
),
BELLE_SIP_TYPE_ID
(
LinphoneLDAPContactSearch
)
BELLE_SIP_TYPE_ID
(
LinphoneLDAPContactSearch
),
BELLE_SIP_TYPE_ID
(
LinphoneChatMessage
)
BELLE_SIP_DECLARE_TYPES_END
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment