Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblinphone
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
liblinphone
Commits
06f9d69a
Commit
06f9d69a
authored
Feb 01, 2016
by
Sylvain Berfini
🎩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added vtable callbacks for friend list created / removed + tests
parent
5fe2c68b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
18 deletions
+80
-18
friend.c
coreapi/friend.c
+2
-0
linphonecore.c
coreapi/linphonecore.c
+5
-3
linphonecore.h
coreapi/linphonecore.h
+16
-0
private.h
coreapi/private.h
+2
-0
vtables.c
coreapi/vtables.c
+10
-0
vcard_tester.c
tester/vcard_tester.c
+45
-15
No files found.
coreapi/friend.c
View file @
06f9d69a
...
...
@@ -918,6 +918,7 @@ int linphone_core_import_friends_from_vcard4_file(LinphoneCore *lc, const char *
#ifndef VCARD_ENABLED
ms_error
(
"vCard support wasn't enabled at compilation time"
);
return
-
1
;
#endif
if
(
!
vcards
)
{
ms_error
(
"Failed to parse the file %s"
,
vcard_file
);
...
...
@@ -948,6 +949,7 @@ int linphone_core_import_friends_from_vcard4_buffer(LinphoneCore *lc, const char
#ifndef VCARD_ENABLED
ms_error
(
"vCard support wasn't enabled at compilation time"
);
return
-
1
;
#endif
if
(
!
vcards
)
{
ms_error
(
"Failed to parse the buffer"
);
...
...
coreapi/linphonecore.c
View file @
06f9d69a
...
...
@@ -1937,12 +1937,13 @@ LinphoneFriendList* linphone_core_get_default_friend_list(const LinphoneCore *lc
void
linphone_core_remove_friend_list
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
)
{
MSList
*
elem
=
ms_list_find
(
lc
->
friends_lists
,
list
);
if
(
elem
==
NULL
)
return
;
list
->
lc
=
NULL
;
linphone_friend_list_unref
(
list
);
lc
->
friends_lists
=
ms_list_remove_link
(
lc
->
friends_lists
,
elem
);
#ifdef FRIENDS_SQL_STORAGE_ENABLED
linphone_core_remove_friends_list_from_db
(
lc
,
list
);
#endif
linphone_core_notify_friend_list_removed
(
lc
,
list
);
list
->
lc
=
NULL
;
linphone_friend_list_unref
(
list
);
lc
->
friends_lists
=
ms_list_remove_link
(
lc
->
friends_lists
,
elem
);
}
void
linphone_core_add_friend_list
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
)
{
...
...
@@ -1954,6 +1955,7 @@ void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) {
#ifdef FRIENDS_SQL_STORAGE_ENABLED
linphone_core_store_friends_list_in_db
(
lc
,
list
);
#endif
linphone_core_notify_friend_list_created
(
lc
,
list
);
}
else
{
const
char
*
rls_uri
=
lp_config_get_string
(
lc
->
config
,
"sip"
,
"rls_uri"
,
NULL
);
list
=
linphone_core_create_friend_list
(
lc
);
...
...
coreapi/linphonecore.h
View file @
06f9d69a
...
...
@@ -2068,6 +2068,20 @@ typedef void (*LinphoneCoreLogCollectionUploadStateChangedCb)(LinphoneCore *lc,
*/
typedef
void
(
*
LinphoneCoreLogCollectionUploadProgressIndicationCb
)(
LinphoneCore
*
lc
,
size_t
offset
,
size_t
total
);
/**
* Callback prototype for reporting when a friend list has been added to the core friends list.
* @param[in] lc LinphoneCore object
* @param[in] list LinphoneFriendList object
*/
typedef
void
(
*
LinphoneCoreFriendListCreatedCb
)
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
);
/**
* Callback prototype for reporting when a friend list has been removed from the core friends list.
* @param[in] lc LinphoneCore object
* @param[in] list LinphoneFriendList object
*/
typedef
void
(
*
LinphoneCoreFriendListRemovedCb
)
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
);
/**
* This structure holds all callbacks that the application should implement.
* None is mandatory.
...
...
@@ -2105,6 +2119,8 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreNetworkReachableCb
network_reachable
;
/**< Callback to report IP network status (I.E up/down )*/
LinphoneCoreLogCollectionUploadStateChangedCb
log_collection_upload_state_changed
;
/**< Callback to upload collected logs */
LinphoneCoreLogCollectionUploadProgressIndicationCb
log_collection_upload_progress_indication
;
/**< Callback to indicate log collection upload progress */
LinphoneCoreFriendListCreatedCb
friend_list_created
;
LinphoneCoreFriendListRemovedCb
friend_list_removed
;
void
*
user_data
;
/**<User data associated with the above callbacks */
}
LinphoneCoreVTable
;
...
...
coreapi/private.h
View file @
06f9d69a
...
...
@@ -1433,6 +1433,8 @@ void linphone_core_notify_subscription_state_changed(LinphoneCore *lc, LinphoneE
void
linphone_core_notify_publish_state_changed
(
LinphoneCore
*
lc
,
LinphoneEvent
*
lev
,
LinphonePublishState
state
);
void
linphone_core_notify_log_collection_upload_state_changed
(
LinphoneCore
*
lc
,
LinphoneCoreLogCollectionUploadState
state
,
const
char
*
info
);
void
linphone_core_notify_log_collection_upload_progress_indication
(
LinphoneCore
*
lc
,
size_t
offset
,
size_t
total
);
void
linphone_core_notify_friend_list_created
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
);
void
linphone_core_notify_friend_list_removed
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
);
void
set_mic_gain_db
(
AudioStream
*
st
,
float
gain
);
void
set_playback_gain_db
(
AudioStream
*
st
,
float
gain
);
...
...
coreapi/vtables.c
View file @
06f9d69a
...
...
@@ -264,6 +264,16 @@ void linphone_core_notify_log_collection_upload_progress_indication(LinphoneCore
cleanup_dead_vtable_refs
(
lc
);
}
void
linphone_core_notify_friend_list_created
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
)
{
NOTIFY_IF_EXIST
(
friend_list_created
,
lc
,
list
);
cleanup_dead_vtable_refs
(
lc
);
}
void
linphone_core_notify_friend_list_removed
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
)
{
NOTIFY_IF_EXIST
(
friend_list_removed
,
lc
,
list
);
cleanup_dead_vtable_refs
(
lc
);
}
static
VTableReference
*
v_table_reference_new
(
LinphoneCoreVTable
*
vtable
,
bool_t
autorelease
,
bool_t
internal
){
VTableReference
*
ref
=
ms_new0
(
VTableReference
,
1
);
ref
->
valid
=
1
;
...
...
tester/vcard_tester.c
View file @
06f9d69a
...
...
@@ -133,22 +133,46 @@ end:
linphone_core_manager_destroy
(
manager
);
}
typedef
struct
_LinphoneFriendListStats
{
int
new_list_count
;
int
removed_list_count
;
}
LinphoneFriendListStats
;
static
void
friend_list_created_cb
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
)
{
LinphoneFriendListStats
*
stats
=
(
LinphoneFriendListStats
*
)
linphone_friend_list_get_user_data
(
list
);
stats
->
new_list_count
++
;
}
static
void
friend_list_removed_cb
(
LinphoneCore
*
lc
,
LinphoneFriendList
*
list
)
{
LinphoneFriendListStats
*
stats
=
(
LinphoneFriendListStats
*
)
linphone_friend_list_get_user_data
(
list
);
stats
->
removed_list_count
++
;
}
static
void
friends_sqlite_storage
(
void
)
{
LinphoneCore
Manager
*
manager
=
linphone_core_manager_new2
(
"empty_rc"
,
FALSE
);
Linphone
FriendList
*
lfl
=
linphone_core_create_friend_list
(
manager
->
lc
)
;
Linphone
VCard
*
lvc
=
linphone_vcard_new
()
;
LinphoneCore
VTable
*
v_table
=
linphone_core_v_table_new
(
);
Linphone
Core
*
lc
=
NULL
;
Linphone
FriendList
*
lfl
=
NULL
;
LinphoneFriend
*
lf
=
NULL
;
LinphoneFriend
*
lf2
=
NULL
;
LinphoneVCard
*
lvc
=
linphone_vcard_new
();
LinphoneAddress
*
addr
=
linphone_address_new
(
"sip:sylvain@sip.linphone.org"
);
const
MSList
*
friends
=
linphone_core_get_friend_list
(
manager
->
lc
)
;
const
MSList
*
friends
=
NULL
;
MSList
*
friends_from_db
=
NULL
;
MSList
*
friends_lists_from_db
=
NULL
;
char
*
friends_db
=
create_filepath
(
bc_tester_get_writable_dir_prefix
(),
"friends"
,
"db"
);
LinphoneFriendListStats
*
stats
=
(
LinphoneFriendListStats
*
)
ms_new0
(
LinphoneFriendListStats
,
1
);
v_table
->
friend_list_created
=
friend_list_created_cb
;
v_table
->
friend_list_removed
=
friend_list_removed_cb
;
lc
=
linphone_core_new
(
v_table
,
NULL
,
NULL
,
NULL
);
friends
=
linphone_core_get_friend_list
(
lc
);
lfl
=
linphone_core_create_friend_list
(
lc
);
linphone_friend_list_set_user_data
(
lfl
,
stats
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends
),
0
,
int
,
"%d"
);
unlink
(
friends_db
);
linphone_core_set_friends_database_path
(
manager
->
lc
,
friends_db
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
manager
->
lc
,
linphone_core_get_default_friend_list
(
manager
->
lc
));
linphone_core_set_friends_database_path
(
lc
,
friends_db
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
lc
,
linphone_core_get_default_friend_list
(
lc
));
BC_ASSERT_EQUAL
(
ms_list_size
(
friends_from_db
),
0
,
int
,
"%d"
);
linphone_vcard_set_etag
(
lvc
,
"
\"
123-456789
\"
"
);
...
...
@@ -157,7 +181,9 @@ static void friends_sqlite_storage(void) {
linphone_friend_set_address
(
lf
,
addr
);
linphone_friend_set_name
(
lf
,
"Sylvain"
);
linphone_core_add_friend_list
(
manager
->
lc
,
lfl
);
linphone_core_add_friend_list
(
lc
,
lfl
);
wait_for_until
(
lc
,
NULL
,
&
stats
->
new_list_count
,
1
,
1000
);
BC_ASSERT_EQUAL
(
stats
->
new_list_count
,
1
,
int
,
"%i"
);
linphone_friend_list_unref
(
lfl
);
linphone_friend_list_set_display_name
(
lfl
,
"Test"
);
BC_ASSERT_EQUAL_FATAL
(
linphone_friend_list_add_friend
(
lfl
,
lf
),
LinphoneFriendListOK
,
int
,
"%i"
);
...
...
@@ -165,10 +191,10 @@ static void friends_sqlite_storage(void) {
BC_ASSERT_EQUAL
(
lfl
->
storage_id
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
lf
->
storage_id
,
1
,
int
,
"%d"
);
friends
=
linphone_core_get_friend_list
(
manager
->
lc
);
friends
=
linphone_core_get_friend_list
(
lc
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends
),
0
,
int
,
"%d"
);
friends_lists_from_db
=
linphone_core_fetch_friends_lists_from_db
(
manager
->
lc
);
friends_lists_from_db
=
linphone_core_fetch_friends_lists_from_db
(
lc
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends_lists_from_db
),
1
,
int
,
"%d"
);
friends_from_db
=
((
LinphoneFriendList
*
)
friends_lists_from_db
->
data
)
->
friends
;
BC_ASSERT_EQUAL
(
ms_list_size
(
friends_from_db
),
1
,
int
,
"%d"
);
...
...
@@ -177,7 +203,7 @@ static void friends_sqlite_storage(void) {
BC_ASSERT_PTR_NOT_NULL
(
lf2
->
friend_list
);
friends_lists_from_db
=
ms_list_free_with_data
(
friends_lists_from_db
,
(
void
(
*
)(
void
*
))
linphone_friend_list_unref
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
manager
->
lc
,
lfl
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
lc
,
lfl
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends_from_db
),
1
,
int
,
"%d"
);
if
(
ms_list_size
(
friends_from_db
)
<
1
)
{
goto
end
;
...
...
@@ -193,7 +219,7 @@ static void friends_sqlite_storage(void) {
linphone_friend_set_name
(
lf
,
"Margaux"
);
linphone_friend_done
(
lf
);
friends_from_db
=
ms_list_free_with_data
(
friends_from_db
,
(
void
(
*
)(
void
*
))
linphone_friend_unref
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
manager
->
lc
,
lfl
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
lc
,
lfl
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends_from_db
),
1
,
int
,
"%d"
);
if
(
ms_list_size
(
friends_from_db
)
<
1
)
{
goto
end
;
...
...
@@ -202,17 +228,21 @@ static void friends_sqlite_storage(void) {
BC_ASSERT_STRING_EQUAL
(
linphone_friend_get_name
(
lf2
),
"Margaux"
);
friends_from_db
=
ms_list_free_with_data
(
friends_from_db
,
(
void
(
*
)(
void
*
))
linphone_friend_unref
);
linphone_core_remove_friend
(
manager
->
lc
,
lf
);
friends
=
linphone_core_get_friend_list
(
manager
->
lc
);
linphone_core_remove_friend
(
lc
,
lf
);
friends
=
linphone_core_get_friend_list
(
lc
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends
),
0
,
int
,
"%d"
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
manager
->
lc
,
lfl
);
friends_from_db
=
linphone_core_fetch_friends_from_db
(
lc
,
lfl
);
BC_ASSERT_EQUAL
(
ms_list_size
(
friends_from_db
),
0
,
int
,
"%d"
);
linphone_core_remove_friend_list
(
lc
,
lfl
);
wait_for_until
(
lc
,
NULL
,
&
stats
->
removed_list_count
,
1
,
1000
);
BC_ASSERT_EQUAL
(
stats
->
removed_list_count
,
1
,
int
,
"%i"
);
end:
unlink
(
friends_db
);
ms_free
(
friends_db
);
linphone_address_unref
(
addr
);
linphone_core_
manager_destroy
(
manager
);
linphone_core_
destroy
(
lc
);
}
#endif
...
...
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