mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 09:49:26 +00:00
heavy rework of lists, presence list subscriptions, and fix many memory leaks
This commit is contained in:
parent
c0fa38c6c3
commit
f9aee35116
24 changed files with 237 additions and 225 deletions
|
|
@ -1829,7 +1829,7 @@ linphonec_proxy_use(LinphoneCore *lc, int index)
|
|||
static void
|
||||
linphonec_friend_display(LinphoneFriend *fr)
|
||||
{
|
||||
LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
char *str = NULL;
|
||||
|
||||
linphonec_out("name: %s\n", linphone_friend_get_name(fr));
|
||||
|
|
@ -1875,12 +1875,11 @@ linphonec_friend_call(LinphoneCore *lc, unsigned int num)
|
|||
if ( n == num )
|
||||
{
|
||||
int ret;
|
||||
LinphoneAddress *addr = linphone_friend_get_address((LinphoneFriend*)friend->data);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address((LinphoneFriend*)friend->data);
|
||||
if (addr) {
|
||||
addr_str = linphone_address_as_string(addr);
|
||||
ret=lpc_cmd_call(lc, addr_str);
|
||||
ms_free(addr_str);
|
||||
linphone_address_unref(addr);
|
||||
return ret;
|
||||
} else {
|
||||
linphonec_out("Friend %u does not have an address\n", num);
|
||||
|
|
|
|||
|
|
@ -291,12 +291,11 @@ linphonec_transfer_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneC
|
|||
static void
|
||||
linphonec_notify_presence_received(LinphoneCore *lc,LinphoneFriend *fid)
|
||||
{
|
||||
LinphoneAddress *addr = linphone_friend_get_address(fid);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(fid);
|
||||
if (addr) {
|
||||
char *tmp=linphone_address_as_string(addr);
|
||||
printf("Friend %s is %s\n", tmp, linphone_online_status_to_string(linphone_friend_get_status(fid)));
|
||||
ms_free(tmp);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
// todo: update Friend list state (unimplemented)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1137,7 +1137,7 @@ void sal_remove_supported_tag(Sal *ctx, const char* tag){
|
|||
bctbx_list_t *elem=bctbx_list_find_custom(ctx->supported_tags,(bctbx_compare_func)strcasecmp,tag);
|
||||
if (elem){
|
||||
ms_free(elem->data);
|
||||
ctx->supported_tags=bctbx_list_remove_link(ctx->supported_tags,elem);
|
||||
ctx->supported_tags=bctbx_list_erase_link(ctx->supported_tags,elem);
|
||||
make_supported_header(ctx);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t
|
|||
bool_t is_update=FALSE;
|
||||
bool_t drop_op = FALSE;
|
||||
|
||||
if (strcmp("ACK",method)!=0){ /*ACK does'nt create srv transaction*/
|
||||
if (strcmp("ACK",method)!=0){ /*ACK doesn't create a server transaction*/
|
||||
server_transaction = belle_sip_provider_create_server_transaction(op->base.root->prov,belle_sip_request_event_get_request(event));
|
||||
belle_sip_object_ref(server_transaction);
|
||||
belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(server_transaction),sal_op_ref(op));
|
||||
|
|
|
|||
|
|
@ -1106,7 +1106,7 @@ static bool_t is_duplicate_msg(LinphoneCore *lc, const char *msg_id){
|
|||
}
|
||||
if (i>=10){
|
||||
ms_free(tail->data);
|
||||
lc->last_recv_msg_ids=bctbx_list_remove_link(lc->last_recv_msg_ids,tail);
|
||||
lc->last_recv_msg_ids=bctbx_list_erase_link(lc->last_recv_msg_ids,tail);
|
||||
}
|
||||
return is_duplicate;
|
||||
}
|
||||
|
|
|
|||
115
coreapi/friend.c
115
coreapi/friend.c
|
|
@ -125,7 +125,7 @@ static LinphoneFriendPresence * find_presence_model_for_uri_or_tel(const Linphon
|
|||
}
|
||||
|
||||
static void add_presence_model_for_uri_or_tel(LinphoneFriend *lf, const char *uri_or_tel, LinphonePresenceModel *presence) {
|
||||
LinphoneFriendPresence *lfp = ms_new(LinphoneFriendPresence, 1);
|
||||
LinphoneFriendPresence *lfp = ms_new0(LinphoneFriendPresence, 1);
|
||||
lfp->uri_or_tel = ms_strdup(uri_or_tel);
|
||||
lfp->presence = presence;
|
||||
lf->presence_models = bctbx_list_append(lf->presence_models, lfp);
|
||||
|
|
@ -134,11 +134,13 @@ static void add_presence_model_for_uri_or_tel(LinphoneFriend *lf, const char *ur
|
|||
static void free_friend_presence(LinphoneFriendPresence *lfp) {
|
||||
ms_free(lfp->uri_or_tel);
|
||||
if (lfp->presence) linphone_presence_model_unref(lfp->presence);
|
||||
ms_free(lfp);
|
||||
}
|
||||
|
||||
static void free_phone_number_sip_uri(LinphoneFriendPhoneNumberSipUri *lfpnsu) {
|
||||
ms_free(lfpnsu->number);
|
||||
ms_free(lfpnsu->uri);
|
||||
ms_free(lfpnsu);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -156,7 +158,7 @@ bctbx_list_t *linphone_find_friend_by_address(bctbx_list_t *fl, const LinphoneAd
|
|||
|
||||
void __linphone_friend_do_subscribe(LinphoneFriend *fr){
|
||||
LinphoneCore *lc=fr->lc;
|
||||
LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
|
||||
if (addr != NULL) {
|
||||
if (fr->outsub==NULL){
|
||||
|
|
@ -174,7 +176,6 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
|
|||
linphone_configure_op(lc,fr->outsub,addr,NULL,TRUE);
|
||||
sal_subscribe_presence(fr->outsub,NULL,NULL,lp_config_get_int(lc->config,"sip","subscribe_expires",600));
|
||||
fr->subscribe_active=TRUE;
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +261,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
|
|||
}
|
||||
}
|
||||
|
||||
LinphoneAddress * linphone_friend_get_address(const LinphoneFriend *lf) {
|
||||
const LinphoneAddress * linphone_friend_get_address(const LinphoneFriend *lf) {
|
||||
if (linphone_core_vcard_supported()) {
|
||||
if (lf->vcard) {
|
||||
bctbx_list_t *sip_addresses = linphone_vcard_get_sip_addresses(lf->vcard);
|
||||
|
|
@ -269,12 +270,16 @@ LinphoneAddress * linphone_friend_get_address(const LinphoneFriend *lf) {
|
|||
LinphoneAddress *addr = NULL;
|
||||
if (uri) addr = linphone_address_new(uri);
|
||||
bctbx_list_free(sip_addresses);
|
||||
if (lf->uri){
|
||||
linphone_address_unref(lf->uri);
|
||||
}
|
||||
((LinphoneFriend*)lf)->uri = addr;
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (lf->uri) return linphone_address_clone(lf->uri);
|
||||
if (lf->uri) return lf->uri;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -321,7 +326,7 @@ void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr
|
|||
}
|
||||
}
|
||||
|
||||
bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf) {
|
||||
bctbx_list_t* linphone_friend_get_addresses(const LinphoneFriend *lf) {
|
||||
bctbx_list_t *sip_addresses = NULL;
|
||||
bctbx_list_t *addresses = NULL;
|
||||
bctbx_list_t *iterator = NULL;
|
||||
|
|
@ -411,12 +416,11 @@ int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscri
|
|||
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence){
|
||||
bctbx_list_t *elem;
|
||||
if (lf->insubs){
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr) {
|
||||
char *addr_str = linphone_address_as_string(addr);
|
||||
ms_message("Want to notify %s", addr_str);
|
||||
ms_free(addr_str);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
for(elem=lf->insubs; elem!=NULL; elem=bctbx_list_next(elem)){
|
||||
|
|
@ -538,12 +542,11 @@ LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){
|
|||
online_status = (basic_status == LinphonePresenceBasicStatusOpen) ? LinphoneStatusOnline : LinphoneStatusOffline;
|
||||
if (nb_activities > 1) {
|
||||
char *tmp = NULL;
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr) tmp = linphone_address_as_string(addr);
|
||||
ms_warning("Friend %s has several activities, get status from the first one", tmp ? tmp : "unknown");
|
||||
if (tmp) {
|
||||
ms_free(tmp);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
nb_activities = 1;
|
||||
}
|
||||
|
|
@ -621,26 +624,25 @@ const LinphonePresenceModel * linphone_friend_get_presence_model(const LinphoneF
|
|||
LinphoneFriend* fuckconst = (LinphoneFriend*)lf;
|
||||
bctbx_list_t* addrs = linphone_friend_get_addresses(fuckconst);
|
||||
bctbx_list_t* phones = NULL;
|
||||
bctbx_list_t *it;
|
||||
|
||||
while (addrs) {
|
||||
LinphoneAddress *addr = addrs->data;
|
||||
for (it = addrs; it!= NULL; it = it->next) {
|
||||
LinphoneAddress *addr = (LinphoneAddress*)it->data;
|
||||
char *uri = linphone_address_as_string_uri_only(addr);
|
||||
presence = linphone_friend_get_presence_model_for_uri_or_tel(fuckconst, uri);
|
||||
ms_free(uri);
|
||||
linphone_address_unref(addr);
|
||||
if (presence) return presence;
|
||||
|
||||
addrs = addrs->next;
|
||||
if (presence) break;
|
||||
}
|
||||
bctbx_list_free_with_data(addrs, (bctbx_list_free_func) linphone_address_unref);
|
||||
if (presence) return presence;
|
||||
|
||||
phones = linphone_friend_get_phone_numbers(fuckconst);
|
||||
while (phones) {
|
||||
presence = linphone_friend_get_presence_model_for_uri_or_tel(fuckconst, phones->data);
|
||||
if (presence) return presence;
|
||||
|
||||
phones = phones->next;
|
||||
for (it = phones; it!= NULL; it = it->next) {
|
||||
presence = linphone_friend_get_presence_model_for_uri_or_tel(fuckconst, it->data);
|
||||
if (presence) break;
|
||||
}
|
||||
return NULL;
|
||||
bctbx_list_free(phones);
|
||||
return presence;
|
||||
}
|
||||
|
||||
const LinphonePresenceModel * linphone_friend_get_presence_model_for_uri_or_tel(const LinphoneFriend *lf, const char *uri_or_tel) {
|
||||
|
|
@ -650,12 +652,11 @@ const LinphonePresenceModel * linphone_friend_get_presence_model_for_uri_or_tel(
|
|||
}
|
||||
|
||||
void linphone_friend_set_presence_model(LinphoneFriend *lf, LinphonePresenceModel *presence) {
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr) {
|
||||
char *uri = linphone_address_as_string_uri_only(addr);
|
||||
linphone_friend_set_presence_model_for_uri_or_tel(lf, uri, presence);
|
||||
ms_free(uri);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -683,14 +684,13 @@ BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf){
|
|||
* Otherwise if the proxy config goes to unregistered state, the subscription refresh will be suspended.
|
||||
* An optional proxy whose state has changed can be passed to optimize the processing.
|
||||
**/
|
||||
void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *proxy, bool_t only_when_registered){
|
||||
void linphone_friend_update_subscribes(LinphoneFriend *fr, bool_t only_when_registered){
|
||||
int can_subscribe=1;
|
||||
|
||||
if (only_when_registered && (fr->subscribe || fr->subscribe_active)){
|
||||
LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
if (addr != NULL) {
|
||||
LinphoneProxyConfig *cfg=linphone_core_lookup_known_proxy(fr->lc, addr);
|
||||
if (proxy && proxy!=cfg) return;
|
||||
if (cfg && cfg->state!=LinphoneRegistrationOk){
|
||||
char *tmp=linphone_address_as_string(addr);
|
||||
ms_message("Friend [%s] belongs to proxy config with identity [%s], but this one isn't registered. Subscription is suspended.",
|
||||
|
|
@ -698,7 +698,6 @@ void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *
|
|||
ms_free(tmp);
|
||||
can_subscribe=0;
|
||||
}
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
if (can_subscribe && fr->subscribe && fr->subscribe_active==FALSE){
|
||||
|
|
@ -727,13 +726,12 @@ void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc) {
|
|||
|
||||
void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc) {
|
||||
LinphonePresenceModel *model;
|
||||
LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(fr);
|
||||
|
||||
if (!addr) {
|
||||
ms_debug("No sip url defined in friend %s", linphone_friend_get_name(fr));
|
||||
return;
|
||||
}
|
||||
linphone_address_unref(addr);
|
||||
if (!linphone_core_ready(lc)) {
|
||||
/* lc not ready, deffering subscription */
|
||||
fr->commit=TRUE;
|
||||
|
|
@ -757,15 +755,9 @@ void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc) {
|
|||
}
|
||||
fr->inc_subscribe_pending = FALSE;
|
||||
}
|
||||
#if 0
|
||||
/*triggering a list subscription update from here is probably not a good idea, as linphone_friend_done() may be called
|
||||
* for thousand of LinphoneFriend sequentially.
|
||||
* It is preferable that the application calls linphone_friend_list_update_subscriptions() once it has performmed
|
||||
* all modifications to friends in the list.*/
|
||||
if (fr->lc) {
|
||||
linphone_friend_list_update_subscriptions(fr->friend_list, NULL, linphone_core_should_subscribe_friends_only_when_registered(fr->lc));
|
||||
}
|
||||
#endif
|
||||
|
||||
linphone_friend_update_subscribes(fr, linphone_core_should_subscribe_friends_only_when_registered(lc));
|
||||
|
||||
ms_debug("linphone_friend_apply() done.");
|
||||
lc->bl_refresh=TRUE;
|
||||
fr->commit=FALSE;
|
||||
|
|
@ -832,11 +824,11 @@ void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *lf) {
|
|||
}
|
||||
}
|
||||
|
||||
void linphone_core_update_friends_subscriptions(LinphoneCore *lc, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
|
||||
void linphone_core_update_friends_subscriptions(LinphoneCore *lc) {
|
||||
bctbx_list_t *lists = lc->friends_lists;
|
||||
while (lists) {
|
||||
LinphoneFriendList *list = (LinphoneFriendList *)bctbx_list_get_data(lists);
|
||||
linphone_friend_list_update_subscriptions(list, cfg, only_when_registered);
|
||||
linphone_friend_list_update_subscriptions(list);
|
||||
lists = bctbx_list_next(lists);
|
||||
}
|
||||
}
|
||||
|
|
@ -846,39 +838,11 @@ bool_t linphone_core_should_subscribe_friends_only_when_registered(const Linphon
|
|||
}
|
||||
|
||||
void linphone_core_send_initial_subscribes(LinphoneCore *lc) {
|
||||
bctbx_list_t *lists = lc->friends_lists;
|
||||
bool_t proxy_config_for_rls_presence_uri_domain = FALSE;
|
||||
LinphoneAddress *rls_address = NULL;
|
||||
const bctbx_list_t *elem;
|
||||
|
||||
if (lc->initial_subscribes_sent) return;
|
||||
lc->initial_subscribes_sent=TRUE;
|
||||
while (lists) {
|
||||
LinphoneFriendList *list = (LinphoneFriendList *)bctbx_list_get_data(lists);
|
||||
if (list->rls_uri != NULL) {
|
||||
rls_address = linphone_core_create_address(lc, list->rls_uri);
|
||||
if (rls_address != NULL) {
|
||||
const char *rls_domain = linphone_address_get_domain(rls_address);
|
||||
if (rls_domain != NULL) {
|
||||
for (elem = linphone_core_get_proxy_config_list(lc); elem != NULL; elem = bctbx_list_next(elem)) {
|
||||
LinphoneProxyConfig *cfg = (LinphoneProxyConfig *)bctbx_list_get_data(elem);
|
||||
const char *proxy_domain = linphone_proxy_config_get_domain(cfg);
|
||||
if (strcmp(rls_domain, proxy_domain) == 0) {
|
||||
proxy_config_for_rls_presence_uri_domain = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
linphone_address_unref(rls_address);
|
||||
}
|
||||
}
|
||||
if (proxy_config_for_rls_presence_uri_domain == TRUE) {
|
||||
ms_message("Presence list activated so do not send initial subscribes it will be done when registered");
|
||||
} else {
|
||||
linphone_core_update_friends_subscriptions(lc,NULL,linphone_core_should_subscribe_friends_only_when_registered(lc));
|
||||
}
|
||||
lists = bctbx_list_next(lists);
|
||||
}
|
||||
|
||||
linphone_core_update_friends_subscriptions(lc);
|
||||
}
|
||||
|
||||
void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc) {
|
||||
|
|
@ -1426,7 +1390,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) {
|
|||
char *buf;
|
||||
int store_friends = lp_config_get_int(lc->config, "misc", "store_friends", 1);
|
||||
LinphoneVcard *vcard = NULL;
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
char *addr_str = NULL;
|
||||
|
||||
if (!store_friends) {
|
||||
|
|
@ -1473,7 +1437,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) {
|
|||
);
|
||||
}
|
||||
if (addr_str != NULL) ms_free(addr_str);
|
||||
if (addr != NULL) linphone_address_unref(addr);
|
||||
|
||||
linphone_sql_request_generic(lc->friends_db, buf);
|
||||
sqlite3_free(buf);
|
||||
|
||||
|
|
@ -1685,7 +1649,7 @@ void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
|
|||
for (i = 0; (lf = linphone_friend_new_from_config_file(lc, i)) != NULL; i++) {
|
||||
char friend_section[32];
|
||||
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr) {
|
||||
char *address = NULL;
|
||||
const char *displayName = linphone_address_get_display_name(addr);
|
||||
|
|
@ -1708,7 +1672,6 @@ void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
|
|||
|
||||
snprintf(friend_section, sizeof(friend_section), "friend_%i", i);
|
||||
lp_config_clean_section(lpc, friend_section);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1748,7 +1711,7 @@ const char * linphone_friend_phone_number_to_sip_uri(LinphoneFriend *lf, const c
|
|||
linphone_address_set_uri_param(addr, "user", "phone");
|
||||
full_uri = linphone_address_as_string_uri_only(addr);
|
||||
linphone_address_unref(addr);
|
||||
lfpnsu = ms_new(LinphoneFriendPhoneNumberSipUri, 1);
|
||||
lfpnsu = ms_new0(LinphoneFriendPhoneNumberSipUri, 1);
|
||||
lfpnsu->number = ms_strdup(phone_number);
|
||||
lfpnsu->uri = full_uri;
|
||||
lf->phone_number_sip_uri_map = bctbx_list_append(lf->phone_number_sip_uri_map, lfpnsu);
|
||||
|
|
|
|||
|
|
@ -174,13 +174,11 @@ static char * create_resource_list_xml(const LinphoneFriendList *list) {
|
|||
|
||||
{
|
||||
bctbx_list_t* entries = uri_list(list);
|
||||
bctbx_list_t* it = entries;
|
||||
while (it) {
|
||||
bctbx_list_t* it;
|
||||
for(it = entries; it != NULL; it = it->next){
|
||||
err = add_uri_entry(writer, err, it->data);
|
||||
ms_free(it->data);
|
||||
it = it->next;
|
||||
}
|
||||
bctbx_free(entries);
|
||||
bctbx_list_free_with_data(entries, ms_free);
|
||||
}
|
||||
if (err >= 0) {
|
||||
/* Close the "list" element. */
|
||||
|
|
@ -232,7 +230,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
|
|||
linphone_free_xml_text_content(version_str);
|
||||
if (version < list->expected_notification_version) {
|
||||
ms_warning("rlmi+xml: Discarding received notification with version %d because %d was expected", version, list->expected_notification_version);
|
||||
linphone_friend_list_update_subscriptions(list, NULL, FALSE); /* Refresh subscription to get new full state notify. */
|
||||
linphone_friend_list_update_subscriptions(list); /* Refresh subscription to get new full state notify. */
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
@ -265,6 +263,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
|
|||
if (uri == NULL) continue;
|
||||
addr = linphone_address_new(uri);
|
||||
lf = addr ? linphone_friend_list_find_friend_by_address(list, addr) : NULL;
|
||||
linphone_address_unref(addr);
|
||||
if (lf != NULL) {
|
||||
const char *state = NULL;
|
||||
snprintf(xpath_str, sizeof(xpath_str),"/rlmi:list/rlmi:resource[%i]/rlmi:instance/@state", i);
|
||||
|
|
@ -369,6 +368,7 @@ static LinphoneFriendList * linphone_friend_list_new(void) {
|
|||
|
||||
static void linphone_friend_list_destroy(LinphoneFriendList *list) {
|
||||
if (list->display_name != NULL) ms_free(list->display_name);
|
||||
if (list->rls_addr) linphone_address_unref(list->rls_addr);
|
||||
if (list->rls_uri != NULL) ms_free(list->rls_uri);
|
||||
if (list->content_digest != NULL) ms_free(list->content_digest);
|
||||
if (list->event != NULL) {
|
||||
|
|
@ -450,24 +450,40 @@ void linphone_friend_list_set_display_name(LinphoneFriendList *list, const char
|
|||
}
|
||||
}
|
||||
|
||||
const LinphoneAddress * linphone_friend_list_get_rls_address(const LinphoneFriendList *list){
|
||||
return list->rls_addr;
|
||||
}
|
||||
|
||||
void linphone_friend_list_set_rls_address(LinphoneFriendList *list, const LinphoneAddress *rls_addr){
|
||||
LinphoneAddress *new_rls_addr = rls_addr ? linphone_address_clone(rls_addr) : NULL;
|
||||
|
||||
if (list->rls_addr){
|
||||
linphone_address_unref(list->rls_addr);
|
||||
}
|
||||
list->rls_addr = new_rls_addr;
|
||||
if (list->rls_uri != NULL){
|
||||
ms_free(list->rls_uri);
|
||||
list->rls_uri = NULL;
|
||||
}
|
||||
if (list->rls_addr){
|
||||
list->rls_uri = linphone_address_as_string(list->rls_addr);
|
||||
linphone_core_store_friends_list_in_db(list->lc, list);
|
||||
}
|
||||
}
|
||||
|
||||
const char * linphone_friend_list_get_rls_uri(const LinphoneFriendList *list) {
|
||||
return list->rls_uri;
|
||||
}
|
||||
|
||||
void linphone_friend_list_set_rls_uri(LinphoneFriendList *list, const char *rls_uri) {
|
||||
if (list->rls_uri != NULL) {
|
||||
ms_free(list->rls_uri);
|
||||
list->rls_uri = NULL;
|
||||
}
|
||||
if (rls_uri != NULL) {
|
||||
list->rls_uri = ms_strdup(rls_uri);
|
||||
linphone_core_store_friends_list_in_db(list->lc, list);
|
||||
}
|
||||
LinphoneAddress *addr = rls_uri ? linphone_core_create_address(list->lc, rls_uri) : NULL;
|
||||
linphone_friend_list_set_rls_address(list, addr);
|
||||
if (addr) linphone_address_destroy(addr);
|
||||
}
|
||||
|
||||
static LinphoneFriendListStatus _linphone_friend_list_add_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) {
|
||||
LinphoneFriendListStatus status = LinphoneFriendListInvalidFriend;
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
|
||||
if (!list || lf->friend_list) {
|
||||
if (!list)
|
||||
|
|
@ -486,7 +502,7 @@ static LinphoneFriendListStatus _linphone_friend_list_add_friend(LinphoneFriendL
|
|||
status = linphone_friend_list_import_friend(list, lf, synchronize);
|
||||
linphone_friend_save(lf, lf->lc);
|
||||
}
|
||||
if (addr) linphone_address_unref(addr);
|
||||
|
||||
if (list->rls_uri == NULL) {
|
||||
/* Mimic the behaviour of linphone_core_add_friend() when a resource list server is not in use */
|
||||
linphone_friend_apply(lf, lf->lc);
|
||||
|
|
@ -552,7 +568,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
|
|||
|
||||
lf->friend_list = NULL;
|
||||
linphone_friend_unref(lf);
|
||||
list->friends = bctbx_list_remove_link(list->friends, elem);
|
||||
list->friends = bctbx_list_erase_link(list->friends, elem);
|
||||
return LinphoneFriendListOK;
|
||||
}
|
||||
|
||||
|
|
@ -721,58 +737,84 @@ static void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) {
|
|||
bctbx_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) {
|
||||
const bctbx_list_t *elem;
|
||||
if (list->rls_uri != NULL) {
|
||||
static void linphone_friend_list_send_list_subscription(LinphoneFriendList *list){
|
||||
const LinphoneAddress *address = list->rls_addr;
|
||||
char *xml_content = create_resource_list_xml(list);
|
||||
if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) {
|
||||
unsigned char digest[16];
|
||||
bctbx_md5((unsigned char *)xml_content, strlen(xml_content), digest);
|
||||
if ((list->event != NULL) && (list->content_digest != NULL) && (memcmp(list->content_digest, digest, sizeof(digest)) == 0)) {
|
||||
/* The content has not changed, only refresh the event. */
|
||||
linphone_event_refresh_subscribe(list->event);
|
||||
} else {
|
||||
LinphoneContent *content;
|
||||
int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600);
|
||||
list->expected_notification_version = 0;
|
||||
if (list->content_digest != NULL) ms_free(list->content_digest);
|
||||
list->content_digest = ms_malloc(sizeof(digest));
|
||||
memcpy(list->content_digest, digest, sizeof(digest));
|
||||
if (list->event != NULL) {
|
||||
linphone_event_terminate(list->event);
|
||||
linphone_event_unref(list->event);
|
||||
}
|
||||
list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires);
|
||||
linphone_event_ref(list->event);
|
||||
linphone_event_set_internal(list->event, TRUE);
|
||||
linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe");
|
||||
linphone_event_add_custom_header(list->event, "Supported", "eventlist");
|
||||
linphone_event_add_custom_header(list->event, "Accept", "multipart/related, application/pidf+xml, application/rlmi+xml");
|
||||
linphone_event_add_custom_header(list->event, "Content-Disposition", "recipient-list");
|
||||
content = linphone_core_create_content(list->lc);
|
||||
linphone_content_set_type(content, "application");
|
||||
linphone_content_set_subtype(content, "resource-lists+xml");
|
||||
linphone_content_set_string_buffer(content, xml_content);
|
||||
if (linphone_core_content_encoding_supported(list->lc, "deflate")) {
|
||||
linphone_content_set_encoding(content, "deflate");
|
||||
linphone_event_add_custom_header(list->event, "Accept-Encoding", "deflate");
|
||||
}
|
||||
linphone_event_send_subscribe(list->event, content);
|
||||
linphone_content_unref(content);
|
||||
linphone_event_set_user_data(list->event, list);
|
||||
}
|
||||
}
|
||||
if (xml_content != NULL) ms_free(xml_content);
|
||||
}
|
||||
|
||||
void linphone_friend_list_update_subscriptions(LinphoneFriendList *list){
|
||||
LinphoneProxyConfig *cfg = NULL;
|
||||
const LinphoneAddress *address = linphone_friend_list_get_rls_address(list);
|
||||
bool_t only_when_registered = FALSE;
|
||||
bool_t should_send_list_subscribe = FALSE;
|
||||
|
||||
if (list->lc){
|
||||
if (address)
|
||||
cfg = linphone_core_lookup_known_proxy(list->lc, address);
|
||||
only_when_registered = linphone_core_should_subscribe_friends_only_when_registered(list->lc);
|
||||
should_send_list_subscribe = (!only_when_registered || !cfg || cfg->state == LinphoneRegistrationOk);
|
||||
}
|
||||
|
||||
if (list->rls_addr != NULL) {
|
||||
if (list->enable_subscriptions) {
|
||||
LinphoneAddress *address = linphone_address_new(list->rls_uri);
|
||||
char *xml_content = create_resource_list_xml(list);
|
||||
if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) {
|
||||
unsigned char digest[16];
|
||||
bctbx_md5((unsigned char *)xml_content, strlen(xml_content), digest);
|
||||
if ((list->event != NULL) && (list->content_digest != NULL) && (memcmp(list->content_digest, digest, sizeof(digest)) == 0)) {
|
||||
/* The content has not changed, only refresh the event. */
|
||||
linphone_event_refresh_subscribe(list->event);
|
||||
} else {
|
||||
LinphoneContent *content;
|
||||
int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600);
|
||||
list->expected_notification_version = 0;
|
||||
if (list->content_digest != NULL) ms_free(list->content_digest);
|
||||
list->content_digest = ms_malloc(sizeof(digest));
|
||||
memcpy(list->content_digest, digest, sizeof(digest));
|
||||
if (list->event != NULL) {
|
||||
linphone_event_terminate(list->event);
|
||||
linphone_event_unref(list->event);
|
||||
}
|
||||
list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires);
|
||||
linphone_event_ref(list->event);
|
||||
linphone_event_set_internal(list->event, TRUE);
|
||||
linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe");
|
||||
linphone_event_add_custom_header(list->event, "Supported", "eventlist");
|
||||
linphone_event_add_custom_header(list->event, "Accept", "multipart/related, application/pidf+xml, application/rlmi+xml");
|
||||
linphone_event_add_custom_header(list->event, "Content-Disposition", "recipient-list");
|
||||
content = linphone_core_create_content(list->lc);
|
||||
linphone_content_set_type(content, "application");
|
||||
linphone_content_set_subtype(content, "resource-lists+xml");
|
||||
linphone_content_set_string_buffer(content, xml_content);
|
||||
if (linphone_core_content_encoding_supported(list->lc, "deflate")) {
|
||||
linphone_content_set_encoding(content, "deflate");
|
||||
linphone_event_add_custom_header(list->event, "Accept-Encoding", "deflate");
|
||||
}
|
||||
linphone_event_send_subscribe(list->event, content);
|
||||
linphone_content_unref(content);
|
||||
linphone_event_set_user_data(list->event, list);
|
||||
if (should_send_list_subscribe){
|
||||
linphone_friend_list_send_list_subscription(list);
|
||||
}else{
|
||||
if (list->event){
|
||||
linphone_event_terminate(list->event);
|
||||
linphone_event_unref(list->event);
|
||||
list->event = NULL;
|
||||
ms_message("Friends list [%p] subscription terminated because proxy config lost connection", list);
|
||||
}else{
|
||||
ms_message("Friends list [%p] subscription update skipped since dependant proxy config is not yet registered", list);
|
||||
}
|
||||
}
|
||||
if (address != NULL) linphone_address_unref(address);
|
||||
if (xml_content != NULL) ms_free(xml_content);
|
||||
} else {
|
||||
ms_message("Friends list [%p] subscription update skipped since subscriptions not enabled yet", list);
|
||||
}
|
||||
} else if (list->enable_subscriptions) {
|
||||
const bctbx_list_t *elem;
|
||||
for (elem = list->friends; elem != NULL; elem = bctbx_list_next(elem)) {
|
||||
LinphoneFriend *lf = (LinphoneFriend *)bctbx_list_get_data(elem);
|
||||
linphone_friend_update_subscribes(lf, cfg, only_when_registered);
|
||||
linphone_friend_update_subscribes(lf, only_when_registered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -978,7 +1020,7 @@ void linphone_friend_list_enable_subscriptions(LinphoneFriendList *list, bool_t
|
|||
if (list->enable_subscriptions != enabled) {
|
||||
list->enable_subscriptions = enabled;
|
||||
if (enabled) {
|
||||
linphone_friend_list_update_subscriptions(list, NULL, TRUE);
|
||||
linphone_friend_list_update_subscriptions(list);
|
||||
} else {
|
||||
linphone_friend_list_close_subscriptions(list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,6 +153,21 @@ LINPHONE_PUBLIC const char * linphone_friend_list_get_rls_uri(const LinphoneFrie
|
|||
**/
|
||||
LINPHONE_PUBLIC void linphone_friend_list_set_rls_uri(LinphoneFriendList *list, const char *rls_uri);
|
||||
|
||||
|
||||
/**
|
||||
* Get the RLS (Resource List Server) URI associated with the friend list to subscribe to these friends presence.
|
||||
* @param[in] list LinphoneFriendList object.
|
||||
* @return The RLS URI associated with the friend list.
|
||||
**/
|
||||
LINPHONE_PUBLIC const LinphoneAddress * linphone_friend_list_get_rls_address(const LinphoneFriendList *list);
|
||||
|
||||
/**
|
||||
* Set the RLS (Resource List Server) URI associated with the friend list to subscribe to these friends presence.
|
||||
* @param[in] list LinphoneFriendList object.
|
||||
* @param[in] rls_addr The RLS URI to associate with the friend list.
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_friend_list_set_rls_address(LinphoneFriendList *list, const LinphoneAddress *rls_addr);
|
||||
|
||||
/**
|
||||
* Add a friend to a friend list. If or when a remote CardDAV server will be attached to the list, the friend will be sent to the server.
|
||||
* @param[in] list LinphoneFriendList object.
|
||||
|
|
@ -202,14 +217,19 @@ LINPHONE_PUBLIC LinphoneFriend * linphone_friend_list_find_friend_by_address(con
|
|||
LINPHONE_PUBLIC LinphoneFriend * linphone_friend_list_find_friend_by_uri(const LinphoneFriendList *list, const char *uri);
|
||||
|
||||
/**
|
||||
* Find a frient in the friend list using a ref key.
|
||||
* Find a friend in the friend list using a ref key.
|
||||
* @param[in] list LinphoneFriendList object.
|
||||
* @param[in] ref_key The ref key string of the friend we want to search for.
|
||||
* @return A LinphoneFriend if found, NULL otherwise.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFriendList *list, const char *ref_key);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered);
|
||||
/**
|
||||
* Update presence subscriptions for the entire list. Calling this function is necessary when list subscriptions are enabled,
|
||||
* ie when a RLS presence server is used.
|
||||
* @param[in] list the friend list
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_friend_list_update_subscriptions(LinphoneFriendList *list);
|
||||
|
||||
/**
|
||||
* Notify our presence to all the friends in the friend list that have subscribed to our presence directly (not using a RLS).
|
||||
|
|
|
|||
|
|
@ -51,23 +51,25 @@ static void stop(int signum){
|
|||
* presence state change notification callback
|
||||
*/
|
||||
static void notify_presence_recv_updated (LinphoneCore *lc, LinphoneFriend *friend) {
|
||||
LinphoneAddress* friend_address = linphone_friend_get_address(friend);
|
||||
const LinphoneAddress* friend_address = linphone_friend_get_address(friend);
|
||||
if (friend_address != NULL) {
|
||||
const LinphonePresenceModel* model = linphone_friend_get_presence_model(friend);
|
||||
LinphonePresenceActivity *activity = linphone_presence_model_get_activity(model);
|
||||
char *activity_str = linphone_presence_activity_to_string(activity);
|
||||
char *str = linphone_address_as_string (friend_address);
|
||||
printf("New state state [%s] for user id [%s] \n"
|
||||
,activity_str
|
||||
,linphone_address_as_string (friend_address));
|
||||
linphone_address_unref(friend_address);
|
||||
,str);
|
||||
ms_free(str);
|
||||
}
|
||||
}
|
||||
static void new_subscription_requested (LinphoneCore *lc, LinphoneFriend *friend, const char* url) {
|
||||
LinphoneAddress* friend_address = linphone_friend_get_address(friend);
|
||||
const LinphoneAddress* friend_address = linphone_friend_get_address(friend);
|
||||
|
||||
if (friend_address != NULL) {
|
||||
printf(" [%s] wants to see your status, accepting\n"
|
||||
,linphone_address_as_string (friend_address));
|
||||
linphone_address_unref(friend_address);
|
||||
char *str = linphone_address_as_string (friend_address);
|
||||
printf(" [%s] wants to see your status, accepting\n", str);
|
||||
ms_free(str);
|
||||
}
|
||||
linphone_friend_edit(friend); /* start editing friend */
|
||||
linphone_friend_set_inc_subscribe_policy(friend,LinphoneSPAccept); /* Accept incoming subscription request for this friend*/
|
||||
|
|
|
|||
|
|
@ -1130,8 +1130,10 @@ static void linphone_call_get_local_ip(LinphoneCall *call, const LinphoneAddress
|
|||
if (res != NULL) freeaddrinfo(res);
|
||||
}
|
||||
|
||||
if (dest != NULL || call->media_localip[0] == '\0')
|
||||
if (dest != NULL || call->media_localip[0] == '\0' || call->need_localip_refresh){
|
||||
call->need_localip_refresh = FALSE;
|
||||
linphone_core_get_local_ip(call->core, af, dest, call->media_localip);
|
||||
}
|
||||
return;
|
||||
found:
|
||||
strncpy(call->media_localip,ip,LINPHONE_IPADDR_SIZE);
|
||||
|
|
@ -4699,7 +4701,7 @@ void linphone_call_log_completed(LinphoneCall *call){
|
|||
}
|
||||
elem=prevelem;
|
||||
linphone_call_log_unref((LinphoneCallLog*)elem->data);
|
||||
lc->call_logs=bctbx_list_remove_link(lc->call_logs,elem);
|
||||
lc->call_logs=bctbx_list_erase_link(lc->call_logs,elem);
|
||||
}
|
||||
call_logs_write_to_config_file(lc);
|
||||
}
|
||||
|
|
@ -5023,6 +5025,7 @@ void linphone_call_set_broken(LinphoneCall *call){
|
|||
/*during these states, the dialog is established. A failure of a transaction is not expected to close it.
|
||||
* Instead we have to repair the dialog by sending a reINVITE*/
|
||||
call->broken = TRUE;
|
||||
call->need_localip_refresh = TRUE;
|
||||
break;
|
||||
default:
|
||||
ms_error("linphone_call_set_broken() unimplemented case.");
|
||||
|
|
|
|||
|
|
@ -1622,8 +1622,11 @@ void linphone_core_reload_ms_plugins(LinphoneCore *lc, const char *path){
|
|||
}
|
||||
|
||||
static void linphone_core_start(LinphoneCore * lc) {
|
||||
linphone_core_add_friend_list(lc, NULL);
|
||||
|
||||
LinphoneFriendList *list = linphone_core_create_friend_list(lc);
|
||||
linphone_friend_list_set_display_name(list, "_default");
|
||||
linphone_core_add_friend_list(lc, list);
|
||||
linphone_friend_list_unref(list);
|
||||
|
||||
sip_setup_register_all(lc->factory);
|
||||
sound_config_read(lc);
|
||||
net_config_read(lc);
|
||||
|
|
@ -2064,31 +2067,22 @@ void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list
|
|||
linphone_core_notify_friend_list_removed(lc, list);
|
||||
list->lc = NULL;
|
||||
linphone_friend_list_unref(list);
|
||||
lc->friends_lists = bctbx_list_remove_link(lc->friends_lists, elem);
|
||||
lc->friends_lists = bctbx_list_erase_link(lc->friends_lists, elem);
|
||||
}
|
||||
|
||||
void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) {
|
||||
const char *rls_uri = lp_config_get_string(lc->config, "sip", "rls_uri", NULL);
|
||||
if (list) {
|
||||
if (!list->lc) {
|
||||
list->lc = lc;
|
||||
}
|
||||
lc->friends_lists = bctbx_list_append(lc->friends_lists, linphone_friend_list_ref(list));
|
||||
|
||||
if (!list->lc) {
|
||||
list->lc = lc;
|
||||
}
|
||||
lc->friends_lists = bctbx_list_append(lc->friends_lists, linphone_friend_list_ref(list));
|
||||
#ifdef SQLITE_STORAGE_ENABLED
|
||||
linphone_core_store_friends_list_in_db(lc, list);
|
||||
linphone_core_store_friends_list_in_db(lc, list);
|
||||
#endif
|
||||
linphone_core_notify_friend_list_created(lc, list);
|
||||
if (!linphone_friend_list_get_rls_uri(list) && rls_uri && lp_config_get_int(lc->config, "sip", "use_rls_presence", 0)) {
|
||||
linphone_friend_list_set_rls_uri(list, rls_uri);
|
||||
}
|
||||
} else {
|
||||
list = linphone_core_create_friend_list(lc);
|
||||
linphone_friend_list_set_display_name(list, "_default");
|
||||
if (rls_uri && lp_config_get_int(lc->config, "sip", "use_rls_presence", 0)) {
|
||||
linphone_friend_list_set_rls_uri(list, rls_uri);
|
||||
}
|
||||
lc->friends_lists = bctbx_list_append(lc->friends_lists, linphone_friend_list_ref(list));
|
||||
linphone_friend_list_unref(list);
|
||||
linphone_core_notify_friend_list_created(lc, list);
|
||||
if (!linphone_friend_list_get_rls_uri(list) && rls_uri && lp_config_get_int(lc->config, "sip", "use_rls_presence", 0)) {
|
||||
linphone_friend_list_set_rls_uri(list, rls_uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2628,7 +2622,7 @@ static void proxy_update(LinphoneCore *lc){
|
|||
LinphoneProxyConfig* cfg = (LinphoneProxyConfig*)elem->data;
|
||||
next=elem->next;
|
||||
if (ms_time(NULL) - cfg->deletion_date > 32) {
|
||||
lc->sip_conf.deleted_proxies =bctbx_list_remove_link(lc->sip_conf.deleted_proxies,elem);
|
||||
lc->sip_conf.deleted_proxies =bctbx_list_erase_link(lc->sip_conf.deleted_proxies,elem);
|
||||
ms_message("Proxy config for [%s] is definitely removed from core.",linphone_proxy_config_get_addr(cfg));
|
||||
_linphone_proxy_config_release_ops(cfg);
|
||||
linphone_proxy_config_unref(cfg);
|
||||
|
|
@ -2665,7 +2659,7 @@ static void analyze_buddy_lookup_results(LinphoneCore *lc, LinphoneProxyConfig *
|
|||
}
|
||||
/*purge completed requests */
|
||||
while((elem=bctbx_list_find(lc->bl_reqs,NULL))!=NULL){
|
||||
lc->bl_reqs=bctbx_list_remove_link(lc->bl_reqs,elem);
|
||||
lc->bl_reqs=bctbx_list_erase_link(lc->bl_reqs,elem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7000,7 +6994,7 @@ int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call)
|
|||
it=bctbx_list_find(the_calls,call);
|
||||
if (it)
|
||||
{
|
||||
the_calls = bctbx_list_remove_link(the_calls,it);
|
||||
the_calls = bctbx_list_erase_link(the_calls,it);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,11 +158,12 @@ LINPHONE_PUBLIC int linphone_friend_set_address(LinphoneFriend *fr, const Linpho
|
|||
#define linphone_friend_set_addr linphone_friend_set_address
|
||||
|
||||
/**
|
||||
* Get address of this friend
|
||||
* Get address of this friend.
|
||||
* @note the LinphoneAddress object returned is hold by the LinphoneFriend, however calling several time this function may return different objects.
|
||||
* @param lf #LinphoneFriend object
|
||||
* @return #LinphoneAddress
|
||||
*/
|
||||
LINPHONE_PUBLIC 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
|
||||
|
|
@ -176,7 +177,7 @@ LINPHONE_PUBLIC void linphone_friend_add_address(LinphoneFriend *lf, const Linph
|
|||
* @param lf #LinphoneFriend object
|
||||
* @return \mslist{LinphoneAddress}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf);
|
||||
LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_addresses(const LinphoneFriend *lf);
|
||||
|
||||
/**
|
||||
* Removes an address in this friend
|
||||
|
|
|
|||
|
|
@ -1766,7 +1766,7 @@ void linphone_task_list_remove(LinphoneTaskList *t, LinphoneCoreIterateHook hook
|
|||
for(elem=t->hooks;elem!=NULL;elem=elem->next){
|
||||
Hook *h=(Hook*)elem->data;
|
||||
if (h->fun==hook && h->data==hook_data){
|
||||
t->hooks = bctbx_list_remove_link(t->hooks,elem);
|
||||
t->hooks = bctbx_list_erase_link(t->hooks,elem);
|
||||
ms_free(h);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1471,7 +1471,7 @@ static LinphonePresenceModel * process_pidf_xml_presence_notification(xmlparsing
|
|||
|
||||
void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalOp *op){
|
||||
LinphoneFriend *fl=linphone_core_create_friend_with_address(lc,subscriber);
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
char *tmp;
|
||||
|
||||
if (fl==NULL) return ;
|
||||
|
|
@ -1487,7 +1487,6 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalO
|
|||
tmp = linphone_address_as_string(addr);
|
||||
linphone_core_notify_new_subscription_requested(lc,fl,tmp);
|
||||
ms_free(tmp);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1897,7 +1896,7 @@ end:
|
|||
void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model){
|
||||
char *tmp;
|
||||
LinphoneFriend *lf = NULL;
|
||||
LinphoneAddress *friend=NULL;
|
||||
const LinphoneAddress *friend=NULL;
|
||||
LinphonePresenceModel *presence = model ? (LinphonePresenceModel *)model:linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline, NULL);
|
||||
|
||||
if (linphone_core_get_default_friend_list(lc) != NULL)
|
||||
|
|
@ -1917,7 +1916,6 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
|
|||
ms_message("We are notified that [%s] has presence [%s]", tmp, activity_str);
|
||||
if (activity_str != NULL) ms_free(activity_str);
|
||||
ms_free(tmp);
|
||||
linphone_address_unref(friend);
|
||||
}
|
||||
linphone_friend_set_presence_model(lf, presence);
|
||||
lf->subscribe_active=TRUE;
|
||||
|
|
|
|||
|
|
@ -368,6 +368,7 @@ struct _LinphoneCall{
|
|||
bool_t paused_by_app;
|
||||
bool_t broken; /*set to TRUE when the call is in broken state due to network disconnection or transport */
|
||||
bool_t defer_notify_incoming;
|
||||
bool_t need_localip_refresh;
|
||||
};
|
||||
|
||||
BELLE_SIP_DECLARE_VPTR(LinphoneCall);
|
||||
|
|
@ -424,7 +425,7 @@ void _linphone_friend_list_release(LinphoneFriendList *list);
|
|||
void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
|
||||
void linphone_friend_close_subscriptions(LinphoneFriend *lf);
|
||||
void _linphone_friend_release(LinphoneFriend *lf);
|
||||
void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered);
|
||||
void linphone_friend_update_subscribes(LinphoneFriend *fr, bool_t only_when_registered);
|
||||
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
|
||||
void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc);
|
||||
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);
|
||||
|
|
@ -438,7 +439,8 @@ LinphoneFriend *linphone_core_find_friend_by_out_subscribe(const LinphoneCore *l
|
|||
LinphoneFriend *linphone_core_find_friend_by_inc_subscribe(const LinphoneCore *lc, SalOp *op);
|
||||
MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf);
|
||||
bool_t linphone_core_should_subscribe_friends_only_when_registered(const LinphoneCore *lc);
|
||||
void linphone_core_update_friends_subscriptions(LinphoneCore *lc, LinphoneProxyConfig *cfg, bool_t only_when_registered);
|
||||
void linphone_core_update_friends_subscriptions(LinphoneCore *lc);
|
||||
void _linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered);
|
||||
void linphone_core_friends_storage_init(LinphoneCore *lc);
|
||||
void linphone_core_friends_storage_close(LinphoneCore *lc);
|
||||
void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf);
|
||||
|
|
@ -754,7 +756,8 @@ struct _LinphoneFriendList {
|
|||
LinphoneCore *lc;
|
||||
LinphoneEvent *event;
|
||||
char *display_name;
|
||||
char *rls_uri;
|
||||
char *rls_uri; /*this field is take in sync with rls_addr*/
|
||||
LinphoneAddress *rls_addr;
|
||||
MSList *friends;
|
||||
unsigned char *content_digest;
|
||||
int expected_notification_version;
|
||||
|
|
|
|||
|
|
@ -1272,7 +1272,7 @@ void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrat
|
|||
ms_message("Updating friends for identity [%s] on core [%p]",linphone_proxy_config_get_identity(cfg),cfg->lc);
|
||||
/* state must be updated before calling linphone_core_update_friends_subscriptions*/
|
||||
cfg->state=state;
|
||||
linphone_core_update_friends_subscriptions(lc,cfg,TRUE);
|
||||
linphone_core_update_friends_subscriptions(lc);
|
||||
} else {
|
||||
/*at this point state must be updated*/
|
||||
cfg->state=state;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void cleanup_dead_vtable_refs(LinphoneCore *lc){
|
|||
next_it=it->next;
|
||||
if (ref->valid==0){
|
||||
ref->valid=0;
|
||||
lc->vtable_refs=bctbx_list_remove_link(lc->vtable_refs, it);
|
||||
lc->vtable_refs=bctbx_list_erase_link(lc->vtable_refs, it);
|
||||
ms_free(ref);
|
||||
}
|
||||
it=next_it;
|
||||
|
|
|
|||
|
|
@ -90,13 +90,12 @@ static void linphone_gtk_set_selection_to_uri_bar(GtkTreeView *treeview){
|
|||
gchar* friend;
|
||||
select = gtk_tree_view_get_selection (treeview);
|
||||
if (gtk_tree_selection_get_selected (select, &model, &iter)) {
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
|
||||
addr = linphone_friend_get_address(lf);
|
||||
if (addr) {
|
||||
friend=linphone_address_as_string(addr);
|
||||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),friend);
|
||||
linphone_address_unref(addr);
|
||||
ms_free(friend);
|
||||
}
|
||||
}
|
||||
|
|
@ -179,14 +178,13 @@ gboolean linphone_gtk_on_key_press(GtkWidget *widget, GdkEvent *event, gpointer
|
|||
LinphoneChatRoom *cr;
|
||||
do{
|
||||
if (index == key) {
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
|
||||
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
|
||||
if (lf != NULL) {
|
||||
addr = linphone_friend_get_address(lf);
|
||||
if (addr != NULL) {
|
||||
linphone_gtk_friend_list_set_chat_conversation(addr);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
if (cr != NULL){
|
||||
|
|
@ -223,7 +221,7 @@ void linphone_gtk_delete_history(GtkWidget *button){
|
|||
linphone_chat_room_delete_history(cr);
|
||||
if(chat_view!=NULL){
|
||||
const LinphoneAddress *from=linphone_gtk_friend_list_get_active_address();
|
||||
LinphoneAddress *addr=linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr=linphone_friend_get_address(lf);
|
||||
if (addr != NULL) {
|
||||
if(linphone_address_weak_equal(from,addr)){
|
||||
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
|
||||
|
|
@ -236,7 +234,6 @@ void linphone_gtk_delete_history(GtkWidget *button){
|
|||
gtk_text_buffer_delete (text_buffer, &start, &end);
|
||||
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
|
||||
}
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
linphone_gtk_show_friends();
|
||||
|
|
@ -339,7 +336,7 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
|
|||
store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)));
|
||||
if (gtk_tree_model_get_iter_first(model,&iter)) {
|
||||
do{
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
gtk_tree_model_get(model, &iter,FRIEND_ID , &lf, -1);
|
||||
addr=linphone_friend_get_address(lf);
|
||||
if (addr != NULL) {
|
||||
|
|
@ -353,7 +350,6 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
|
|||
gtk_tree_selection_select_iter(selection, &iter);
|
||||
break;
|
||||
}
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}while(gtk_tree_model_iter_next(model,&iter));
|
||||
}
|
||||
|
|
@ -403,7 +399,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
|
|||
store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(item)));
|
||||
if (gtk_tree_selection_get_selected (select, &model, &iter)){
|
||||
GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(w,"viewswitch");
|
||||
LinphoneAddress *addr;
|
||||
const LinphoneAddress *addr;
|
||||
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
|
||||
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
|
||||
addr=linphone_friend_get_address(lf);
|
||||
|
|
@ -420,7 +416,6 @@ void linphone_gtk_chat_selected(GtkWidget *item){
|
|||
} else {
|
||||
linphone_gtk_load_chatroom(cr,addr,page);
|
||||
}
|
||||
linphone_address_unref(addr);
|
||||
linphone_gtk_mark_chat_read(cr);
|
||||
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
|
||||
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
|
||||
|
|
@ -607,12 +602,11 @@ void linphone_gtk_friend_list_on_name_column_clicked(GtkTreeModel *model){
|
|||
static int get_friend_weight(const LinphoneFriend *lf){
|
||||
int w=0;
|
||||
LinphoneCore *lc=linphone_gtk_get_core();
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
LinphoneChatRoom *cr = NULL;
|
||||
|
||||
if (addr != NULL) {
|
||||
cr = linphone_core_get_chat_room(lc, addr);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
if (cr && linphone_chat_room_get_unread_messages_count(cr)>0){
|
||||
w+=2000;
|
||||
|
|
@ -639,7 +633,7 @@ static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend *
|
|||
w2=get_friend_weight(lf2);
|
||||
if (w1==w2){
|
||||
const char *u1,*u2;
|
||||
LinphoneAddress *addr1,*addr2;
|
||||
const LinphoneAddress *addr1,*addr2;
|
||||
addr1=linphone_friend_get_address(lf1);
|
||||
addr2=linphone_friend_get_address(lf2);
|
||||
if ((addr1 == NULL) && (addr2 == NULL)) return 0;
|
||||
|
|
@ -654,8 +648,6 @@ static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend *
|
|||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
linphone_address_unref(addr1);
|
||||
linphone_address_unref(addr2);
|
||||
} else {
|
||||
ret = w2-w1;
|
||||
}
|
||||
|
|
@ -777,7 +769,7 @@ void linphone_gtk_show_friends(void){
|
|||
|
||||
for(itf=sorted;itf!=NULL;itf=bctbx_list_next(itf)){
|
||||
LinphoneFriend *lf=(LinphoneFriend*)itf->data;
|
||||
LinphoneAddress *f_addr=linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *f_addr=linphone_friend_get_address(lf);
|
||||
const char *name=linphone_friend_get_name(lf);
|
||||
char *uri = NULL;
|
||||
const char *display=name;
|
||||
|
|
@ -806,7 +798,6 @@ void linphone_gtk_show_friends(void){
|
|||
escaped=g_markup_escape_text(uri,-1);
|
||||
gtk_list_store_set(store,&iter,FRIEND_SIP_ADDRESS,escaped,-1);
|
||||
g_free(escaped);
|
||||
linphone_address_unref(f_addr);
|
||||
ms_free(uri);
|
||||
}
|
||||
}
|
||||
|
|
@ -817,7 +808,7 @@ void linphone_gtk_show_contact(LinphoneFriend *lf, GtkWidget *parent){
|
|||
GtkWidget *w = linphone_gtk_create_window("contact", parent);
|
||||
char *uri;
|
||||
const char *name = linphone_friend_get_name(lf);
|
||||
LinphoneAddress *f_addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *f_addr = linphone_friend_get_address(lf);
|
||||
|
||||
if (f_addr != NULL) {
|
||||
uri=linphone_address_as_string_uri_only(f_addr);
|
||||
|
|
@ -825,7 +816,6 @@ void linphone_gtk_show_contact(LinphoneFriend *lf, GtkWidget *parent){
|
|||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"sip_address")),uri);
|
||||
ms_free(uri);
|
||||
}
|
||||
linphone_address_unref(f_addr);
|
||||
}
|
||||
|
||||
if (name){
|
||||
|
|
|
|||
|
|
@ -677,7 +677,7 @@ void on_contact_provider_search_results( LinphoneContactSearch* req, bctbx_list_
|
|||
while( friends ){
|
||||
LinphoneFriend* lf = friends->data;
|
||||
if( lf ) {
|
||||
LinphoneAddress* la = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress* la = linphone_friend_get_address(lf);
|
||||
if( la ){
|
||||
char *addr = linphone_address_as_string(la);
|
||||
|
||||
|
|
@ -688,7 +688,6 @@ void on_contact_provider_search_results( LinphoneContactSearch* req, bctbx_list_
|
|||
1, COMPLETION_LDAP, -1);
|
||||
ms_free(addr);
|
||||
}
|
||||
linphone_address_unref(la);
|
||||
}
|
||||
}
|
||||
friends = friends->next;
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ static void linphone_gtk_codec_move(GtkWidget *button, int dir, int type){ /* 0=
|
|||
else before=sel_elem;
|
||||
codec_list=bctbx_list_insert(codec_list,before,pt);
|
||||
}
|
||||
codec_list=bctbx_list_remove_link(codec_list,sel_elem);
|
||||
codec_list=bctbx_list_erase_link(codec_list,sel_elem);
|
||||
if (pt->type==PAYLOAD_VIDEO)
|
||||
linphone_core_set_video_codecs(lc,codec_list);
|
||||
else linphone_core_set_audio_codecs(lc,codec_list);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 28ade0c3e76761ad7fa35ebaa7c68e98599de17e
|
||||
Subproject commit 5feed4355361ef5dfd22317c68851131891a62d5
|
||||
2
oRTP
2
oRTP
|
|
@ -1 +1 @@
|
|||
Subproject commit 9522d4f0d06bb41fd5c684804d5fdb665664bf03
|
||||
Subproject commit 5d58ed7bead312e77bd6f0ac0328352250dd1349
|
||||
|
|
@ -393,7 +393,7 @@ static void test_presence_list_base(bool_t enable_compression) {
|
|||
linphone_core_remove_friend_list(marie->lc, linphone_core_get_default_friend_list(marie->lc));
|
||||
linphone_core_add_friend_list(marie->lc, lfl);
|
||||
linphone_friend_list_unref(lfl);
|
||||
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(marie->lc), NULL, FALSE);
|
||||
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(marie->lc));
|
||||
|
||||
wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 4000);
|
||||
BC_ASSERT_EQUAL(marie->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
|
||||
|
|
@ -411,7 +411,7 @@ static void test_presence_list_base(bool_t enable_compression) {
|
|||
linphone_core_remove_friend_list(pauline->lc, linphone_core_get_default_friend_list(pauline->lc));
|
||||
linphone_core_add_friend_list(pauline->lc, lfl);
|
||||
linphone_friend_list_unref(lfl);
|
||||
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(pauline->lc), NULL, FALSE);
|
||||
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(pauline->lc));
|
||||
|
||||
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 4000);
|
||||
BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
|
||||
|
|
@ -476,6 +476,7 @@ static void test_presence_list_base(bool_t enable_compression) {
|
|||
, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
|
||||
|
||||
end:
|
||||
bctbx_list_free(lcs);
|
||||
linphone_core_manager_destroy(laure);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
|
|
@ -555,7 +556,7 @@ static void test_presence_list_subscription_expire_for_unknown(void) {
|
|||
linphone_friend_list_add_friend(lfl, lf);
|
||||
linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc));
|
||||
linphone_core_add_friend_list(laure->lc, lfl);
|
||||
linphone_friend_list_update_subscriptions(lfl,NULL,FALSE);
|
||||
linphone_friend_list_update_subscriptions(lfl);
|
||||
linphone_friend_list_unref(lfl);
|
||||
|
||||
/* wait for refresh*/
|
||||
|
|
@ -593,7 +594,7 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) {
|
|||
linphone_core_add_friend_list(laure->lc, lfl);
|
||||
linphone_friend_list_unref(lfl);
|
||||
linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL));
|
||||
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc), NULL, FALSE);
|
||||
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc));
|
||||
lcs = bctbx_list_append(lcs, laure->lc);
|
||||
lcs = bctbx_list_append(lcs, pauline->lc);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,11 +38,10 @@ static LinphoneCoreManager* presence_linphone_core_manager_new(char* username) {
|
|||
|
||||
void new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url){
|
||||
stats* counters;
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr != NULL) {
|
||||
char* from=linphone_address_as_string(addr);
|
||||
ms_message("New subscription request from [%s] url [%s]",from,url);
|
||||
linphone_address_unref(addr);
|
||||
ms_free(from);
|
||||
}
|
||||
counters = get_stats(lc);
|
||||
|
|
@ -53,11 +52,10 @@ void new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char
|
|||
void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) {
|
||||
stats* counters;
|
||||
unsigned int i;
|
||||
LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr != NULL) {
|
||||
char* from=linphone_address_as_string(addr);
|
||||
ms_message("New Notify request from [%s] ",from);
|
||||
linphone_address_unref(addr);
|
||||
ms_free(from);
|
||||
}
|
||||
counters = get_stats(lc);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue