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
227de3e1
Commit
227de3e1
authored
Jun 05, 2017
by
jehan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix vcard object leak (initial ref count moved from 0 to 1)
parent
e350d2ca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
32 deletions
+39
-32
coreapi/carddav.c
coreapi/carddav.c
+1
-0
coreapi/friend.c
coreapi/friend.c
+1
-0
coreapi/friendlist.c
coreapi/friendlist.c
+26
-32
tester/vcard_tester.c
tester/vcard_tester.c
+11
-0
No files found.
coreapi/carddav.c
View file @
227de3e1
...
...
@@ -129,6 +129,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
ms_debug
(
"Downloaded vCard etag/url are %s and %s"
,
vCard
->
etag
,
full_url
);
lf
=
linphone_friend_new_from_vcard
(
lvc
);
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
);
...
...
coreapi/friend.c
View file @
227de3e1
...
...
@@ -1397,6 +1397,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) {
linphone_vcard_set_etag
(
vcard
,
argv
[
7
]);
linphone_vcard_set_url
(
vcard
,
argv
[
8
]);
lf
=
linphone_friend_new_from_vcard
(
vcard
);
linphone_vcard_unref
(
vcard
);
}
if
(
!
lf
)
{
lf
=
linphone_friend_new
();
...
...
coreapi/friendlist.c
View file @
227de3e1
...
...
@@ -1007,11 +1007,10 @@ LinphoneCore* linphone_friend_list_get_core(const LinphoneFriendList *list) {
return
list
->
lc
;
}
LinphoneStatus
linphone_friend_list_import_friends_from_vcard4_file
(
LinphoneFriendList
*
list
,
const
char
*
vcard_file
)
{
bctbx_list_t
*
vcards
=
NULL
;
static
LinphoneStatus
linphone_friend_list_import_friends_from_vcard4
(
LinphoneFriendList
*
list
,
bctbx_list_t
*
vcards
)
{
bctbx_list_t
*
vcards_iterator
=
NULL
;
int
count
=
0
;
if
(
!
linphone_core_vcard_supported
())
{
ms_error
(
"vCard support wasn't enabled at compilation time"
);
return
-
1
;
...
...
@@ -1020,37 +1019,49 @@ LinphoneStatus linphone_friend_list_import_friends_from_vcard4_file(LinphoneFrie
ms_error
(
"Can't import into a NULL list"
);
return
-
1
;
}
vcards
=
linphone_vcard_context_get_vcard_list_from_file
(
list
->
lc
->
vcard_context
,
vcard_file
);
vcards_iterator
=
vcards
;
if
(
!
vcards
)
{
ms_error
(
"Failed to parse the file %s"
,
vcard_file
);
return
-
1
;
}
while
(
vcards_iterator
!=
NULL
&&
bctbx_list_get_data
(
vcards_iterator
)
!=
NULL
)
{
LinphoneVcard
*
vcard
=
(
LinphoneVcard
*
)
bctbx_list_get_data
(
vcards_iterator
);
LinphoneFriend
*
lf
=
linphone_friend_new_from_vcard
(
vcard
);
linphone_vcard_unref
(
vcard
);
if
(
lf
)
{
if
(
LinphoneFriendListOK
==
linphone_friend_list_import_friend
(
list
,
lf
,
TRUE
))
{
linphone_friend_save
(
lf
,
lf
->
lc
);
count
++
;
}
linphone_friend_unref
(
lf
);
}
else
{
linphone_vcard_unref
(
vcard
);
}
vcards_iterator
=
bctbx_list_next
(
vcards_iterator
);
}
bctbx_list_free
(
vcards
);
linphone_core_store_friends_list_in_db
(
list
->
lc
,
list
);
return
count
;
}
LinphoneStatus
linphone_friend_list_import_friends_from_vcard4_file
(
LinphoneFriendList
*
list
,
const
char
*
vcard_file
)
{
bctbx_list_t
*
vcards
=
NULL
;
if
(
!
linphone_core_vcard_supported
())
{
ms_error
(
"vCard support wasn't enabled at compilation time"
);
return
-
1
;
}
if
(
!
list
)
{
ms_error
(
"Can't import into a NULL list"
);
return
-
1
;
}
vcards
=
linphone_vcard_context_get_vcard_list_from_file
(
list
->
lc
->
vcard_context
,
vcard_file
);
if
(
!
vcards
)
{
ms_error
(
"Failed to parse the file %s"
,
vcard_file
);
return
-
1
;
}
return
linphone_friend_list_import_friends_from_vcard4
(
list
,
vcards
);
}
LinphoneStatus
linphone_friend_list_import_friends_from_vcard4_buffer
(
LinphoneFriendList
*
list
,
const
char
*
vcard_buffer
)
{
bctbx_list_t
*
vcards
=
NULL
;
bctbx_list_t
*
vcards_iterator
=
NULL
;
int
count
=
0
;
if
(
!
linphone_core_vcard_supported
())
{
ms_error
(
"vCard support wasn't enabled at compilation time"
);
...
...
@@ -1062,29 +1073,12 @@ LinphoneStatus linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFr
}
vcards
=
linphone_vcard_context_get_vcard_list_from_buffer
(
list
->
lc
->
vcard_context
,
vcard_buffer
);
vcards_iterator
=
vcards
;
if
(
!
vcards
)
{
ms_error
(
"Failed to parse the buffer"
);
return
-
1
;
}
while
(
vcards_iterator
!=
NULL
&&
bctbx_list_get_data
(
vcards_iterator
)
!=
NULL
)
{
LinphoneVcard
*
vcard
=
(
LinphoneVcard
*
)
bctbx_list_get_data
(
vcards_iterator
);
LinphoneFriend
*
lf
=
linphone_friend_new_from_vcard
(
vcard
);
if
(
lf
)
{
if
(
LinphoneFriendListOK
==
linphone_friend_list_import_friend
(
list
,
lf
,
TRUE
))
{
count
++
;
}
linphone_friend_unref
(
lf
);
}
else
{
linphone_vcard_unref
(
vcard
);
}
vcards_iterator
=
bctbx_list_next
(
vcards_iterator
);
}
bctbx_list_free
(
vcards
);
linphone_core_store_friends_list_in_db
(
list
->
lc
,
list
);
return
count
;
}
return
linphone_friend_list_import_friends_from_vcard4
(
list
,
vcards
);}
void
linphone_friend_list_export_friends_as_vcard4_file
(
LinphoneFriendList
*
list
,
const
char
*
vcard_file
)
{
FILE
*
file
=
NULL
;
...
...
tester/vcard_tester.c
View file @
227de3e1
...
...
@@ -147,6 +147,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
LinphoneCoreManager
*
manager
=
linphone_core_manager_new2
(
"empty_rc"
,
FALSE
);
LinphoneVcard
*
lvc
=
linphone_vcard_context_get_vcard_from_buffer
(
manager
->
lc
->
vcard_context
,
"BEGIN:VCARD
\r\n
VERSION:4.0
\r\n
FN:Sylvain Berfini
\r\n
IMPP:sip:sberfini@sip.linphone.org
\r\n
IMPP;TYPE=home:sip:sylvain@sip.linphone.org
\r\n
TEL;TYPE=work:0952636505
\r\n
END:VCARD
\r\n
"
);
LinphoneFriend
*
lf
=
linphone_friend_new_from_vcard
(
lvc
);
linphone_vcard_unref
(
lvc
);
const
bctbx_list_t
*
sip_addresses
=
linphone_friend_get_addresses
(
lf
);
bctbx_list_t
*
phone_numbers
=
linphone_friend_get_phone_numbers
(
lf
);
LinphoneAddress
*
addr
=
NULL
;
...
...
@@ -158,6 +159,7 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
lvc
=
linphone_vcard_context_get_vcard_from_buffer
(
manager
->
lc
->
vcard_context
,
"BEGIN:VCARD
\r\n
VERSION:4.0
\r\n
FN:Sylvain Berfini
\r\n
TEL;TYPE=work:0952636505
\r\n
TEL:0476010203
\r\n
END:VCARD
\r\n
"
);
lf
=
linphone_friend_new_from_vcard
(
lvc
);
linphone_vcard_unref
(
lvc
);
lf
->
lc
=
manager
->
lc
;
sip_addresses
=
linphone_friend_get_addresses
(
lf
);
phone_numbers
=
linphone_friend_get_phone_numbers
(
lf
);
...
...
@@ -301,6 +303,7 @@ static void friends_sqlite_storage(void) {
linphone_vcard_set_etag
(
lvc
,
"
\"
123-456789
\"
"
);
linphone_vcard_set_url
(
lvc
,
"http://dav.somewhere.fr/addressbook/me/someone.vcf"
);
lf
=
linphone_friend_new_from_vcard
(
lvc
);
linphone_vcard_unref
(
lvc
);
linphone_friend_set_address
(
lf
,
addr
);
linphone_friend_set_name
(
lf
,
"Sylvain"
);
...
...
@@ -635,6 +638,7 @@ static void carddav_sync_3(void) {
LinphoneFriendList
*
lfl
=
linphone_core_create_friend_list
(
manager
->
lc
);
LinphoneCardDavContext
*
c
=
NULL
;
linphone_vcard_unref
(
lvc
);
linphone_friend_list_set_uri
(
lfl
,
CARDDAV_SERVER
);
linphone_core_add_friend_list
(
manager
->
lc
,
lfl
);
linphone_friend_list_unref
(
lfl
);
...
...
@@ -674,6 +678,7 @@ static void carddav_sync_4(void) {
LinphoneFriendList
*
lfl
=
linphone_core_create_friend_list
(
manager
->
lc
);
LinphoneCardDavContext
*
c
=
NULL
;
linphone_vcard_unref
(
lvc
);
linphone_friend_list_set_uri
(
lfl
,
CARDDAV_SERVER
);
linphone_core_add_friend_list
(
manager
->
lc
,
lfl
);
linphone_friend_list_unref
(
lfl
);
...
...
@@ -740,6 +745,7 @@ static void carddav_integration(void) {
char
*
address
=
NULL
;
const
LinphoneAddress
*
addr
;
linphone_vcard_unref
(
lvc
);
linphone_friend_list_set_uri
(
lfl
,
CARDDAV_SERVER
);
cbs
=
linphone_friend_list_get_callbacks
(
lfl
);
linphone_friend_list_cbs_set_user_data
(
cbs
,
stats
);
...
...
@@ -766,12 +772,14 @@ static void carddav_integration(void) {
lvc
=
linphone_vcard_context_get_vcard_from_buffer
(
manager
->
lc
->
vcard_context
,
"BEGIN:VCARD
\r\n
VERSION:4.0
\r\n
FN:Ghislain Mary
\r\n
IMPP;TYPE=work:sip:ghislain@sip.linphone.org
\r\n
END:VCARD
\r\n
"
);
lf
=
linphone_friend_new_from_vcard
(
lvc
);
linphone_vcard_unref
(
lvc
);
BC_ASSERT_EQUAL
(
linphone_friend_list_add_local_friend
(
lfl
,
lf
),
LinphoneFriendListOK
,
int
,
"%d"
);
linphone_friend_unref
(
lf
);
lvc2
=
linphone_vcard_context_get_vcard_from_buffer
(
manager
->
lc
->
vcard_context
,
"BEGIN:VCARD
\r\n
VERSION:4.0
\r\n
FN:Sylvain Berfini
\r\n
IMPP:sip:sberfini@sip.linphone.org
\r\n
UID:1f08dd48-29ac-4097-8e48-8596d7776283
\r\n
END:VCARD
\r\n
"
);
linphone_vcard_set_url
(
lvc2
,
"/card.php/addressbooks/tester/default/me.vcf"
);
lf2
=
linphone_friend_new_from_vcard
(
lvc2
);
linphone_vcard_unref
(
lvc2
);
linphone_friend_set_ref_key
(
lf2
,
refkey
);
BC_ASSERT_EQUAL
(
linphone_friend_list_add_local_friend
(
lfl
,
lf2
),
LinphoneFriendListOK
,
int
,
"%d"
);
...
...
@@ -853,6 +861,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
lvc
=
linphone_vcard_context_get_vcard_from_buffer
(
manager
->
lc
->
vcard_context
,
"BEGIN:VCARD
\r\n
VERSION:4.0
\r\n
FN:Sylvain Berfini
\r\n
IMPP:sip:sylvain@sip.linphone.org
\r\n
UID:1f08dd48-29ac-4097-8e48-8596d7776283
\r\n
END:VCARD
\r\n
"
);
linphone_vcard_set_url
(
lvc
,
"http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf"
);
lf
=
linphone_friend_new_from_vcard
(
lvc
);
linphone_vcard_unref
(
lvc
);
linphone_friend_list_add_friend
(
lfl
,
lf
);
wait_for_until
(
manager
->
lc
,
NULL
,
&
stats
->
sync_done_count
,
1
,
CARDDAV_SYNC_TIMEOUT
);
BC_ASSERT_EQUAL
(
stats
->
sync_done_count
,
1
,
int
,
"%i"
);
...
...
@@ -904,6 +913,8 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) {
LinphoneFriend
*
lf2
=
linphone_friend_new_from_vcard
(
lvc2
);
bctbx_list_t
*
friends
=
NULL
,
*
friends_iterator
=
NULL
;
linphone_vcard_unref
(
lvc1
);
linphone_vcard_unref
(
lvc2
);
linphone_friend_list_cbs_set_user_data
(
cbs
,
stats
);
linphone_friend_list_cbs_set_contact_created
(
cbs
,
carddav_contact_created
);
linphone_friend_list_cbs_set_contact_deleted
(
cbs
,
carddav_contact_deleted
);
...
...
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