static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t remove_from_server) { bctbx_list_t *elem = bctbx_list_find(list->friends, lf); if (elem == NULL) return LinphoneFriendListNonExistentFriend; #ifdef SQLITE_STORAGE_ENABLED if (lf && lf->lc && lf->lc->friends_db) { linphone_core_remove_friend_from_db(lf->lc, lf); } #endif if (remove_from_server) { LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lvc && linphone_vcard_get_uid(lvc)) { LinphoneCardDavContext *cdc = linphone_carddav_context_new(list); if (cdc) { cdc->sync_done_cb = carddav_done; if (cdc->friend_list->cbs->sync_state_changed_cb) { cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL); } linphone_carddav_delete_vcard(cdc, lf); } } } if (!list->lc->friends_db_file) { linphone_core_write_friends_config(list->lc); } lf->friend_list = NULL; linphone_friend_unref(lf); list->friends = bctbx_list_remove_link(list->friends, elem); return LinphoneFriendListOK; }
void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op){ if (bctbx_list_find(lf->insubs, op)){ sal_op_release(op); lf->insubs = bctbx_list_remove(lf->insubs, op); } }
static LinphoneFriendListStatus _linphone_friend_list_add_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) { LinphoneFriendListStatus status = LinphoneFriendListInvalidFriend; if (!list || !lf->uri || lf->friend_list) { if (!list) ms_error("linphone_friend_list_add_friend(): invalid list, null"); if (!lf->uri) ms_error("linphone_friend_list_add_friend(): invalid friend, no sip uri"); if (lf->friend_list) ms_error("linphone_friend_list_add_friend(): invalid friend, already in list"); return status; } if (bctbx_list_find(list->friends, lf) != NULL) { char *tmp = NULL; const LinphoneAddress *addr = linphone_friend_get_address(lf); if (addr) tmp = linphone_address_as_string(addr); ms_warning("Friend %s already in list [%s], ignored.", tmp ? tmp : "unknown", list->display_name); if (tmp) ms_free(tmp); } else { status = linphone_friend_list_import_friend(list, lf, synchronize); linphone_friend_save(lf, lf->lc); } 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); } return status; }
void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) { if (linphone_friend_list_add_friend(linphone_core_get_default_friend_list(lc), lf) != LinphoneFriendListOK) return; if (bctbx_list_find(lc->subscribers, lf)) { /*if this friend was in the pending subscriber list, now remove it from this list*/ lc->subscribers = bctbx_list_remove(lc->subscribers, lf); linphone_friend_unref(lf); } }
void sal_remove_pending_auth(Sal *sal, SalOp *op){ if (op->has_auth_pending){ op->has_auth_pending=FALSE; if (bctbx_list_find(sal->pending_auths,op)){ sal->pending_auths=bctbx_list_remove(sal->pending_auths,op); } } }
LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe(const LinphoneFriendList *list, SalOp *op) { const bctbx_list_t *elem; for (elem = list->friends; elem != NULL; elem = elem->next) { LinphoneFriend *lf = (LinphoneFriend *)elem->data; if (bctbx_list_find(lf->insubs, op)) return lf; } return NULL; }
bctbx_list_t* _bctbx_list_remove(bctbx_list_t* first, void *data, int warn_if_not_found) { bctbx_list_t* it; it=bctbx_list_find(first,data); if (it) return bctbx_list_erase_link(first,it); else if (warn_if_not_found) { bctbx_warning("bctbx_list_remove: no element with %p data was in the list", data); } return first; }
static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, LinphoneFriend *lf_old) { if (cdc) { LinphoneFriendList *lfl = cdc->friend_list; bctbx_list_t *elem = bctbx_list_find(lfl->friends, lf_old); if (elem) { elem->data = linphone_friend_ref(lf_new); } linphone_core_store_friend_in_db(lf_new->lc, lf_new); if (cdc->friend_list->cbs->contact_updated_cb) { cdc->friend_list->cbs->contact_updated_cb(lfl, lf_new, lf_old); } linphone_friend_unref(lf_old); } }
void sal_add_pending_auth(Sal *sal, SalOp *op){ if (bctbx_list_find(sal->pending_auths,op)==NULL){ sal->pending_auths=bctbx_list_append(sal->pending_auths,op); op->has_auth_pending=TRUE; } }
static bool_t stateful_analyzer_process_rtcp(MSQosAnalyzer *objbase, mblk_t *rtcp){ MSStatefulQosAnalyzer *obj=(MSStatefulQosAnalyzer*)objbase; const report_block_t *rb=NULL; if (rtcp_is_SR(rtcp)){ rb=rtcp_SR_get_report_block(rtcp,0); }else if (rtcp_is_RR(rtcp)){ rb=rtcp_RR_get_report_block(rtcp,0); } if (rb && report_block_get_ssrc(rb)==rtp_session_get_send_ssrc(obj->session)){ if (ortp_loss_rate_estimator_process_report_block(objbase->lre,obj->session,rb)){ int i; float loss_rate = ortp_loss_rate_estimator_get_value(objbase->lre); float up_bw = stateful_qos_analyzer_upload_bandwidth(obj,report_block_get_high_ext_seq(rb)); obj->curindex++; /*flush bandwidth estimation measures for seq number lower than remote report block received*/ for (i=0;i<BW_HISTORY;i++){ if (obj->upload_bandwidth[i].seq_number<report_block_get_high_ext_seq(rb)){ obj->upload_bandwidth[i].seq_number=0; obj->upload_bandwidth[i].up_bandwidth=0.f; } } /* Always skip the first report, since values might be erroneous due to initialization of multiples objects (encoder/decoder/stats computing..) Instead assume loss rate is a good estimation of network capacity */ if (obj->curindex==1) { obj->network_loss_rate=loss_rate; return TRUE; } obj->latest=ms_new0(rtcpstatspoint_t, 1); obj->latest->timestamp=ms_time(0); obj->latest->bandwidth=up_bw; obj->latest->loss_percent=loss_rate; obj->latest->rtt=rtp_session_get_round_trip_propagation(obj->session); obj->rtcpstatspoint=bctbx_list_insert_sorted(obj->rtcpstatspoint, obj->latest, (bctbx_compare_func)sort_by_bandwidth); /*if the measure was 0% loss, reset to 0% every measures below it*/ if (obj->latest->loss_percent < 1e-5){ bctbx_list_t *it=obj->rtcpstatspoint; bctbx_list_t *latest_pos=bctbx_list_find(obj->rtcpstatspoint,obj->latest); while (it!=latest_pos->next){ ((rtcpstatspoint_t *)it->data)->loss_percent=0.f; it = it->next; } } ms_message("MSStatefulQosAnalyzer[%p]: one more %d: %f %f", obj, obj->curindex-1, obj->latest->bandwidth, obj->latest->loss_percent); if (bctbx_list_size(obj->rtcpstatspoint) > ESTIM_HISTORY){ size_t prev_size = bctbx_list_size(obj->rtcpstatspoint); /*clean everything which occurred 60 sec or more ago*/ time_t clear_time = ms_time(0) - 60; obj->rtcpstatspoint = bctbx_list_remove_custom(obj->rtcpstatspoint, (bctbx_compare_func)earlier_than, &clear_time); ms_message("MSStatefulQosAnalyzer[%p]: reached list maximum capacity " "(count=%u) --> Cleaned list (count=%u)", obj, (unsigned int)prev_size, (unsigned int)bctbx_list_size(obj->rtcpstatspoint)); } return TRUE; } } return FALSE; }