mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Added methods to friend to manipulate phone numbers and sip addresses
This commit is contained in:
parent
a8cd6e8a1f
commit
4112738454
5 changed files with 216 additions and 5 deletions
106
coreapi/friend.c
106
coreapi/friend.c
|
|
@ -195,6 +195,10 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
|
|||
}
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf){
|
||||
return lf->uri;
|
||||
}
|
||||
|
||||
int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr){
|
||||
LinphoneAddress *fr = linphone_address_clone(addr);
|
||||
LinphoneVcard *vcard = NULL;
|
||||
|
|
@ -211,6 +215,103 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
if (!lf || !addr) {
|
||||
return;
|
||||
}
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
return;
|
||||
}
|
||||
|
||||
linphone_vcard_add_sip_address(vcard, linphone_address_as_string_uri_only(addr));
|
||||
}
|
||||
|
||||
const MSList* linphone_friend_get_addresses(LinphoneFriend *lf) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
MSList *sipAddresses = NULL;
|
||||
MSList *addresses = NULL;
|
||||
|
||||
if (!lf) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipAddresses = linphone_vcard_get_sip_addresses(vcard);
|
||||
if (sipAddresses) {
|
||||
const char *sipAddress = (const char *)sipAddresses->data;
|
||||
LinphoneAddress *addr = linphone_address_new(sipAddress);
|
||||
if (addr) {
|
||||
ms_list_append(addresses, addr);
|
||||
}
|
||||
ms_list_free(sipAddresses);
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
void linphone_friend_remove_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
if (!lf || !addr) {
|
||||
return;
|
||||
}
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
return;
|
||||
}
|
||||
|
||||
linphone_vcard_remove_sip_address(vcard, linphone_address_as_string_uri_only(addr));
|
||||
}
|
||||
|
||||
void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
if (!lf || !phone) {
|
||||
return;
|
||||
}
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
return;
|
||||
}
|
||||
|
||||
linphone_vcard_add_phone_number(vcard, phone);
|
||||
}
|
||||
|
||||
const MSList* linphone_friend_get_phone_numbers(LinphoneFriend *lf) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
|
||||
if (!lf) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return linphone_vcard_get_phone_numbers(vcard);
|
||||
}
|
||||
|
||||
void linphone_friend_remove_phone_number(LinphoneFriend *lf, const char *phone) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
if (!lf || !phone) {
|
||||
return;
|
||||
}
|
||||
|
||||
vcard = linphone_friend_get_vcard(lf);
|
||||
if (!vcard) {
|
||||
return;
|
||||
}
|
||||
|
||||
linphone_vcard_remove_phone_number(vcard, phone);
|
||||
}
|
||||
|
||||
int linphone_friend_set_name(LinphoneFriend *lf, const char *name){
|
||||
LinphoneAddress *fr = lf->uri;
|
||||
LinphoneVcard *vcard = NULL;
|
||||
|
|
@ -334,10 +435,6 @@ static belle_sip_error_code _linphone_friend_marshall(belle_sip_object_t *obj, c
|
|||
return err;
|
||||
}
|
||||
|
||||
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf){
|
||||
return lf->uri;
|
||||
}
|
||||
|
||||
const char * linphone_friend_get_name(const LinphoneFriend *lf) {
|
||||
if (lf && lf->vcard) {
|
||||
return linphone_vcard_get_full_name(lf->vcard);
|
||||
|
|
@ -915,6 +1012,7 @@ LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard) {
|
|||
linphone_friend_set_address(fr, linphone_address);
|
||||
linphone_address_unref(linphone_address);
|
||||
}
|
||||
ms_free(sipAddresses);
|
||||
}
|
||||
if (name) {
|
||||
linphone_friend_set_name(fr, name);
|
||||
|
|
|
|||
|
|
@ -162,7 +162,49 @@ LINPHONE_PUBLIC int linphone_friend_set_address(LinphoneFriend *fr, const Linpho
|
|||
* @param lf #LinphoneFriend object
|
||||
* @return #LinphoneAddress
|
||||
*/
|
||||
LINPHONE_PUBLIC const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
|
||||
LINPHONE_PUBLIC const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
|
||||
|
||||
/**
|
||||
* Adds an address in this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @param addr #LinphoneAddress object
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr);
|
||||
|
||||
/**
|
||||
* Returns a list of #LinphoneAddress for this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @return \mslist{LinphoneAddress}
|
||||
*/
|
||||
LINPHONE_PUBLIC const MSList* linphone_friend_get_addresses(LinphoneFriend *lf);
|
||||
|
||||
/**
|
||||
* Removes an address in this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @param addr #LinphoneAddress object
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_remove_address(LinphoneFriend *lf, const LinphoneAddress *addr);
|
||||
|
||||
/**
|
||||
* Adds a phone number in this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @param phone number to add
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone);
|
||||
|
||||
/**
|
||||
* Returns a list of phone numbers for this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @return a MSList of phone numbers
|
||||
*/
|
||||
LINPHONE_PUBLIC const MSList* linphone_friend_get_phone_numbers(LinphoneFriend *lf);
|
||||
|
||||
/**
|
||||
* Removes a phone number in this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @param phone number to remove
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_friend_remove_phone_number(LinphoneFriend *lf, const char *phone);
|
||||
|
||||
/**
|
||||
* Set the display name for this friend
|
||||
|
|
|
|||
|
|
@ -163,6 +163,37 @@ MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) {
|
||||
if (!vCard || !phone) return;
|
||||
|
||||
shared_ptr<belcard::BelCardPhoneNumber> phone_number = belcard::BelCardGeneric::create<belcard::BelCardPhoneNumber>();
|
||||
phone_number->setValue(phone);
|
||||
vCard->belCard->addPhoneNumber(phone_number);
|
||||
}
|
||||
|
||||
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) {
|
||||
if (!vCard) return;
|
||||
|
||||
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
|
||||
const char *value = (*it)->getValue().c_str();
|
||||
if (strcmp(value, phone) == 0) {
|
||||
vCard->belCard->removePhoneNumber(*it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
|
||||
MSList *result = NULL;
|
||||
if (!vCard) return NULL;
|
||||
|
||||
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
|
||||
const char *value = (*it)->getValue().c_str();
|
||||
result = ms_list_append(result, (char *)value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
|
||||
if (!vCard) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,34 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_
|
|||
*/
|
||||
LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard);
|
||||
|
||||
/**
|
||||
* Adds a phone number in the vCard, using the TEL property
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
* @param[in] sip_address the phone number to add
|
||||
*/
|
||||
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone);
|
||||
|
||||
/**
|
||||
* Removes a phone number in the vCard (if it exists), using the TEL property
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
* @param[in] sip_address the phone number to remove
|
||||
*/
|
||||
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone);
|
||||
|
||||
/**
|
||||
* Returns the list of phone numbers (as string) in the vCard (all the TEL attributes) or NULL
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
* @return \mslist{const char *}
|
||||
*/
|
||||
LINPHONE_PUBLIC MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard);
|
||||
|
||||
/**
|
||||
* Returns the list of SIP addresses (as string) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
* @return \mslist{const char *}
|
||||
*/
|
||||
LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard);
|
||||
|
||||
/**
|
||||
* Fills the Organization field of the vCard
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
|
|
|
|||
|
|
@ -71,6 +71,18 @@ MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) {
|
||||
|
||||
}
|
||||
|
||||
void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) {
|
||||
|
||||
}
|
||||
|
||||
MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue