mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 14:18:07 +00:00
friendlist: add linphone_friend_list_enable_subscriptions API
This commit is contained in:
parent
29230187e1
commit
23397e26be
5 changed files with 30 additions and 11 deletions
|
|
@ -387,8 +387,9 @@ void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op)
|
|||
static void linphone_friend_unsubscribe(LinphoneFriend *lf){
|
||||
if (lf->outsub!=NULL) {
|
||||
sal_unsubscribe(lf->outsub);
|
||||
lf->subscribe_active=FALSE;
|
||||
}
|
||||
/* for friend list there is no necessary outsub*/
|
||||
lf->subscribe_active=FALSE;
|
||||
}
|
||||
|
||||
void linphone_friend_invalidate_subscription(LinphoneFriend *lf){
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ static bool_t linphone_friend_list_has_subscribe_inactive(const LinphoneFriendLi
|
|||
static LinphoneFriendList * linphone_friend_list_new(void) {
|
||||
LinphoneFriendList *list = belle_sip_object_new(LinphoneFriendList);
|
||||
list->cbs = linphone_friend_list_cbs_new();
|
||||
list->enable_subscriptions = FALSE;
|
||||
belle_sip_object_ref(list);
|
||||
return list;
|
||||
}
|
||||
|
|
@ -541,12 +542,12 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new,
|
|||
|
||||
void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list) {
|
||||
LinphoneCardDavContext *cdc = NULL;
|
||||
|
||||
|
||||
if (!list || !list->uri || !list->lc) {
|
||||
ms_error("FATAL");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cdc = linphone_carddav_context_new(list);
|
||||
if (cdc) {
|
||||
cdc->contact_created_cb = carddav_created;
|
||||
|
|
@ -606,19 +607,19 @@ LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe(const Linphon
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) {
|
||||
/* FIXME we should wait until subscription to complete. */
|
||||
static void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) {
|
||||
/* FIXME we should wait until subscription to complete. */
|
||||
if (list->event) {
|
||||
linphone_event_terminate(list->event);
|
||||
linphone_event_unref(list->event);
|
||||
list->event = NULL;
|
||||
} else if (list->friends)
|
||||
ms_list_for_each(list->friends, (void (*)(void *))linphone_friend_close_subscriptions);
|
||||
}
|
||||
ms_list_for_each(list->friends, (void (*)(void *))linphone_friend_close_subscriptions);
|
||||
}
|
||||
|
||||
void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
|
||||
const MSList *elem;
|
||||
if (list->rls_uri != NULL) {
|
||||
if (list->enable_subscriptions && list->rls_uri != NULL) {
|
||||
LinphoneAddress *address = linphone_address_new(list->rls_uri);
|
||||
char *xml_content = create_resource_list_xml(list);
|
||||
if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) {
|
||||
|
|
@ -852,3 +853,14 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list
|
|||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void linphone_friend_list_enable_subscriptions(LinphoneFriendList *list, bool_t enabled) {
|
||||
if (list->enable_subscriptions != enabled) {
|
||||
if (enabled) {
|
||||
linphone_friend_list_update_subscriptions(list, NULL, TRUE);
|
||||
} else {
|
||||
linphone_friend_list_close_subscriptions(list);
|
||||
}
|
||||
list->enable_subscriptions = enabled;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,8 +209,6 @@ LINPHONE_PUBLIC LinphoneFriend * linphone_friend_list_find_friend_by_uri(const L
|
|||
**/
|
||||
LINPHONE_PUBLIC LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFriendList *list, const char *ref_key);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_friend_list_close_subscriptions(LinphoneFriendList *list);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered);
|
||||
|
||||
/**
|
||||
|
|
@ -408,6 +406,13 @@ LINPHONE_PUBLIC int linphone_friend_list_import_friends_from_vcard4_buffer(Linph
|
|||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list, const char *vcard_file);
|
||||
|
||||
/**
|
||||
* Enable subscription to NOTIFYes of all friends list
|
||||
* @param[in] list the LinphoneFriendList object
|
||||
* @param[in] enabled should subscription be enabled or not
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_list_enable_subscriptions(LinphoneFriendList *list, bool_t enabled);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6559,7 +6559,7 @@ static void linphone_core_uninit(LinphoneCore *lc)
|
|||
|
||||
for (elem = lc->friends_lists; elem != NULL; elem = ms_list_next(elem)) {
|
||||
LinphoneFriendList *list = (LinphoneFriendList *)elem->data;
|
||||
linphone_friend_list_close_subscriptions(list);
|
||||
linphone_friend_list_enable_subscriptions(list, FALSE);
|
||||
if (list->event)
|
||||
wait_until_unsubscribe = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -729,6 +729,7 @@ struct _LinphoneFriendList {
|
|||
MSList *dirty_friends_to_update;
|
||||
int revision;
|
||||
LinphoneFriendListCbs *cbs;
|
||||
bool_t enable_subscriptions;
|
||||
};
|
||||
|
||||
BELLE_SIP_DECLARE_VPTR(LinphoneFriendList);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue