Commit 126f1633 authored by Erwan Croze's avatar Erwan Croze 👋🏻

Continue conversion

parent 21ac2121
......@@ -136,14 +136,12 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_li
if (local_friend) {
LinphoneFriend *lf2 = (LinphoneFriend *)local_friend->data;
//New setter and getter in private_function.h
lf->storage_id = lf2->storage_id;
lf->pol = lf2->pol;
lf->subscribe = lf2->subscribe;
lf->refkey = ms_strdup(lf2->refkey);
lf->presence_received = lf2->presence_received;
lf->lc = lf2->lc;
lf->friend_list = lf2->friend_list;
linphone_friend_set_storage_id(lf, linphone_friend_get_storage_id(lf2));
linphone_friend_set_inc_subscribe_policy(lf, linphone_friend_get_inc_subscribe_policy(lf2));
linphone_friend_enable_subscribes(lf, linphone_friend_subscribes_enabled(lf2));
linphone_friend_set_ref_key(lf, linphone_friend_get_ref_key(lf2));
linphone_friend_set_presence_received(lf, linphone_friend_is_presence_received(lf2));
linphone_friend_set_friend_list(lf, linphone_friend_get_friend_list(lf2));
if (cdc->contact_updated_cb) {
ms_debug("Contact updated: %s", linphone_friend_get_name(lf));
cdc->contact_updated_cb(cdc, lf, lf2);
......@@ -212,10 +210,11 @@ end:
}
static int find_matching_vcard(LinphoneCardDavResponse *response, LinphoneFriend *lf) {
if (!response->url || !lf || !lf->vcard || !linphone_vcard_get_url(lf->vcard)) {
LinphoneVcard *vcard = linphone_friend_get_vcard(lf);
if (!response->url || !vcard || !linphone_vcard_get_url(vcard)) {
return 1;
}
return strcmp(response->url, linphone_vcard_get_url(lf->vcard));
return strcmp(response->url, linphone_vcard_get_url(vcard));
}
static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, bctbx_list_t *vCards) {
......
......@@ -366,10 +366,6 @@ static belle_sip_error_code _linphone_friend_marshall(belle_sip_object_t *obj, c
return err;
}
bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf){
return lf->subscribe;
}
/*
* updates the p2p subscriptions.
* If only_when_registered is TRUE, subscribe will be sent only if the friend's corresponding proxy config is in registered.
......
......@@ -393,14 +393,12 @@ void linphone_core_create_im_notif_policy(LinphoneCore *lc);
/*****************************************************************************
* FRIEND PRIVATE SETTER GETTER *
****************************************************************************/
/*
lf->pol = lf2->pol;
char *refkey;
bool_t subscribe;
bool_t presence_received;
unsigned int storage_id;
LinphoneFriendList *friend_list;
*/
void linphone_friend_set_presence_received(LinphoneFriend *lf, bool_t p_r);
void linphone_friend_set_storage_id(LinphoneFriend *lf, unsigned int id);
unsigned int linphone_friend_get_storage_id(const LinphoneFriend *lf);
LinphoneFriendList *linphone_friend_get_friend_list(const LinphoneFriend *lf);
void linphone_friend_set_friend_list(LinphoneFriend *lf, LinphoneFriendList * list);
/*****************************************************************************
* REMOTE PROVISIONING FUNCTIONS *
......
......@@ -238,7 +238,7 @@ void linphone_friend_remove_phone_number(LinphoneFriend *lf, const char *phone)
}
}
LinphoneStatus linphone_friend_set_name(LinphoneFriend *lf, const char *name){
LinphoneStatus linphone_friend_set_name(LinphoneFriend *lf, const char *name) {
if (linphone_core_vcard_supported()) {
if (!lf->vcard) linphone_friend_create_vcard(lf, name);
linphone_vcard_set_full_name(lf->vcard, name);
......@@ -263,7 +263,11 @@ const char * linphone_friend_get_name(const LinphoneFriend *lf) {
return NULL;
}
LinphoneStatus linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val){
bool_t linphone_friend_subscribes_enabled(const LinphoneFriend *lf) {
return lf->subscribe;
}
LinphoneStatus linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val) {
fr->subscribe=val;
return 0;
}
......@@ -273,7 +277,7 @@ LinphoneStatus linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, Linp
return 0;
}
LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf){
LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf) {
return lf->pol;
}
......@@ -285,7 +289,8 @@ void linphone_friend_edit(LinphoneFriend *fr) {
void linphone_friend_done(LinphoneFriend *fr) {
ms_return_if_fail(fr);
if (!fr->lc) return;
LinphoneCore *lc = L_GET_CPP_PTR_FROM_C_OBJECT(fr)->getCore()->getCCore();
if (!lc) return;
if (fr && linphone_core_vcard_supported() && fr->vcard) {
if (linphone_vcard_compare_md5_hash(fr->vcard) != 0) {
......@@ -296,11 +301,11 @@ void linphone_friend_done(LinphoneFriend *fr) {
}
}
}
linphone_friend_apply(fr, fr->lc);
linphone_friend_save(fr, fr->lc);
linphone_friend_apply(fr, lc);
linphone_friend_save(fr, lc);
}
LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){
LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf) {
const LinphonePresenceModel *presence = linphone_friend_get_presence_model(lf);
LinphoneOnlineStatus online_status = LinphoneStatusOffline;
LinphonePresenceBasicStatus basic_status = LinphonePresenceBasicStatusClosed;
......@@ -450,19 +455,19 @@ bool_t linphone_friend_is_presence_received(const LinphoneFriend *lf) {
return lf->presence_received;
}
void linphone_friend_set_user_data(LinphoneFriend *lf, void *data){
void linphone_friend_set_user_data(LinphoneFriend *lf, void *data) {
lf->user_data=data;
}
void* linphone_friend_get_user_data(const LinphoneFriend *lf){
void* linphone_friend_get_user_data(const LinphoneFriend *lf) {
return lf->user_data;
}
BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf){
BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf) {
return lf->info;
}
void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key){
void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key) {
if (lf->refkey != NULL) {
ms_free(lf->refkey);
lf->refkey = NULL;
......@@ -470,8 +475,8 @@ void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key){
if (key) {
lf->refkey = ms_strdup(key);
}
if (lf->lc) {
linphone_friend_save(lf, lf->lc);
if (L_GET_CPP_PTR_FROM_C_OBJECT(lf)->getCore()->getCCore()) {
linphone_friend_save(lf, L_GET_CPP_PTR_FROM_C_OBJECT(lf)->getCore()->getCCore());
}
}
......@@ -492,8 +497,8 @@ void linphone_friend_unref(LinphoneFriend *lf) {
belle_sip_object_unref(lf);
}
LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr){
return fr->lc;
LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr) {
return L_GET_CPP_PTR_FROM_C_OBJECT(fr)->getCore()->getCCore();
}
LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr) {
......@@ -508,7 +513,7 @@ void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVcard *vcard) {
if (fr->vcard) linphone_vcard_unref(fr->vcard);
fr->vcard = vcard;
linphone_friend_save(fr, fr->lc);
linphone_friend_save(fr, L_GET_CPP_PTR_FROM_C_OBJECT(fr)->getCore()->getCCore());
}
bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) {
......@@ -531,7 +536,7 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) {
vcard = linphone_factory_create_vcard(linphone_factory_get());
lc = fr->lc;
lc = L_GET_CPP_PTR_FROM_C_OBJECT(fr)->getCore()->getCCore();
if (!lc && fr->friend_list) {
lc = fr->friend_list->lc;
}
......@@ -578,3 +583,27 @@ void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc) {
#endif
}
//--------- Private functions
void linphone_friend_set_presence_received(LinphoneFriend *lf, bool_t p_r) {
if (!lf) return;
lf->presence_received = p_r;
}
void linphone_friend_set_storage_id(LinphoneFriend *lf, unsigned int id) {
if (!lf) return;
lf->storage_id = id;
}
unsigned int linphone_friend_get_storage_id(const LinphoneFriend *lf) {
return (!lf) ? -1 : lf->storage_id;
}
LinphoneFriendList *linphone_friend_get_friend_list(const LinphoneFriend *lf) {
return (!lf) ? nullptr : lf->friend_list;
}
void linphone_friend_set_friend_list(LinphoneFriend *lf, LinphoneFriendList * list) {
if (!lf) return;
lf->friend_list = list;
}
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