Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
cf6995ef
Commit
cf6995ef
authored
Sep 04, 2015
by
Simon Morlat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean chat room api.
fix multiple memory leaks, mainly in gtk UI
parent
96bbacec
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
125 additions
and
175 deletions
+125
-175
console/commands.c
console/commands.c
+1
-1
coreapi/chat.c
coreapi/chat.c
+50
-42
coreapi/help/chatroom.c
coreapi/help/chatroom.c
+1
-2
coreapi/help/filetransfer.c
coreapi/help/filetransfer.c
+1
-2
coreapi/linphonecore.h
coreapi/linphonecore.h
+7
-17
coreapi/message_storage.c
coreapi/message_storage.c
+5
-1
gtk/calllogs.c
gtk/calllogs.c
+4
-6
gtk/chat.c
gtk/chat.c
+8
-11
gtk/friendlist.c
gtk/friendlist.c
+20
-10
gtk/main.c
gtk/main.c
+1
-1
tester/flexisip_tester.c
tester/flexisip_tester.c
+7
-20
tester/message_tester.c
tester/message_tester.c
+17
-59
tester/setup_tester.c
tester/setup_tester.c
+3
-3
No files found.
console/commands.c
View file @
cf6995ef
...
...
@@ -633,7 +633,7 @@ lpc_cmd_chat(LinphoneCore *lc, char *args)
/* missing one parameter */
return
0
;
}
cr
=
linphone_core_
create
_chat_room
(
lc
,
arg1
);
cr
=
linphone_core_
get
_chat_room
_from_uri
(
lc
,
arg1
);
linphone_chat_room_send_message
(
cr
,
arg2
);
return
1
;
}
...
...
coreapi/chat.c
View file @
cf6995ef
...
...
@@ -39,6 +39,9 @@
#define FILE_TRANSFER_KEY_SIZE 32
static
void
linphone_chat_message_release
(
LinphoneChatMessage
*
msg
);
static
LinphoneChatMessageCbs
*
linphone_chat_message_cbs_new
(
void
)
{
return
belle_sip_object_new
(
LinphoneChatMessageCbs
);
}
...
...
@@ -429,14 +432,6 @@ static LinphoneChatRoom * _linphone_core_get_or_create_chat_room(LinphoneCore* l
return
ret
;
}
LinphoneChatRoom
*
linphone_core_get_or_create_chat_room
(
LinphoneCore
*
lc
,
const
char
*
to
)
{
return
_linphone_core_get_or_create_chat_room
(
lc
,
to
);
}
LinphoneChatRoom
*
linphone_core_create_chat_room
(
LinphoneCore
*
lc
,
const
char
*
to
)
{
return
_linphone_core_get_or_create_chat_room
(
lc
,
to
);
}
LinphoneChatRoom
*
linphone_core_get_chat_room
(
LinphoneCore
*
lc
,
const
LinphoneAddress
*
addr
){
LinphoneChatRoom
*
ret
=
_linphone_core_get_chat_room
(
lc
,
addr
);
if
(
!
ret
)
{
...
...
@@ -445,6 +440,17 @@ LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAd
return
ret
;
}
void
linphone_core_delete_chat_room
(
LinphoneCore
*
lc
,
LinphoneChatRoom
*
cr
){
if
(
ms_list_find
(
lc
->
chatrooms
,
cr
)){
lc
->
chatrooms
=
ms_list_remove
(
cr
->
lc
->
chatrooms
,
cr
);
linphone_chat_room_unref
(
cr
);
}
else
{
ms_error
(
"linphone_core_delete_chat_room(): chatroom [%p] isn't part of LinphoneCore."
,
cr
);
}
}
LinphoneChatRoom
*
linphone_core_get_chat_room_from_uri
(
LinphoneCore
*
lc
,
const
char
*
to
)
{
return
_linphone_core_get_or_create_chat_room
(
lc
,
to
);
}
...
...
@@ -477,12 +483,18 @@ static void linphone_chat_room_delete_remote_composing_refresh_timer(LinphoneCha
}
static
void
_linphone_chat_room_destroy
(
LinphoneChatRoom
*
cr
){
ms_list_free_with_data
(
cr
->
transient_messages
,
(
void
(
*
)(
void
*
))
linphone_chat_message_
unref
);
ms_list_free_with_data
(
cr
->
transient_messages
,
(
void
(
*
)(
void
*
))
linphone_chat_message_
release
);
linphone_chat_room_delete_composing_idle_timer
(
cr
);
linphone_chat_room_delete_composing_refresh_timer
(
cr
);
linphone_chat_room_delete_remote_composing_refresh_timer
(
cr
);
if
(
cr
->
lc
!=
NULL
)
{
cr
->
lc
->
chatrooms
=
ms_list_remove
(
cr
->
lc
->
chatrooms
,(
void
*
)
cr
);
if
(
ms_list_find
(
cr
->
lc
->
chatrooms
,
cr
)){
ms_error
(
"LinphoneChatRoom[%p] is destroyed while still being used by the LinphoneCore. This is abnormal."
" linphone_core_get_chat_room() doesn't give a reference, there is no need to call linphone_chat_room_unref(). "
"In order to remove a chat room from the core, use linphone_core_delete_chat_room()."
,
cr
);
}
cr
->
lc
->
chatrooms
=
ms_list_remove
(
cr
->
lc
->
chatrooms
,
cr
);
}
linphone_address_destroy
(
cr
->
peer_url
);
ms_free
(
cr
->
peer
);
...
...
@@ -794,14 +806,17 @@ static void process_im_is_composing_notification(LinphoneChatRoom *cr, xmlparsin
xmlXPathRegisterNs
(
xml_ctx
->
xpath_ctx
,
(
const
xmlChar
*
)
"xsi"
,
(
const
xmlChar
*
)
"urn:ietf:params:xml:ns:im-iscomposing"
);
iscomposing_object
=
linphone_get_xml_xpath_object_for_node_list
(
xml_ctx
,
iscomposing_prefix
);
if
((
iscomposing_object
!=
NULL
)
&&
(
iscomposing_object
->
nodesetval
!=
NULL
))
{
for
(
i
=
1
;
i
<=
iscomposing_object
->
nodesetval
->
nodeNr
;
i
++
)
{
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"%s[%i]/xsi:state"
,
iscomposing_prefix
,
i
);
state_str
=
linphone_get_xml_text_content
(
xml_ctx
,
xpath_str
);
if
(
state_str
==
NULL
)
continue
;
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"%s[%i]/xsi:refresh"
,
iscomposing_prefix
,
i
);
refresh_str
=
linphone_get_xml_text_content
(
xml_ctx
,
xpath_str
);
if
(
iscomposing_object
!=
NULL
){
if
(
iscomposing_object
->
nodesetval
!=
NULL
)
{
for
(
i
=
1
;
i
<=
iscomposing_object
->
nodesetval
->
nodeNr
;
i
++
)
{
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"%s[%i]/xsi:state"
,
iscomposing_prefix
,
i
);
state_str
=
linphone_get_xml_text_content
(
xml_ctx
,
xpath_str
);
if
(
state_str
==
NULL
)
continue
;
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"%s[%i]/xsi:refresh"
,
iscomposing_prefix
,
i
);
refresh_str
=
linphone_get_xml_text_content
(
xml_ctx
,
xpath_str
);
}
}
xmlXPathFreeObject
(
iscomposing_object
);
}
if
(
state_str
!=
NULL
)
{
...
...
@@ -841,10 +856,12 @@ static void linphone_chat_room_notify_is_composing(LinphoneChatRoom *cr, const c
}
void
linphone_core_is_composing_received
(
LinphoneCore
*
lc
,
SalOp
*
op
,
const
SalIsComposing
*
is_composing
)
{
LinphoneChatRoom
*
cr
=
linphone_core_get_or_create_chat_room
(
lc
,
is_composing
->
from
);
LinphoneAddress
*
addr
=
linphone_address_new
(
is_composing
->
from
);
LinphoneChatRoom
*
cr
=
_linphone_core_get_chat_room
(
lc
,
addr
);
if
(
cr
!=
NULL
)
{
linphone_chat_room_notify_is_composing
(
cr
,
is_composing
->
text
);
}
linphone_address_destroy
(
addr
);
}
bool_t
linphone_chat_room_is_remote_composing
(
const
LinphoneChatRoom
*
cr
)
{
...
...
@@ -971,37 +988,22 @@ static char * linphone_chat_room_create_is_composing_xml(LinphoneChatRoom *cr) {
static
void
linphone_chat_room_send_is_composing_notification
(
LinphoneChatRoom
*
cr
)
{
SalOp
*
op
=
NULL
;
LinphoneCall
*
call
;
const
char
*
identity
=
NULL
;
char
*
content
=
NULL
;
LinphoneProxyConfig
*
proxy
=
linphone_core_lookup_known_proxy
(
cr
->
lc
,
cr
->
peer_url
);
if
(
proxy
)
identity
=
linphone_proxy_config_get_identity
(
proxy
);
else
identity
=
linphone_core_get_primary_contact
(
cr
->
lc
);
/*sending out of calls*/
op
=
sal_op_new
(
cr
->
lc
->
sal
);
linphone_configure_op
(
cr
->
lc
,
op
,
cr
->
peer_url
,
NULL
,
lp_config_get_int
(
cr
->
lc
->
config
,
"sip"
,
"chat_msg_with_contact"
,
0
));
if
(
lp_config_get_int
(
cr
->
lc
->
config
,
"sip"
,
"chat_use_call_dialogs"
,
0
))
{
if
((
call
=
linphone_core_get_call_by_remote_address
(
cr
->
lc
,
cr
->
peer
))
!=
NULL
)
{
if
(
call
->
state
==
LinphoneCallConnected
||
call
->
state
==
LinphoneCallStreamsRunning
||
call
->
state
==
LinphoneCallPaused
||
call
->
state
==
LinphoneCallPausing
||
call
->
state
==
LinphoneCallPausedByRemote
)
{
ms_message
(
"send SIP message through the existing call."
);
op
=
call
->
op
;
identity
=
linphone_core_find_best_identity
(
cr
->
lc
,
linphone_call_get_remote_address
(
call
));
}
}
}
if
(
op
==
NULL
)
{
LinphoneProxyConfig
*
proxy
=
linphone_core_lookup_known_proxy
(
cr
->
lc
,
cr
->
peer_url
);
if
(
proxy
)
identity
=
linphone_proxy_config_get_identity
(
proxy
);
else
identity
=
linphone_core_get_primary_contact
(
cr
->
lc
);
/*sending out of calls*/
op
=
sal_op_new
(
cr
->
lc
->
sal
);
linphone_configure_op
(
cr
->
lc
,
op
,
cr
->
peer_url
,
NULL
,
lp_config_get_int
(
cr
->
lc
->
config
,
"sip"
,
"chat_msg_with_contact"
,
0
));
}
content
=
linphone_chat_room_create_is_composing_xml
(
cr
);
if
(
content
!=
NULL
)
{
sal_message_send
(
op
,
identity
,
cr
->
peer
,
"application/im-iscomposing+xml"
,
content
,
NULL
);
ms_free
(
content
);
sal_op_unref
(
op
);
}
}
...
...
@@ -1402,6 +1404,12 @@ void linphone_chat_message_unref(LinphoneChatMessage *msg){
belle_sip_object_unref
(
msg
);
}
static
void
linphone_chat_message_release
(
LinphoneChatMessage
*
msg
){
/*mark the chat message as orphan (it has no chat room anymore), and unref it*/
msg
->
chat_room
=
NULL
;
linphone_chat_message_unref
(
msg
);
}
const
LinphoneErrorInfo
*
linphone_chat_message_get_error_info
(
const
LinphoneChatMessage
*
msg
){
return
linphone_error_info_from_sal_op
(
msg
->
op
);
}
...
...
coreapi/help/chatroom.c
View file @
cf6995ef
...
...
@@ -81,7 +81,7 @@ int main(int argc, char *argv[]){
/*Next step is to create a chat root*/
chat_room
=
linphone_core_
create
_chat_room
(
lc
,
dest_friend
);
chat_room
=
linphone_core_
get
_chat_room
_from_uri
(
lc
,
dest_friend
);
linphone_chat_room_send_message
(
chat_room
,
"Hello world"
);
/*sending message*/
...
...
@@ -92,7 +92,6 @@ int main(int argc, char *argv[]){
}
printf
(
"Shutting down...
\n
"
);
linphone_chat_room_destroy
(
chat_room
);
linphone_core_destroy
(
lc
);
printf
(
"Exited
\n
"
);
return
0
;
...
...
coreapi/help/filetransfer.c
View file @
cf6995ef
...
...
@@ -160,7 +160,7 @@ int main(int argc, char *argv[]){
/*Next step is to create a chat room*/
chat_room
=
linphone_core_
create
_chat_room
(
lc
,
dest_friend
);
chat_room
=
linphone_core_
get
_chat_room
_from_uri
(
lc
,
dest_friend
);
content
=
linphone_core_create_content
(
lc
);
linphone_content_set_type
(
content
,
"text"
);
...
...
@@ -196,7 +196,6 @@ int main(int argc, char *argv[]){
printf
(
"Shutting down...
\n
"
);
linphone_content_unref
(
content
);
linphone_chat_room_destroy
(
chat_room
);
linphone_core_destroy
(
lc
);
printf
(
"Exited
\n
"
);
return
0
;
...
...
coreapi/linphonecore.h
View file @
cf6995ef
...
...
@@ -1232,24 +1232,11 @@ typedef LinphoneBuffer * (*LinphoneChatMessageCbsFileTransferSendCb)(LinphoneCha
typedef
void
(
*
LinphoneChatMessageCbsFileTransferProgressIndicationCb
)(
LinphoneChatMessage
*
message
,
const
LinphoneContent
*
content
,
size_t
offset
,
size_t
total
);
LINPHONE_PUBLIC
void
linphone_core_set_chat_database_path
(
LinphoneCore
*
lc
,
const
char
*
path
);
/**
* Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org
* @param lc #LinphoneCore object
* @param to destination address for messages
* @return #LinphoneChatRoom where messaging can take place.
* @deprecated Use linphone_core_get_chat_room() or linphone_core_get_chat_room_from_uri() instead.
*/
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_core_create_chat_room
(
LinphoneCore
*
lc
,
const
char
*
to
);
/**
* Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org if not already existing, else return exisiting one
* @param lc #LinphoneCore object
* @param to destination address for messages
* @return #LinphoneChatRoom where messaging can take place.
* @deprecated Use linphone_core_get_chat_room() or linphone_core_get_chat_room_from_uri() instead.
*/
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_core_get_or_create_chat_room
(
LinphoneCore
*
lc
,
const
char
*
to
);
/**
* Get a chat room whose peer is the supplied address. If it does not exist yet, it will be created.
* No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room.
* @param lc the linphone core
* @param addr a linphone address.
* @return #LinphoneChatRoom where messaging can take place.
...
...
@@ -1257,6 +1244,7 @@ LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_get_or_create_chat_room(Linphon
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_core_get_chat_room
(
LinphoneCore
*
lc
,
const
LinphoneAddress
*
addr
);
/**
* Get a chat room for messaging from a sip uri like sip:joe@sip.linphone.org. If it does not exist yet, it will be created.
* No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room.
* @param lc The linphone core
* @param to The destination address for messages.
* @return #LinphoneChatRoom where messaging can take place.
...
...
@@ -1356,6 +1344,7 @@ LINPHONE_PUBLIC void linphone_chat_room_send_message(LinphoneChatRoom *cr, const
* @param ud user data for the status cb.
* @deprecated Use linphone_chat_room_send_chat_message() instead.
* @note The LinphoneChatMessage must not be destroyed until the the callback is called.
* The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application.
*/
LINPHONE_PUBLIC
void
linphone_chat_room_send_message2
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
,
LinphoneChatMessageStateChangedCb
status_cb
,
void
*
ud
);
/**
...
...
@@ -1364,6 +1353,7 @@ LINPHONE_PUBLIC void linphone_chat_room_send_message2(LinphoneChatRoom *cr, Linp
* @param[in] msg LinphoneChatMessage object
* The state of the message sending will be notified via the callbacks defined in the LinphoneChatMessageCbs object that can be obtained
* by calling linphone_chat_message_get_callbacks().
* The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application.
*/
LINPHONE_PUBLIC
void
linphone_chat_room_send_chat_message
(
LinphoneChatRoom
*
cr
,
LinphoneChatMessage
*
msg
);
...
...
@@ -1583,7 +1573,7 @@ LINPHONE_PUBLIC void linphone_chat_message_set_user_data(LinphoneChatMessage* me
**/
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_chat_message_get_chat_room
(
LinphoneChatMessage
*
msg
);
/**
* get peer address \link linphone_core_
create
_chat_room() associated to \endlink this #LinphoneChatRoom
* get peer address \link linphone_core_
get
_chat_room() associated to \endlink this #LinphoneChatRoom
* @param cr #LinphoneChatRoom object
* @return #LinphoneAddress peer address
*/
...
...
coreapi/message_storage.c
View file @
cf6995ef
...
...
@@ -100,7 +100,11 @@ static void fetch_content_from_database(sqlite3 *db, LinphoneChatMessage *messag
static
int
callback_all
(
void
*
data
,
int
argc
,
char
**
argv
,
char
**
colName
){
LinphoneCore
*
lc
=
(
LinphoneCore
*
)
data
;
char
*
address
=
argv
[
0
];
linphone_core_get_or_create_chat_room
(
lc
,
address
);
LinphoneAddress
*
addr
=
linphone_address_new
(
address
);
if
(
addr
){
linphone_core_get_chat_room
(
lc
,
addr
);
linphone_address_destroy
(
addr
);
}
return
0
;
}
...
...
gtk/calllogs.c
View file @
cf6995ef
...
...
@@ -282,8 +282,7 @@ void linphone_gtk_call_log_update(GtkWidget *w){
LinphoneFriend
*
lf
=
NULL
;
int
duration
=
linphone_call_log_get_duration
(
cl
);
time_t
start_date_time
=
linphone_call_log_get_start_date
(
cl
);
GdkPixbuf
*
incoming
;
GdkPixbuf
*
outgoing
;
GdkPixbuf
*
pbuf
;
#if GLIB_CHECK_VERSION(2,26,0)
if
(
start_date_time
){
...
...
@@ -348,14 +347,13 @@ void linphone_gtk_call_log_update(GtkWidget *w){
g_free
(
seconds
);
if
(
start_date
)
g_free
(
start_date
);
gtk_tree_store_append
(
store
,
&
iter
,
NULL
);
incoming
=
create_pixbuf
(
"call_status_incoming.png"
);
outgoing
=
create_pixbuf
(
"call_status_outgoing.png"
);
pbuf
=
linphone_call_log_get_dir
(
cl
)
==
LinphoneCallOutgoing
?
create_pixbuf
(
"call_status_outgoing.png"
)
:
create_pixbuf
(
"call_status_incoming.png"
);
gtk_tree_store_set
(
store
,
&
iter
,
0
,
linphone_call_log_get_dir
(
cl
)
==
LinphoneCallOutgoing
?
outgoing
:
incoming
,
0
,
pbuf
,
1
,
headtxt
,
2
,
cl
,
-
1
);
gtk_tree_store_append
(
store
,
&
iter2
,
&
iter
);
gtk_tree_store_set
(
store
,
&
iter2
,
1
,
logtxt
,
-
1
);
g_object_unref
(
pbuf
);
ms_free
(
addr
);
g_free
(
logtxt
);
g_free
(
headtxt
);
...
...
gtk/chat.c
View file @
cf6995ef
...
...
@@ -64,7 +64,6 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
GtkWidget
*
friendlist
=
linphone_gtk_get_widget
(
main_window
,
"contact_list"
);
GtkWidget
*
w
=
g_object_get_data
(
G_OBJECT
(
friendlist
),
"chatview"
);
gchar
*
from
;
GHashTable
*
table
=
g_object_get_data
(
G_OBJECT
(
w
),
"table"
);
g_return_if_fail
(
w
!=
NULL
);
gtk_notebook_remove_page
(
GTK_NOTEBOOK
(
nb
),
gtk_notebook_page_num
(
GTK_NOTEBOOK
(
nb
),
w
));
...
...
@@ -76,7 +75,6 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
g_object_set_data
(
G_OBJECT
(
w
),
"from_message"
,
NULL
);
g_free
(
from
);
}
g_hash_table_destroy
(
table
);
g_object_set_data
(
G_OBJECT
(
w
),
"cr"
,
NULL
);
linphone_gtk_friend_list_set_active_address
(
NULL
);
gtk_widget_destroy
(
w
);
...
...
@@ -215,7 +213,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
g_hash_table_insert
(
table
,(
gpointer
)
msg
,
GINT_TO_POINTER
(
gtk_text_iter_get_line
(
&
iter
)));
gtk_text_buffer_insert_with_tags_by_name
(
buffer
,
&
iter
,
"Sending .."
,
-
1
,
"status"
,
me
?
"me"
:
NULL
,
NULL
);
g_object_set_data
(
G_OBJECT
(
w
),
"table"
,
table
);
//
g_object_set_data(G_OBJECT(w),"table",table);
break
;
case
LinphoneChatMessageStateDelivered
:
tnow
=
time
(
NULL
);
...
...
@@ -293,7 +291,7 @@ void update_chat_state_message(LinphoneChatMessageState state,LinphoneChatMessag
}
gtk_text_buffer_insert_with_tags_by_name
(
b
,
&
iter
,
result
,
-
1
,
"status"
,
"me"
,
NULL
);
g_object_set_data
(
G_OBJECT
(
page
),
"table"
,
table
);
//
g_object_set_data(G_OBJECT(page),"table",table);
}
}
...
...
@@ -348,7 +346,7 @@ void linphone_gtk_free_list(MSList *messages){
}
void
display_history_message
(
GtkWidget
*
chat_view
,
MSList
*
messages
,
const
LinphoneAddress
*
with
){
if
(
messages
!=
NULL
){
if
(
messages
!=
NULL
){
MSList
*
it
;
char
*
from_str
;
char
*
with_str
;
...
...
@@ -361,14 +359,15 @@ void display_history_message(GtkWidget *chat_view,MSList *messages,const Linphon
linphone_chat_message_get_from
(
msg
),
strcmp
(
from_str
,
with_str
)
==
0
?
FALSE
:
TRUE
,
linphone_chat_message_get_chat_room
(
msg
),
msg
,
TRUE
);
ms_free
(
from_str
);
ms_free
(
with_str
);
}
tmp
=
g_object_get_data
(
G_OBJECT
(
chat_view
),
"from_message"
);
if
(
tmp
){
g_object_set_data
(
G_OBJECT
(
chat_view
),
"from_message"
,
NULL
);
g_free
(
tmp
);
}
ms_free
(
from_str
);
ms_free
(
with_str
);
linphone_gtk_free_list
(
messages
);
}
}
...
...
@@ -497,7 +496,7 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres
table
=
g_hash_table_new_full
(
g_direct_hash
,
g_direct_equal
,
NULL
,
NULL
);
g_object_set_data
(
G_OBJECT
(
chat_view
),
"cr"
,
cr
);
g_object_set_data
(
G_OBJECT
(
chat_view
),
"from_message"
,
NULL
);
g_object_set_data
(
G_OBJECT
(
chat_view
),
"table"
,
table
);
g_object_set_data
_full
(
G_OBJECT
(
chat_view
),
"table"
,
table
,(
GDestroyNotify
)
g_hash_table_destroy
);
gtk_text_buffer_create_tag
(
gtk_text_view_get_buffer
(
GTK_TEXT_VIEW
(
text
)),
...
...
@@ -553,9 +552,7 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres
}
LinphoneChatRoom
*
linphone_gtk_create_chatroom
(
const
LinphoneAddress
*
with
){
char
*
tmp
=
linphone_address_as_string
(
with
);
LinphoneChatRoom
*
cr
=
linphone_core_get_or_create_chat_room
(
linphone_gtk_get_core
(),
tmp
);
ms_free
(
tmp
);
LinphoneChatRoom
*
cr
=
linphone_core_get_chat_room
(
linphone_gtk_get_core
(),
with
);
return
cr
;
}
...
...
gtk/friendlist.c
View file @
cf6995ef
...
...
@@ -243,20 +243,23 @@ void linphone_gtk_friend_list_update_chat_picture(){
int
nbmsg
=
0
;
if
(
gtk_tree_model_get_iter_first
(
model
,
&
iter
))
{
do
{
GdkPixbuf
*
pbuf
=
NULL
;
gtk_tree_model_get
(
model
,
&
iter
,
FRIEND_CHATROOM
,
&
cr
,
-
1
);
nbmsg
=
linphone_chat_room_get_unread_messages_count
(
cr
);
is_composing
=
linphone_chat_room_is_remote_composing
(
cr
);
if
(
nbmsg
!=
0
){
if
(
is_composing
==
TRUE
)
gtk_list_store_set
(
GTK_LIST_STORE
(
model
),
&
iter
,
FRIEND_CHAT
,
create_composing_unread_msg
()
,
-
1
)
;
pbuf
=
create_composing_unread_msg
();
else
gtk_list_store_set
(
GTK_LIST_STORE
(
model
),
&
iter
,
FRIEND_CHAT
,
create_unread_msg
()
,
-
1
)
;
pbuf
=
create_unread_msg
();
}
else
{
if
(
is_composing
==
TRUE
)
gtk_list_store_set
(
GTK_LIST_STORE
(
model
),
&
iter
,
FRIEND_CHAT
,
create_composing_chat_picture
()
,
-
1
)
;
pbuf
=
create_composing_chat_picture
();
else
gtk_list_store_set
(
GTK_LIST_STORE
(
model
),
&
iter
,
FRIEND_CHAT
,
create_chat_picture
()
,
-
1
)
;
pbuf
=
create_chat_picture
();
}
gtk_list_store_set
(
GTK_LIST_STORE
(
model
),
&
iter
,
FRIEND_CHAT
,
pbuf
,
-
1
);
if
(
pbuf
)
g_object_unref
(
pbuf
);
}
while
(
gtk_tree_model_iter_next
(
model
,
&
iter
));
}
}
...
...
@@ -269,9 +272,7 @@ static gboolean grab_focus(GtkWidget *w){
void
linphone_gtk_friend_list_set_active_address
(
const
LinphoneAddress
*
addr
){
GtkWidget
*
w
=
linphone_gtk_get_main_window
();
GtkWidget
*
friendlist
=
linphone_gtk_get_widget
(
w
,
"contact_list"
);
LinphoneAddress
*
old_addr
=
(
LinphoneAddress
*
)
g_object_get_data
(
G_OBJECT
(
friendlist
),
"from"
);
g_object_set_data
(
G_OBJECT
(
friendlist
),
"from"
,
addr
?
linphone_address_clone
(
addr
)
:
NULL
);
if
(
old_addr
)
linphone_address_unref
(
old_addr
);
g_object_set_data_full
(
G_OBJECT
(
friendlist
),
"from"
,
addr
?
linphone_address_clone
(
addr
)
:
NULL
,
(
GDestroyNotify
)
linphone_address_destroy
);
}
const
LinphoneAddress
*
linphone_gtk_friend_list_get_active_address
(
void
){
...
...
@@ -831,6 +832,7 @@ void linphone_gtk_show_friends(void){
char
*
escaped
=
NULL
;
//char buf[26]={0};
int
nbmsg
=
0
;
GdkPixbuf
*
pbuf
,
*
pbuf2
,
*
pbuf3
;
/*if (lookup){
if (strstr(uri,search)==NULL){
...
...
@@ -844,14 +846,22 @@ void linphone_gtk_show_friends(void){
display
=
linphone_address_get_username
(
f_uri
);
}
gtk_list_store_append
(
store
,
&
iter
);
pbuf
=
create_chat_picture
();
pbuf2
=
create_call_picture
();
pbuf3
=
send_subscribe
?
create_status_picture
(
linphone_friend_get_status
(
lf
))
:
NULL
;
gtk_list_store_set
(
store
,
&
iter
,
FRIEND_NAME
,
display
,
FRIEND_ID
,
lf
,
FRIEND_PRESENCE_IMG
,
send_subscribe
?
create_status_picture
(
linphone_friend_get_status
(
lf
))
:
NULL
,
FRIEND_CHAT
,
create_chat_picture
(),
FRIEND_CALL
,
create_call_picture
(),
-
1
);
FRIEND_PRESENCE_IMG
,
pbuf3
,
FRIEND_CHAT
,
pbuf
,
FRIEND_CALL
,
pbuf2
,
-
1
);
g_object_unref
(
pbuf
);
g_object_unref
(
pbuf2
);
if
(
pbuf3
)
g_object_unref
(
pbuf3
);
cr
=
linphone_gtk_create_chatroom
(
f_uri
);
gtk_list_store_set
(
store
,
&
iter
,
FRIEND_CHATROOM
,
cr
,
-
1
);
nbmsg
=
linphone_chat_room_get_unread_messages_count
(
cr
);
if
(
nbmsg
!=
0
){
gtk_list_store_set
(
store
,
&
iter
,
FRIEND_CHAT
,
create_unread_msg
(),
-
1
);
pbuf
=
create_unread_msg
();
gtk_list_store_set
(
store
,
&
iter
,
FRIEND_CHAT
,
pbuf
,
-
1
);
g_object_unref
(
pbuf
);
}
escaped
=
g_markup_escape_text
(
uri
,
-
1
);
gtk_list_store_set
(
store
,
&
iter
,
FRIEND_SIP_ADDRESS
,
escaped
,
-
1
);
...
...
gtk/main.c
View file @
cf6995ef
...
...
@@ -1750,7 +1750,7 @@ static void linphone_gtk_configure_main_window(){
gchar
*
tmp
;
GtkWidget
*
menu_item
=
linphone_gtk_get_widget
(
w
,
"home_item"
);
tmp
=
g_strdup
(
home
);
g_object_set_data
(
G_OBJECT
(
menu_item
),
"home"
,
tmp
);
g_object_set_data
_full
(
G_OBJECT
(
menu_item
),
"home"
,
tmp
,
(
GDestroyNotify
)
g_free
);
}
{
/*
...
...
tester/flexisip_tester.c
View file @
cf6995ef
...
...
@@ -63,8 +63,7 @@ static void message_forking(void) {
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
transport_supported
(
LinphoneTransportTls
)
?
"pauline_rc"
:
"pauline_tcp_rc"
);
LinphoneCoreManager
*
marie2
=
linphone_core_manager_new
(
"marie_rc"
);
MSList
*
lcs
=
ms_list_append
(
NULL
,
marie
->
lc
);
char
*
to
=
linphone_address_as_string
(
marie
->
identity
);
LinphoneChatRoom
*
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
LinphoneChatRoom
*
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
LinphoneChatMessage
*
message
=
linphone_chat_room_create_message
(
chat_room
,
"Bli bli bli
\n
blu"
);
lcs
=
ms_list_append
(
lcs
,
pauline
->
lc
);
...
...
@@ -78,7 +77,6 @@ static void message_forking(void) {
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
marie2
);
linphone_core_manager_destroy
(
pauline
);
ms_free
(
to
);
ms_list_free
(
lcs
);
}
...
...
@@ -88,8 +86,7 @@ static void message_forking_with_unreachable_recipients(void) {
LinphoneCoreManager
*
marie2
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
marie3
=
linphone_core_manager_new
(
"marie_rc"
);
MSList
*
lcs
=
ms_list_append
(
NULL
,
marie
->
lc
);
char
*
to
=
linphone_address_as_string
(
marie
->
identity
);
LinphoneChatRoom
*
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
LinphoneChatRoom
*
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
LinphoneChatMessage
*
message
=
linphone_chat_room_create_message
(
chat_room
,
"Bli bli bli
\n
blu"
);
lcs
=
ms_list_append
(
lcs
,
pauline
->
lc
);
...
...
@@ -121,7 +118,6 @@ static void message_forking_with_unreachable_recipients(void) {
linphone_core_manager_destroy
(
marie2
);
linphone_core_manager_destroy
(
marie3
);
linphone_core_manager_destroy
(
pauline
);
ms_free
(
to
);
ms_list_free
(
lcs
);
}
...
...
@@ -131,8 +127,7 @@ static void message_forking_with_all_recipients_unreachable(void) {
LinphoneCoreManager
*
marie2
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
marie3
=
linphone_core_manager_new
(
"marie_rc"
);
MSList
*
lcs
=
ms_list_append
(
NULL
,
marie
->
lc
);
char
*
to
=
linphone_address_as_string
(
marie
->
identity
);
LinphoneChatRoom
*
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
LinphoneChatRoom
*
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
LinphoneChatMessage
*
message
=
linphone_chat_room_create_message
(
chat_room
,
"Bli bli bli
\n
blu"
);
lcs
=
ms_list_append
(
lcs
,
pauline
->
lc
);
...
...
@@ -172,7 +167,6 @@ static void message_forking_with_all_recipients_unreachable(void) {
linphone_core_manager_destroy
(
marie2
);
linphone_core_manager_destroy
(
marie3
);
linphone_core_manager_destroy
(
pauline
);
ms_free
(
to
);
ms_list_free
(
lcs
);
}
...
...
@@ -729,7 +723,6 @@ static void call_with_ipv6(void) {
static
void
file_transfer_message_rcs_to_external_body_client
(
void
)
{
if
(
transport_supported
(
LinphoneTransportTls
))
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_init
(
"marie_rc"
);
char
*
to
;
LinphoneChatRoom
*
chat_room
;
LinphoneChatMessage
*
message
;
LinphoneChatMessageCbs
*
cbs
;
...
...
@@ -758,9 +751,8 @@ static void file_transfer_message_rcs_to_external_body_client(void) {
linphone_core_set_file_transfer_server
(
pauline
->
lc
,
"https://www.linphone.org:444/lft.php"
);
/* create a chatroom on pauline's side */
to
=
linphone_address_as_string
(
marie
->
identity
);
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
ms_free
(
to
);
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
/* create a file transfer message */
content
=
linphone_core_create_content
(
pauline
->
lc
);
linphone_content_set_type
(
content
,
"image"
);
...
...
@@ -803,14 +795,12 @@ static void file_transfer_message_rcs_to_external_body_client(void) {
}
void
send_file_transfer_message_using_external_body_url
(
LinphoneCoreManager
*
marie
,
LinphoneCoreManager
*
pauline
)
{
char
*
to
;
LinphoneChatMessageCbs
*
cbs
;
LinphoneChatRoom
*
chat_room
;
LinphoneChatMessage
*
message
;
/* create a chatroom on pauline's side */
to
=
linphone_address_as_string
(
marie
->
identity
);
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
message
=
linphone_chat_room_create_message
(
chat_room
,
NULL
);
...
...
@@ -876,7 +866,6 @@ static void file_transfer_message_external_body_to_rcs_client(void) {
}
static
void
dos_module_trigger
(
void
)
{
char
*
to
;
LinphoneChatRoom
*
chat_room
;
int
i
=
0
;
const
char
*
passmsg
=
"This one should pass through"
;
...
...
@@ -887,8 +876,7 @@ static void dos_module_trigger(void) {
reset_counters
(
&
marie
->
stat
);
reset_counters
(
&
pauline
->
stat
);
to
=
linphone_address_as_string
(
marie
->
identity
);
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
do
{
char
msg
[
128
];
...
...
@@ -913,7 +901,6 @@ static void dos_module_trigger(void) {
}
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
ms_free
(
to
);
}
test_t
flexisip_tests
[]
=
{
...
...
tester/message_tester.c
View file @
cf6995ef
...
...
@@ -183,12 +183,9 @@ void liblinphone_tester_chat_message_msg_state_changed(LinphoneChatMessage *msg,
static
void
text_message
(
void
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
char
*
to
;
LinphoneChatRoom
*
chat_room
;
to
=
linphone_address_as_string
(
marie
->
identity
);
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
ms_free
(
to
);
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
{
int
dummy
=
0
;
wait_for_until
(
marie
->
lc
,
pauline
->
lc
,
&
dummy
,
1
,
100
);
/*just to have time to purge message stored in the server*/
...
...
@@ -206,16 +203,13 @@ static void text_message(void) {
}
static
void
text_message_within_dialog
(
void
)
{
char
*
to
;
LinphoneChatRoom
*
chat_room
;
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
lp_config_set_int
(
pauline
->
lc
->
config
,
"sip"
,
"chat_use_call_dialogs"
,
1
);
to
=
linphone_address_as_string
(
marie
->
identity
);
chat_room
=
linphone_core_create_chat_room
(
pauline
->
lc
,
to
);
ms_free
(
to
);
chat_room
=
linphone_core_get_chat_room
(
pauline
->
lc
,
marie
->
identity
);
{
int
dummy
=
0
;
wait_for_until
(
marie
->
lc
,
pauline
->
lc
,
&
dummy
,
1
,
100
);
/*just to have time to purge message stored in the server*/
...
...
@@ -243,7 +237,6 @@ static void text_message_with_credential_from_auth_cb_auth_info_requested(Linpho
static
void
text_message_with_credential_from_auth_cb
(
void
)
{
char
*
to
;
LinphoneChatRoom
*
chat_room
;
LinphoneCoreVTable
*
vtable