Commit bf8735e4 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added callback on friend list with all friends that have received presence...

Added callback on friend list with all friends that have received presence information in last multipart
parent 266bb2ef
......@@ -93,6 +93,14 @@ void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs
cbs->sync_state_changed_cb = cb;
}
LinphoneFriendListCbsPresenceReceivedCb linphone_friend_list_cbs_get_presence_received(const LinphoneFriendListCbs *cbs) {
return cbs->presence_received_cb;
}
void linphone_friend_list_cbs_set_presence_received(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsPresenceReceivedCb cb) {
cbs->presence_received_cb = cb;
}
static int add_uri_entry(xmlTextWriterPtr writer, int err, const char *uri) {
if (err >= 0) {
err = xmlTextWriterStartElement(writer, (const xmlChar *)"entry");
......@@ -216,6 +224,8 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
bool_t full_state = FALSE;
int version;
int i;
bctbx_list_t *list_friends_presence_received = NULL;
LinphoneFriendListCbs *list_cbs = linphone_friend_list_get_callbacks(list);
if (linphone_create_xml_xpath_context(xml_ctx) < 0) goto end;
xmlXPathRegisterNs(xml_ctx->xpath_ctx, (const xmlChar *)"rlmi", (const xmlChar *)"urn:ietf:params:xml:ns:rlmi");
......@@ -302,7 +312,9 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
linphone_core_notify_notify_presence_received_for_uri_or_tel(list->lc, lf, phone_number, (LinphonePresenceModel *)presence);
else
linphone_core_notify_notify_presence_received_for_uri_or_tel(list->lc, lf, uri, (LinphonePresenceModel *)presence);
// Deprecated
linphone_core_notify_notify_presence_received(list->lc, lf);
list_friends_presence_received = bctbx_list_prepend(list_friends_presence_received, lf);
}
linphone_free_xml_text_content(uri);
}
......@@ -312,6 +324,11 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
linphone_free_xml_text_content(cid);
}
}
// Notify list with all friends for which we received presence information
if (bctbx_list_size(list_friends_presence_received) > 0 && list_cbs && linphone_friend_list_cbs_get_presence_received(list_cbs)) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received);
}
bctbx_list_free(list_friends_presence_received);
}
if (resource_object)
xmlXPathFreeObject(resource_object);
......@@ -345,9 +362,16 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
}
if (numbers) bctbx_list_free(numbers);
if (linphone_friend_is_presence_received(lf)) {
// Deprecated
linphone_core_notify_notify_presence_received(list->lc, lf);
list_friends_presence_received = bctbx_list_prepend(list_friends_presence_received, lf);
}
}
// Notify list with all friends for which we received presence information
if (bctbx_list_size(list_friends_presence_received) > 0 && list_cbs && linphone_friend_list_cbs_get_presence_received(list_cbs)) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received);
}
bctbx_list_free(list_friends_presence_received);
}
} else {
ms_warning("Wrongly formatted rlmi+xml body: %s", xml_ctx->errorBuffer);
......
......@@ -198,6 +198,7 @@ struct _LinphoneFriendListCbs {
LinphoneFriendListCbsContactDeletedCb contact_deleted_cb;
LinphoneFriendListCbsContactUpdatedCb contact_updated_cb;
LinphoneFriendListCbsSyncStateChangedCb sync_state_changed_cb;
LinphoneFriendListCbsPresenceReceivedCb presence_received_cb;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriendListCbs);
......
......@@ -515,6 +515,13 @@ typedef void (*LinphoneFriendListCbsContactUpdatedCb)(LinphoneFriendList *list,
**/
typedef void (*LinphoneFriendListCbsSyncStateChangedCb)(LinphoneFriendList *list, LinphoneFriendListSyncStatus status, const char *msg);
/**
* Callback used to notify a list with all friends that have received presence information.
* @param list The #LinphoneFriendList object for which the status has changed
* @param friends A \bctbx_list{LinphoneFriend} of the relevant friends
**/
typedef void (*LinphoneFriendListCbsPresenceReceivedCb)(LinphoneFriendList *list, const bctbx_list_t *friends);
/**
* @}
**/
......
......@@ -298,6 +298,20 @@ LINPHONE_PUBLIC LinphoneFriendListCbsSyncStateChangedCb linphone_friend_list_cbs
**/
LINPHONE_PUBLIC void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsSyncStateChangedCb cb);
/**
* Get the presence received callback.
* @param[in] cbs #LinphoneFriendListCbs object.
* @return The current presence received callback.
**/
LINPHONE_PUBLIC LinphoneFriendListCbsPresenceReceivedCb linphone_friend_list_cbs_get_presence_received(const LinphoneFriendListCbs *cbs);
/**
* Set the presence received callback.
* @param[in] cbs #LinphoneFriendListCbs object.
* @param[in] cb The presence received callback to be used.
**/
LINPHONE_PUBLIC void linphone_friend_list_cbs_set_presence_received(LinphoneFriendListCbs *cbs, LinphoneFriendListCbsPresenceReceivedCb cb);
/**
* Starts a CardDAV synchronization using value set using linphone_friend_list_set_uri.
* @param[in] list #LinphoneFriendList object.
......
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