Commit 23397e26 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

friendlist: add linphone_friend_list_enable_subscriptions API

parent 29230187
...@@ -387,8 +387,9 @@ void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op) ...@@ -387,8 +387,9 @@ void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op)
static void linphone_friend_unsubscribe(LinphoneFriend *lf){ static void linphone_friend_unsubscribe(LinphoneFriend *lf){
if (lf->outsub!=NULL) { if (lf->outsub!=NULL) {
sal_unsubscribe(lf->outsub); 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){ void linphone_friend_invalidate_subscription(LinphoneFriend *lf){
......
...@@ -285,6 +285,7 @@ static bool_t linphone_friend_list_has_subscribe_inactive(const LinphoneFriendLi ...@@ -285,6 +285,7 @@ static bool_t linphone_friend_list_has_subscribe_inactive(const LinphoneFriendLi
static LinphoneFriendList * linphone_friend_list_new(void) { static LinphoneFriendList * linphone_friend_list_new(void) {
LinphoneFriendList *list = belle_sip_object_new(LinphoneFriendList); LinphoneFriendList *list = belle_sip_object_new(LinphoneFriendList);
list->cbs = linphone_friend_list_cbs_new(); list->cbs = linphone_friend_list_cbs_new();
list->enable_subscriptions = FALSE;
belle_sip_object_ref(list); belle_sip_object_ref(list);
return list; return list;
} }
...@@ -541,12 +542,12 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, ...@@ -541,12 +542,12 @@ static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new,
void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list) { void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list) {
LinphoneCardDavContext *cdc = NULL; LinphoneCardDavContext *cdc = NULL;
if (!list || !list->uri || !list->lc) { if (!list || !list->uri || !list->lc) {
ms_error("FATAL"); ms_error("FATAL");
return; return;
} }
cdc = linphone_carddav_context_new(list); cdc = linphone_carddav_context_new(list);
if (cdc) { if (cdc) {
cdc->contact_created_cb = carddav_created; cdc->contact_created_cb = carddav_created;
...@@ -606,19 +607,19 @@ LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe(const Linphon ...@@ -606,19 +607,19 @@ LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe(const Linphon
return NULL; return NULL;
} }
void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) { static void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) {
/* FIXME we should wait until subscription to complete. */ /* FIXME we should wait until subscription to complete. */
if (list->event) { if (list->event) {
linphone_event_terminate(list->event); linphone_event_terminate(list->event);
linphone_event_unref(list->event); linphone_event_unref(list->event);
list->event = NULL; 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) { void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
const MSList *elem; const MSList *elem;
if (list->rls_uri != NULL) { if (list->enable_subscriptions && list->rls_uri != NULL) {
LinphoneAddress *address = linphone_address_new(list->rls_uri); LinphoneAddress *address = linphone_address_new(list->rls_uri);
char *xml_content = create_resource_list_xml(list); char *xml_content = create_resource_list_xml(list);
if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) { 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 ...@@ -852,3 +853,14 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list
fclose(file); 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 ...@@ -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 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); 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 ...@@ -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); 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) ...@@ -6559,7 +6559,7 @@ static void linphone_core_uninit(LinphoneCore *lc)
for (elem = lc->friends_lists; elem != NULL; elem = ms_list_next(elem)) { for (elem = lc->friends_lists; elem != NULL; elem = ms_list_next(elem)) {
LinphoneFriendList *list = (LinphoneFriendList *)elem->data; LinphoneFriendList *list = (LinphoneFriendList *)elem->data;
linphone_friend_list_close_subscriptions(list); linphone_friend_list_enable_subscriptions(list, FALSE);
if (list->event) if (list->event)
wait_until_unsubscribe = TRUE; wait_until_unsubscribe = TRUE;
} }
......
...@@ -729,6 +729,7 @@ struct _LinphoneFriendList { ...@@ -729,6 +729,7 @@ struct _LinphoneFriendList {
MSList *dirty_friends_to_update; MSList *dirty_friends_to_update;
int revision; int revision;
LinphoneFriendListCbs *cbs; LinphoneFriendListCbs *cbs;
bool_t enable_subscriptions;
}; };
BELLE_SIP_DECLARE_VPTR(LinphoneFriendList); BELLE_SIP_DECLARE_VPTR(LinphoneFriendList);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment