Commit 1d262248 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Started CardDAV integration into liblinphone friends API

parent 3ae31c37
......@@ -43,6 +43,7 @@ linphone_include_HEADERS=\
sipsetup.h \
xml2lpc.h \
xmlrpc.h \
vcard.h \
carddav.h
lib_LTLIBRARIES=liblinphone.la
......@@ -120,10 +121,10 @@ liblinphone_la_SOURCES+=linphone_tunnel_stubs.c linphone_tunnel.h
endif
if BUILD_VCARD
liblinphone_la_SOURCES+=vcard.cc vcard.h
liblinphone_la_SOURCES+=vcard.cc
liblinphone_la_CXXFLAGS=-std=c++11
else
liblinphone_la_SOURCES+=vcard_stubs.c vcard.h
liblinphone_la_SOURCES+=vcard_stubs.c
endif
liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION) -no-undefined
......@@ -157,6 +158,7 @@ liblinphone_la_LIBADD= \
AM_CPPFLAGS=\
-DIN_LINPHONE \
-I$(top_srcdir) -I$(top_srcdir)/include -I$(builddir) \
$(ORTP_CFLAGS) \
$(MEDIASTREAMER_CFLAGS) \
......
......@@ -20,13 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef LINPHONE_ACCOUNT_CREATOR_H_
#define LINPHONE_ACCOUNT_CREATOR_H_
#include "linphonecore.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "linphonecore.h"
/**
* @addtogroup misc
* @{
......
......@@ -20,29 +20,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore.h"
#include "private.h"
LinphoneCardDavContext* linphone_core_create_carddav_context(LinphoneCore *lc) {
LinphoneCardDavContext* linphone_carddav_context_new(LinphoneFriendList *lfl) {
LinphoneCardDavContext *carddav_context = NULL;
if (!lc) {
if (!lfl || !lfl->uri) {
return NULL;
}
#ifdef VCARD_ENABLED
carddav_context = (LinphoneCardDavContext *)ms_new0(LinphoneCardDavContext, 1);
carddav_context->lc = lc;
carddav_context->server_url = linphone_core_get_carddav_server_url(lc);
carddav_context->ctag = linphone_core_get_carddav_last_ctag(lc);
carddav_context->username = linphone_core_get_carddav_username(lc);
carddav_context->password = linphone_core_get_carddav_password(lc);
carddav_context->ha1 = linphone_core_get_carddav_ha1(lc);
carddav_context->friend_list = linphone_friend_list_ref(lfl);
#else
ms_error("vCard isn't available (maybe it wasn't compiled), can't do CardDAV sync");
#endif
return carddav_context;
}
void linphone_carddav_destroy(LinphoneCardDavContext *cdc) {
void linphone_carddav_context_destroy(LinphoneCardDavContext *cdc) {
if (cdc) {
if (cdc->friend_list) {
linphone_friend_list_unref(cdc->friend_list);
cdc->friend_list = NULL;
}
ms_free(cdc);
}
}
......@@ -62,7 +61,7 @@ void linphone_carddav_synchronize(LinphoneCardDavContext *cdc) {
static void linphone_carddav_sync_done(LinphoneCardDavContext *cdc, bool_t success, const char *msg) {
if (success) {
ms_debug("CardDAV sync successful, saving new cTag: %i", cdc->ctag);
linphone_core_set_carddav_current_ctag(cdc->lc, cdc->ctag);
linphone_friend_list_update_revision(cdc->friend_list, cdc->ctag);
} else {
ms_error("CardDAV sync failure: %s", msg);
}
......@@ -75,8 +74,12 @@ static void linphone_carddav_sync_done(LinphoneCardDavContext *cdc, bool_t succe
static int find_matching_friend(LinphoneFriend *lf1, LinphoneFriend *lf2) {
LinphoneVCard *lvc1 = linphone_friend_get_vcard(lf1);
LinphoneVCard *lvc2 = linphone_friend_get_vcard(lf2);
const char *uid1 = linphone_vcard_get_uid(lvc1);
const char *uid2 = linphone_vcard_get_uid(lvc2);
const char *uid1 = NULL, *uid2 = NULL;
if (!lvc1 || !lvc2) {
return 1;
}
uid1 = linphone_vcard_get_uid(lvc1);
uid2 = linphone_vcard_get_uid(lvc2);
if (!uid1 || !uid2) {
return 1;
}
......@@ -85,7 +88,7 @@ static int find_matching_friend(LinphoneFriend *lf1, LinphoneFriend *lf2) {
static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList *vCards) {
if (vCards != NULL && ms_list_size(vCards) > 0) {
MSList *localFriends = linphone_core_fetch_friends_from_db(cdc->lc);
MSList *friends = cdc->friend_list->friends;
while (vCards) {
LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data;
if (vCard) {
......@@ -97,13 +100,13 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList *
// Compute downloaded vCards' URL and save it (+ eTag)
char *vCard_name = strrchr(vCard->url, '/');
char full_url[300];
snprintf(full_url, sizeof(full_url), "%s%s", cdc->server_url, vCard_name);
snprintf(full_url, sizeof(full_url), "%s%s", cdc->friend_list->uri, vCard_name);
linphone_vcard_set_url(lvc, full_url);
linphone_vcard_set_etag(lvc, vCard->etag);
ms_debug("Downloaded vCard etag/url are %s and %s", vCard->etag, full_url);
}
lf = linphone_friend_new_from_vcard(lvc);
local_friend = ms_list_find_custom(localFriends, (int (*)(const void*, const void*))find_matching_friend, lf);
local_friend = ms_list_find_custom(friends, (int (*)(const void*, const void*))find_matching_friend, lf);
if (local_friend) {
LinphoneFriend *lf2 = (LinphoneFriend *)local_friend->data;
......@@ -121,7 +124,6 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList *
}
vCards = ms_list_next(vCards);
}
localFriends = ms_list_free_with_data(localFriends, (void (*)(void *))linphone_friend_unref);
}
ms_list_free(vCards);
linphone_carddav_sync_done(cdc, TRUE, "");
......@@ -169,8 +171,12 @@ end:
static int find_matching_vcard(LinphoneCardDavResponse *response, LinphoneFriend *lf) {
LinphoneVCard *lvc1 = linphone_vcard_new_from_vcard4_buffer(response->vcard);
LinphoneVCard *lvc2 = linphone_friend_get_vcard(lf);
const char *uid1 = linphone_vcard_get_uid(lvc1);
const char *uid2 = linphone_vcard_get_uid(lvc2);
const char *uid1 = NULL, *uid2 = NULL;
if (!lvc1 || !lvc2) {
return 1;
}
uid1 = linphone_vcard_get_uid(lvc1);
uid2 = linphone_vcard_get_uid(lvc2);
linphone_vcard_free(lvc1);
if (!uid1 || !uid2) {
return 1;
......@@ -180,8 +186,7 @@ static int find_matching_vcard(LinphoneCardDavResponse *response, LinphoneFriend
static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, MSList *vCards) {
if (vCards != NULL && ms_list_size(vCards) > 0) {
MSList *localFriends = linphone_core_fetch_friends_from_db(cdc->lc);
MSList *friends = localFriends;
MSList *friends = cdc->friend_list->friends;
while (friends) {
LinphoneFriend *lf = (LinphoneFriend *)friends->data;
if (lf) {
......@@ -208,7 +213,6 @@ static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, MSList
}
friends = ms_list_next(friends);
}
localFriends = ms_list_free_with_data(localFriends, (void (*)(void *))linphone_friend_unref);
linphone_carddav_pull_vcards(cdc, vCards);
}
ms_list_free(vCards);
......@@ -372,22 +376,7 @@ static void process_io_error_from_carddav_request(void *data, const belle_sip_io
}
static void process_auth_requested_from_carddav_request(void *data, belle_sip_auth_event_t *event) {
LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)data;
LinphoneCardDavContext *context = query->context;
if (context->username && (context->password || context->ha1)) {
belle_sip_auth_event_set_username(event, context->username);
if (context->password) {
belle_sip_auth_event_set_passwd(event, context->password);
}
if (context->ha1) {
belle_sip_auth_event_set_ha1(event, context->ha1);
}
} else {
ms_error("Authentication requested during CardDAV request sending, and username/password weren't provided");
linphone_carddav_query_free(query);
linphone_carddav_sync_done(query->context, FALSE, "Authentication requested during CardDAV request sending, and username/password weren't provided");
}
//TODO //FIXME: find a way around this
}
static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
......@@ -434,7 +423,7 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
cbs.process_io_error = process_io_error_from_carddav_request;
cbs.process_auth_requested = process_auth_requested_from_carddav_request;
query->http_request_listener = belle_http_request_listener_create_from_callbacks(&cbs, query);
belle_http_provider_send_request(query->context->lc->http_provider, req, query->http_request_listener);
belle_http_provider_send_request(query->context->friend_list->lc->http_provider, req, query->http_request_listener);
}
static LinphoneCardDavQuery* linphone_carddav_create_put_query(LinphoneCardDavContext *cdc, LinphoneVCard *lvc) {
......@@ -468,7 +457,7 @@ void linphone_carddav_put_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *lf)
LinphoneCardDavQuery *query = NULL;
if (!linphone_vcard_get_url(lvc)) {
char *url = generate_url_from_server_address_and_uid(cdc->server_url);
char *url = generate_url_from_server_address_and_uid(cdc->friend_list->uri);
linphone_vcard_set_url(lvc, url);
ms_free(url);
}
......@@ -512,7 +501,7 @@ void linphone_carddav_delete_vcard(LinphoneCardDavContext *cdc, LinphoneFriend *
LinphoneCardDavQuery *query = NULL;
if (!linphone_vcard_get_url(lvc)) {
char *url = generate_url_from_server_address_and_uid(cdc->server_url);
char *url = generate_url_from_server_address_and_uid(cdc->friend_list->uri);
linphone_vcard_set_url(lvc, url);
ms_free(url);
}
......@@ -562,7 +551,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_propfind_query(LinphoneCard
query->ifmatch = NULL;
query->body = "<d:propfind xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\"><d:prop><cs:getctag /></d:prop></d:propfind>";
query->method = "PROPFIND";
query->url = cdc->server_url;
query->url = cdc->friend_list->uri;
query->type = LinphoneCardDavQueryTypePropfind;
return query;
}
......@@ -579,7 +568,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_query(LinphoneC
query->ifmatch = NULL;
query->body = "<card:addressbook-query xmlns:d=\"DAV:\" xmlns:card=\"urn:ietf:params:xml:ns:carddav\"><d:prop><d:getetag /></d:prop></card:addressbook-query>";
query->method = "REPORT";
query->url = cdc->server_url;
query->url = cdc->friend_list->uri;
query->type = LinphoneCardDavQueryTypeAddressbookQuery;
return query;
}
......@@ -598,7 +587,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query(
query->depth = "1";
query->ifmatch = NULL;
query->method = "REPORT";
query->url = cdc->server_url;
query->url = cdc->friend_list->uri;
query->type = LinphoneCardDavQueryTypeAddressbookMultiget;
sprintf(body, "%s", "<card:addressbook-multiget xmlns:d=\"DAV:\" xmlns:card=\"urn:ietf:params:xml:ns:carddav\"><d:prop><d:getetag /><card:address-data content-type='text/vcard' version='4.0'/></d:prop>");
......
......@@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef LINPHONE_CARDDAV_H
#define LINPHONE_CARDDAV_H
#include "linphonecore.h"
#ifdef __cplusplus
extern "C" {
#endif
......@@ -65,16 +67,16 @@ typedef void (*LinphoneCardDavSynchronizationDoneCb)(LinphoneCardDavContext *cdc
/**
* Creates a CardDAV context for all related operations
* @param lc LinphoneCore object
* @param lfl LinphoneFriendList object
* @return LinphoneCardDavContext object if vCard support is enabled and server URL is available, NULL otherwise
*/
LINPHONE_PUBLIC LinphoneCardDavContext* linphone_core_create_carddav_context(LinphoneCore *lc);
LINPHONE_PUBLIC LinphoneCardDavContext* linphone_carddav_context_new(LinphoneFriendList *lfl);
/**
* Deletes a LinphoneCardDavContext object
* @param cdc LinphoneCardDavContext object
*/
LINPHONE_PUBLIC void linphone_carddav_destroy(LinphoneCardDavContext *cdc);
LINPHONE_PUBLIC void linphone_carddav_context_destroy(LinphoneCardDavContext *cdc);
/**
* Sets a user pointer to the LinphoneCardDAVContext object
......
......@@ -26,11 +26,12 @@
#ifndef CONFERENCE_H
#define CONFERENCE_H
#include "linphonecore.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "linphonecore.h"
//typedef struct _LinphoneConference LinphoneConference;
......
......@@ -155,8 +155,8 @@ void* linphone_friend_get_user_data(const LinphoneFriend *lf){
return lf->user_data;
}
bool_t linphone_friend_in_list(const LinphoneFriend *lf){
return lf->in_list;
bool_t linphone_friend_in_list(const LinphoneFriend *lf) {
return lf->friend_list != NULL;
}
void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result){
......@@ -529,13 +529,27 @@ void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc) {
}
void linphone_friend_edit(LinphoneFriend *fr) {
if (fr && fr->vcard) {
linphone_vcard_compute_md5_hash(fr->vcard);
}
}
void linphone_friend_done(LinphoneFriend *fr) {
const char *previous_md5 = NULL;
ms_return_if_fail(fr);
if (!fr->lc || !fr->in_list) return;
if (!fr->lc || !fr->friend_list) return;
linphone_friend_apply(fr, fr->lc);
linphone_friend_save(fr, fr->lc);
if (fr && fr->vcard) {
previous_md5 = linphone_vcard_get_md5_hash(fr->vcard);
linphone_vcard_compute_md5_hash(fr->vcard);
if (previous_md5 && strcmp(previous_md5, linphone_vcard_get_md5_hash(fr->vcard)) != 0) {
ms_debug("vCard's md5 has changed, mark friend as dirty");
fr->friend_list->dirty_friends_to_update = ms_list_append(fr->friend_list->dirty_friends_to_update, fr);
}
}
}
LinphoneFriend * linphone_core_create_friend(LinphoneCore *lc) {
......
......@@ -22,6 +22,55 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <polarssl/md5.h>
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriendListCbs);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriendListCbs, belle_sip_object_t,
NULL, // destroy
NULL, // clone
NULL, // Marshall
FALSE
);
static LinphoneFriendListCbs * linphone_friend_list_cbs_new(void) {
return belle_sip_object_new(LinphoneFriendListCbs);
}
LinphoneFriendListCbs * linphone_friend_list_get_callbacks(const LinphoneFriendList *list) {
return list->cbs;
}
LinphoneFriendListCbs * linphone_friend_list_cbs_ref(LinphoneFriendListCbs *cbs) {
belle_sip_object_ref(cbs);
return cbs;
}
void linphone_friend_list_cbs_unref(LinphoneFriendListCbs *cbs) {
belle_sip_object_unref(cbs);
}
void *linphone_friend_list_cbs_get_user_data(const LinphoneFriendListCbs *cbs) {
return cbs->user_data;
}
void linphone_friend_list_cbs_set_user_data(LinphoneFriendListCbs *cbs, void *ud) {
cbs->user_data = ud;
}
LinphoneFriendListContactCreatedCb linphone_friend_list_cbs_get_contact_created(const LinphoneFriendListCbs *cbs) {
return cbs->contact_created_cb;
}
void linphone_friend_list_cbs_set_contact_created(LinphoneFriendListCbs *cbs, LinphoneFriendListContactCreatedCb cb) {
cbs->contact_created_cb = cb;
}
LinphoneFriendListContactDeletedCb linphone_friend_list_cbs_get_contact_deleted(const LinphoneFriendListCbs *cbs) {
return cbs->contact_deleted_cb;
}
void linphone_friend_list_cbs_set_contact_deleted(LinphoneFriendListCbs *cbs, LinphoneFriendListContactDeletedCb cb) {
cbs->contact_deleted_cb = cb;
}
static char * create_resource_list_xml(const LinphoneFriendList *list) {
char *xml_content = NULL;
......@@ -219,6 +268,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();
belle_sip_object_ref(list);
return list;
}
......@@ -228,7 +278,10 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) {
if (list->rls_uri != NULL) ms_free(list->rls_uri);
if (list->content_digest != NULL) ms_free(list->content_digest);
if (list->event != NULL) linphone_event_unref(list->event);
if (list->uri != NULL) ms_free(list->uri);
if (list->cbs) linphone_friend_list_cbs_unref(list->cbs);
list->friends = ms_list_free_with_data(list->friends, (void (*)(void *))linphone_friend_unref);
list->dirty_friends_to_update = ms_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))_linphone_friend_release);
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriendList);
......@@ -259,7 +312,12 @@ void _linphone_friend_list_release(LinphoneFriendList *list){
linphone_event_unref(list->event);
list->event = NULL;
}
if (list->cbs) {
linphone_friend_list_cbs_unref(list->cbs);
list->cbs = NULL;
}
list->friends = ms_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release);
list->dirty_friends_to_update = ms_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))_linphone_friend_release);
belle_sip_object_unref(list);
}
......@@ -304,10 +362,10 @@ void linphone_friend_list_set_rls_uri(LinphoneFriendList *list, const char *rls_
}
LinphoneFriendListStatus linphone_friend_list_add_friend(LinphoneFriendList *list, LinphoneFriend *lf) {
if (lf->uri == NULL || lf->in_list) {
if (lf->uri == NULL || lf->friend_list) {
if (!lf->uri)
ms_error("linphone_friend_list_add_friend(): invalid friend, no sip uri");
if (lf->in_list)
if (lf->friend_list)
ms_error("linphone_friend_list_add_friend(): invalid friend, already in list");
return LinphoneFriendListInvalidFriend;
}
......@@ -326,24 +384,81 @@ LinphoneFriendListStatus linphone_friend_list_add_friend(LinphoneFriendList *lis
LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf) {
if ((lf->lc != NULL) || (lf->uri == NULL)) return LinphoneFriendListInvalidFriend;
list->friends = ms_list_append(list->friends, linphone_friend_ref(lf));
lf->in_list = TRUE;
list->dirty_friends_to_update = ms_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf));
lf->friend_list = list;
return LinphoneFriendListOK;
}
static void carddav_done(LinphoneCardDavContext *cdc, bool_t success, const char *msg) {
linphone_carddav_context_destroy(cdc);
}
LinphoneFriendListStatus linphone_friend_list_remove_friend(LinphoneFriendList *list, LinphoneFriend *lf) {
MSList *elem = ms_list_find(list->friends, lf);
LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
if (elem == NULL) return LinphoneFriendListNonExistentFriend;
#ifdef FRIENDS_SQL_STORAGE_ENABLED
linphone_core_remove_friend_from_db(lf->lc, lf);
#endif
if (cdc) {
cdc->sync_done_cb = carddav_done;
linphone_carddav_delete_vcard(cdc, lf);
}
lf->in_list = FALSE;
lf->friend_list = NULL;
linphone_friend_unref(lf);
list->friends = ms_list_remove_link(list->friends, elem);
return LinphoneFriendListOK;
}
void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
MSList *dirty_friends = list->dirty_friends_to_update;
if (cdc) {
cdc->sync_done_cb = carddav_done;
while (dirty_friends) {
LinphoneFriend *lf = (LinphoneFriend *)dirty_friends->data;
if (lf) {
linphone_carddav_put_vcard(cdc, lf);
}
dirty_friends = ms_list_next(dirty_friends);
}
}
list->dirty_friends_to_update = ms_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref);
}
static void carddav_created(LinphoneCardDavContext *cdc, LinphoneFriend *lf) {
if (cdc && cdc->friend_list->cbs->contact_created_cb) {
LinphoneFriendList *lfl = cdc->friend_list;
lfl->friends = ms_list_append(lfl->friends, linphone_friend_ref(lf));
cdc->friend_list->cbs->contact_created_cb(lfl, linphone_friend_ref(lf));
}
linphone_friend_unref(lf);
}
static void carddav_removed(LinphoneCardDavContext *cdc, LinphoneFriend *lf) {
if (cdc && cdc->friend_list->cbs->contact_deleted_cb) {
LinphoneFriendList *lfl = cdc->friend_list;
MSList *elem = ms_list_find(lfl->friends, lf);
lfl->friends = ms_list_remove_link(lfl->friends, elem);
cdc->friend_list->cbs->contact_deleted_cb(lfl, linphone_friend_ref(lf));
}
linphone_friend_unref(lf);
}
void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list) {
LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
if (cdc) {
cdc->contact_created_cb = carddav_created;
cdc->contact_removed_cb = carddav_removed;
cdc->sync_done_cb = carddav_done;
linphone_carddav_synchronize(cdc);
}
}
LinphoneFriend * linphone_friend_list_find_friend_by_address(const LinphoneFriendList *list, const LinphoneAddress *address) {
LinphoneFriend *lf = NULL;
const MSList *elem;
......@@ -487,3 +602,21 @@ void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, Lin
linphone_content_unref(first_part);
}
}
const char * linphone_friend_list_get_uri(const LinphoneFriendList *list) {
return list->uri;
}
void linphone_friend_list_set_uri(LinphoneFriendList *list, const char *uri) {
if (list->uri != NULL) {
ms_free(list->uri);
list->uri = NULL;
}
if (uri != NULL) {
list->uri = ms_strdup(uri);
}
}
void linphone_friend_list_update_revision(LinphoneFriendList *list, int rev) {
list->revision = rev;
}
\ No newline at end of file
......@@ -174,6 +174,116 @@ LINPHONE_PUBLIC void linphone_friend_list_update_subscriptions(LinphoneFriendLis
**/
LINPHONE_PUBLIC void linphone_friend_list_notify_presence(LinphoneFriendList *list, LinphonePresenceModel *presence);
/**
* Get the URI associated with the friend list.
* @param[in] list LinphoneFriendList object.
* @return The URI associated with the friend list.
**/
LINPHONE_PUBLIC const char * linphone_friend_list_get_uri(const LinphoneFriendList *list);
/**
* Set the URI associated with the friend list.
* @param[in] list LinphoneFriendList object.
* @param[in] rls_uri The URI to associate with the friend list.
**/
LINPHONE_PUBLIC void linphone_friend_list_set_uri(LinphoneFriendList *list, const char *uri);
/**
* Sets the revision from the last synchronization.
* @param[in] list LinphoneFriendList object.
* @param[in] rev The revision
*/
void linphone_friend_list_update_revision(LinphoneFriendList *list, int rev);
/**
* An object to handle the callbacks for LinphoneFriend synchronization.
**/
typedef struct _LinphoneFriendListCbs LinphoneFriendListCbs;
/**
* Callback used to notify a new contact has been created on the CardDAV server and downloaded locally
**/
typedef void (*LinphoneFriendListContactCreatedCb)(LinphoneFriendList *list, LinphoneFriend *lf);
/**
* Callback used to notify a contact has been deleted on the CardDAV server
**/
typedef void (*LinphoneFriendListContactDeletedCb)(LinphoneFriendList *list, LinphoneFriend *lf);
/**
* Get the LinphoneFriendListCbs object associated with a LinphoneFriendList.
* @param[in] request LinphoneXmlRpcRequest object
* @return The LinphoneFriendListCbs object associated with the LinphoneFriendList.
**/
LINPHONE_PUBLIC LinphoneFriendListCbs * linphone_friend_list_get_callbacks(const LinphoneFriendList *list);
/**
* Acquire a reference to a LinphoneFriendListCbs object.
* @param[in] cbs LinphoneFriendListCbs object.
* @return The same LinphoneFriendListCbs object.
**/
LINPHONE_PUBLIC LinphoneFriendListCbs * linphone_friend_list_cbs_ref(LinphoneFriendListCbs *cbs);
/**
* Release a reference to a LinphoneFriendListCbs object.
* @param[in] cbs LinphoneFriendListCbs object.
**/
LINPHONE_PUBLIC void linphone_friend_list_cbs_unref(LinphoneFriendListCbs *cbs);
/**
* Retrieve the user pointer associated with a LinphoneFriendListCbs object.
* @param[in] cbs LinphoneFriendListCbs object.
* @return The user pointer associated with the LinphoneFriendListCbs object.
**/
LINPHONE_PUBLIC void *linphone_friend_list_cbs_get_user_data(const LinphoneFriendListCbs *cbs);
/**
* Assign a user pointer to a LinphoneFriendListCbs object.
* @param[in] cbs LinphoneFriendListCbs object.
* @param[in] ud The user pointer to associate with the LinphoneFriendListCbs object.
**/
LINPHONE_PUBLIC void linphone_friend_list_cbs_set_user_data(LinphoneFriendListCbs *cbs, void *ud);
/**
* Get the contact created callback.
* @param[in] cbs LinphoneFriendListCbs object.
* @return The current contact created callback.
**/
LINPHONE_PUBLIC LinphoneFriendListContactCreatedCb linphone_friend_list_cbs_get_contact_created(const LinphoneFriendListCbs *cbs);
/**
* Set the contact created callback.
* @param[in] cbs LinphoneFriendListCbs object.
* @param[in] cb The contact created to be used.
**/
LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_created(LinphoneFriendListCbs *cbs, LinphoneFriendListContactCreatedCb cb);
/**
* Get the contact deleted callback.
* @param[in] cbs LinphoneFriendListCbs object.
* @return The current contact deleted callback.
**/
LINPHONE_PUBLIC LinphoneFriendListContactDeletedCb linphone_friend_list_cbs_get_contact_deleted(const LinphoneFriendListCbs *cbs);
/**
* Set the contact deleted callback.
* @param[in] cbs LinphoneFriendListCbs object.
* @param[in] cb The contact deleted to be used.
**/
LINPHONE_PUBLIC void linphone_friend_list_cbs_set_contact_deleted(LinphoneFriendListCbs *cbs, LinphoneFriendListContactDeletedCb cb);
/**
*
* @param[in] list LinphoneFriendList object.
*/
LINPHONE_PUBLIC void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *list);
/**
*
* @param[in] list LinphoneFriendList object.
*/
void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list);
/**
* @}
*/
......
......@@ -2736,6 +2736,9 @@ void linphone_core_iterate(LinphoneCore *lc){
if (lp_config_needs_commit(lc->config)) {
lp_config_sync(lc->config);
}
if (lc->friendlist->dirty_friends_to_update) {
linphone_friend_list_update_dirty_friends(lc->friendlist);
}
}
if (liblinphone_serialize_logs == TRUE) {
......@@ -7431,85 +7434,6 @@ const char *linphone_stream_type_to_string(const LinphoneStreamType type) {
return "INVALID";
}
/*****************************************************************************
* CardDAV interface *
****************************************************************************/
void linphone_core_set_carddav_server_url(LinphoneCore *lc, const char *carddav_server_url) {
if (lc && carddav_server_url) {
LpConfig *lpc = linphone_core_get_config(lc);
lp_config_set_string(lpc, "carddav", "server_url", carddav_server_url);
}
}
const char *linphone_core_get_carddav_server_url(LinphoneCore *lc) {
if (lc) {
LpConfig *lpc = linphone_core_get_config(lc);
return lp_config_get_string(lpc, "carddav", "server_url", NULL);
}
return NULL;
}
void linphone_core_set_carddav_username(LinphoneCore *lc, const char *username) {
if (lc && username) {
LpConfig *lpc = linphone_core_get_config(lc);
lp_config_set_string(lpc, "carddav", "username", username);
}
}
const char *linphone_core_get_carddav_username(LinphoneCore *lc) {
if (lc) {
LpConfig *lpc = linphone_core_get_config(lc);
return lp_config_get_string(lpc, "carddav", "username", NULL);
}
return NULL;
}
void linphone_core_set_carddav_password(LinphoneCore *lc, const char *password) {
if (lc && password) {
LpConfig *lpc = linphone_core_get_config(lc);
lp_config_set_string(lpc, "carddav", "password", password);
}
}
const char *linphone_core_get_carddav_password(LinphoneCore *lc) {
if (lc) {
LpConfig *lpc = linphone_core_get_config(lc);
return lp_config_get_string(lpc, "carddav", "password", NULL);
}
return NULL;
}
void linphone_core_set_carddav_ha1(LinphoneCore *lc, const char *ha1) {
if (lc && ha1) {
LpConfig *lpc = linphone_core_get_config(lc);
lp_config_set_string(lpc, "carddav", "ha1", ha1);
}
}
const char *linphone_core_get_carddav_ha1(LinphoneCore *lc) {
if (lc) {
LpConfig *lpc = linphone_core_get_config(lc);
return lp_config_get_string(lpc, "carddav", "ha1", NULL);
}
return NULL;
}
void linphone_core_set_carddav_current_ctag(LinphoneCore *lc, int ctag) {
if (lc) {
LpConfig *lpc = linphone_core_get_config(lc);
lp_config_set_int(lpc, "carddav", "ctag", ctag);
}
}