示例#1
0
文件: call_log.c 项目: 42p/linphone
static void copy_user_data_from_existing_logs(bctbx_list_t *existing_logs, bctbx_list_t *new_logs) {
	while (new_logs) {
		LinphoneCallLog *new_log = (LinphoneCallLog *)new_logs->data;
		copy_user_data_from_existing_log(existing_logs, new_log);
		new_logs = bctbx_list_next(new_logs);
	}
}
示例#2
0
int ms_ticker_detach(MSTicker *ticker,MSFilter *f){
	bctbx_list_t *sources=NULL;
	bctbx_list_t *filters=NULL;
	bctbx_list_t *it;

	if (f->ticker==NULL) {
		ms_message("Filter %s is not scheduled; nothing to do.",f->desc->name);
		return 0;
	}

	ms_mutex_lock(&ticker->lock);

	filters=ms_filter_find_neighbours(f);
	sources=get_sources(filters);
	if (sources==NULL){
		ms_fatal("No sources found around filter %s",f->desc->name);
		bctbx_list_free(filters);
		ms_mutex_unlock(&ticker->lock);
		return -1;
	}

	for(it=sources;it!=NULL;it=bctbx_list_next(it)){
		ticker->execution_list=bctbx_list_remove(ticker->execution_list,it->data);
	}
	ms_mutex_unlock(&ticker->lock);
	bctbx_list_for_each(filters,(void (*)(void*))call_postprocess);
	bctbx_list_free(filters);
	bctbx_list_free(sources);
	return 0;
}
示例#3
0
文件: friend.c 项目: 42p/linphone
bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf) {
	LinphoneVcard *vcard = NULL;
	bctbx_list_t *sipAddresses = NULL;
	bctbx_list_t *addresses = NULL;
	bctbx_list_t *iterator = NULL;

	if (!lf) {
		return NULL;
	}

	vcard = lf->vcard;
	if (!vcard) {
		return lf->uri ? bctbx_list_append(addresses, lf->uri) : NULL;
	}

	sipAddresses = linphone_vcard_get_sip_addresses(vcard);
	iterator = sipAddresses;
	while (iterator) {
		const char *sipAddress = (const char *)iterator->data;
		LinphoneAddress *addr = linphone_address_new(sipAddress);
		if (addr) {
			addresses = bctbx_list_append(addresses, addr);
		}
		iterator = bctbx_list_next(iterator);
	}
	if (sipAddresses) bctbx_list_free(sipAddresses);
	return addresses;
}
示例#4
0
文件: friend.c 项目: 42p/linphone
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 *)lists->data;
		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 = elem->next) {
						LinphoneProxyConfig *cfg = (LinphoneProxyConfig *)elem->data;
						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);
	}
}
示例#5
0
文件: friend.c 项目: 42p/linphone
void linphone_core_friends_storage_init(LinphoneCore *lc) {
	int ret;
	const char *errmsg;
	sqlite3 *db;
	const bctbx_list_t *friends_lists = NULL;

	linphone_core_friends_storage_close(lc);

	ret = _linphone_sqlite3_open(lc->friends_db_file, &db);
	if (ret != SQLITE_OK) {
		errmsg = sqlite3_errmsg(db);
		ms_error("Error in the opening: %s.\n", errmsg);
		sqlite3_close(db);
		return;
	}

	linphone_create_table(db);
	linphone_update_table(db);
	lc->friends_db = db;

	friends_lists = linphone_core_fetch_friends_lists_from_db(lc);
	if (friends_lists) {
		ms_warning("Replacing current default friend list by the one(s) from the database");
		lc->friends_lists = bctbx_list_free_with_data(lc->friends_lists, (void (*)(void*))linphone_friend_list_unref);
		lc->friends_lists = NULL;

		while (friends_lists) {
			LinphoneFriendList *list = (LinphoneFriendList *)friends_lists->data;
			linphone_core_add_friend_list(lc, list);
			friends_lists = bctbx_list_next(friends_lists);
		}
	}
}
示例#6
0
void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list, const char *vcard_file) {
	FILE *file = NULL;
	const bctbx_list_t *friends = linphone_friend_list_get_friends(list);

	file = fopen(vcard_file, "wb");
	if (file == NULL) {
		ms_warning("Could not write %s ! Maybe it is read-only. Contacts will not be saved.", vcard_file);
		return;
	}

#ifndef VCARD_ENABLED
	ms_error("vCard support wasn't enabled at compilation time");
#endif
	while (friends != NULL && friends->data != NULL) {
		LinphoneFriend *lf = (LinphoneFriend *)friends->data;
		LinphoneVcard *vcard = linphone_friend_get_vcard(lf);
		if (vcard) {
			const char *vcard_text = linphone_vcard_as_vcard4_string(vcard);
			fprintf(file, "%s", vcard_text);
		} else {
			ms_warning("Couldn't export friend %s because it doesn't have a vCard attached", linphone_address_as_string(linphone_friend_get_address(lf)));
		}
		friends = bctbx_list_next(friends);
	}

	fclose(file);
}
示例#7
0
bctbx_list_t* bctbx_list_copy_with_data(const bctbx_list_t* list, bctbx_list_copy_func copyfunc) {
    bctbx_list_t* copy=NULL;
    const bctbx_list_t* iter;
    for(iter=list; iter!=NULL; iter=bctbx_list_next(iter)) {
        copy=bctbx_list_append(copy,copyfunc(iter->data));
    }
    return copy;
}
示例#8
0
文件: friend.c 项目: 42p/linphone
void linphone_core_update_friends_subscriptions(LinphoneCore *lc, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
	bctbx_list_t *lists = lc->friends_lists;
	while (lists) {
		LinphoneFriendList *list = (LinphoneFriendList *)lists->data;
		linphone_friend_list_update_subscriptions(list, cfg, only_when_registered);
		lists = bctbx_list_next(lists);
	}
}
示例#9
0
bctbx_list_t* bctbx_list_copy(const bctbx_list_t* list) {
    bctbx_list_t* copy=NULL;
    const bctbx_list_t* iter;
    for(iter=list; iter!=NULL; iter=bctbx_list_next(iter)) {
        copy=bctbx_list_append(copy,iter->data);
    }
    return copy;
}
示例#10
0
文件: friend.c 项目: 42p/linphone
void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc) {
	bctbx_list_t *lists = lc->friends_lists;
	while (lists) {
		LinphoneFriendList *list = (LinphoneFriendList *)lists->data;
		linphone_friend_list_invalidate_subscriptions(list);
		lists = bctbx_list_next(lists);
	}
	lc->initial_subscribes_sent=FALSE;
}
示例#11
0
bctbx_list_t*  bctbx_list_concat(bctbx_list_t* first, bctbx_list_t* second) {
    bctbx_list_t* it=first;
    if (it==NULL) return second;
    if (second==NULL) return first;
    while(it->next!=NULL) it=bctbx_list_next(it);
    it->next=second;
    second->prev=it;
    return first;
}
示例#12
0
bctbx_list_t*  bctbx_list_append_link(bctbx_list_t* elem,bctbx_list_t *new_elem) {
    bctbx_list_t* it=elem;
    if (elem==NULL)  return new_elem;
    if (new_elem==NULL)  return elem;
    while (it->next!=NULL) it=bctbx_list_next(it);
    it->next=new_elem;
    new_elem->prev=it;
    return elem;
}
示例#13
0
文件: friend.c 项目: 42p/linphone
LinphoneFriend *linphone_core_find_friend(const LinphoneCore *lc, const LinphoneAddress *addr) {
	bctbx_list_t *lists = lc->friends_lists;
	LinphoneFriend *lf = NULL;
	while (lists && !lf) {
		LinphoneFriendList *list = (LinphoneFriendList *)lists->data;
		lf = linphone_friend_list_find_friend_by_address(list, addr);
		lists = bctbx_list_next(lists);
	}
	return lf;
}
示例#14
0
文件: call_log.c 项目: 42p/linphone
static void copy_user_data_from_existing_log(bctbx_list_t *existing_logs, LinphoneCallLog *log) {
	while (existing_logs) {
		LinphoneCallLog *existing_log = (LinphoneCallLog *)existing_logs->data;
		if (existing_log->storage_id == log->storage_id) {
			log->user_data = existing_log->user_data;
			break;
		}
		existing_logs = bctbx_list_next(existing_logs);
	}
}
示例#15
0
文件: friend.c 项目: 42p/linphone
LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key) {
	bctbx_list_t *lists = lc->friends_lists;
	LinphoneFriend *lf = NULL;
	while (lists && !lf) {
		LinphoneFriendList *list = (LinphoneFriendList *)lists->data;
		lf = linphone_friend_list_find_friend_by_ref_key(list, key);
		lists = bctbx_list_next(lists);
	}
	return lf;
}
示例#16
0
文件: friend.c 项目: 42p/linphone
LinphoneFriend *linphone_core_find_friend_by_inc_subscribe(const LinphoneCore *lc, SalOp *op) {
	bctbx_list_t *lists = lc->friends_lists;
	LinphoneFriend *lf = NULL;
	while (lists && !lf) {
		LinphoneFriendList *list = (LinphoneFriendList *)lists->data;
		lf = linphone_friend_list_find_friend_by_inc_subscribe(list, op);
		lists = bctbx_list_next(lists);
	}
	return lf;
}
示例#17
0
/**
 * Clear all authentication information.
**/
void linphone_core_clear_all_auth_info(LinphoneCore *lc){
	bctbx_list_t *elem;
	int i;
	for(i=0,elem=lc->auth_info;elem!=NULL;elem=bctbx_list_next(elem),i++){
		LinphoneAuthInfo *info=(LinphoneAuthInfo*)elem->data;
		linphone_auth_info_destroy(info);
		linphone_auth_info_write_config(lc->config,NULL,i);
	}
	bctbx_list_free(lc->auth_info);
	lc->auth_info=NULL;
}
示例#18
0
static void write_auth_infos(LinphoneCore *lc){
	bctbx_list_t *elem;
	int i;

	if (!linphone_core_ready(lc)) return;
	if (!lc->sip_conf.save_auth_info) return;
	for(elem=lc->auth_info,i=0;elem!=NULL;elem=bctbx_list_next(elem),i++){
		LinphoneAuthInfo *ai=(LinphoneAuthInfo*)(elem->data);
		linphone_auth_info_write_config(lc->config,ai,i);
	}
	linphone_auth_info_write_config(lc->config,NULL,i); /* mark the end */
}
示例#19
0
文件: friend.c 项目: 42p/linphone
void linphone_core_write_friends_config(LinphoneCore* lc) {
	bctbx_list_t *elem;
	int i;
	int store_friends;

	if (! linphone_core_ready(lc)) return; /*dont write config when reading it !*/
	store_friends = lp_config_get_int(lc->config, "misc", "store_friends", 1);
	if (store_friends) {
		for (elem=linphone_core_get_default_friend_list(lc)->friends,i=0; elem!=NULL; elem=bctbx_list_next(elem),i++){
			linphone_friend_write_to_config_file(lc->config,(LinphoneFriend*)elem->data,i);
		}
		linphone_friend_write_to_config_file(lc->config,NULL,i);	/* set the end */
	}
}
示例#20
0
static void carddav_clean(void) {  // This is to ensure the content of the test addressbook is in the correct state for the following tests
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
	bctbx_list_t *friends = NULL;
	bctbx_list_t *friends_iterator = NULL;
	LinphoneFriend *lf = NULL;
	LinphoneVcard *lvc = NULL;

	linphone_friend_list_cbs_set_user_data(cbs, stats);
	linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
	linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted);
	linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
	linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);

	linphone_friend_list_synchronize_friends_from_server(lfl);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");
	stats->sync_done_count = 0;

	friends = bctbx_list_copy(lfl->friends);
	friends_iterator = friends;
	while (friends_iterator) {
		LinphoneFriend *lf = (LinphoneFriend *)friends_iterator->data;
		linphone_friend_list_remove_friend(lfl, lf);
		wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
		BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");
		stats->sync_done_count = 0;
		stats->removed_contact_count = 0;
		friends_iterator = bctbx_list_next(friends_iterator);
	}
	bctbx_list_free(friends);

	lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:[email protected]\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
	linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf");
	lf = linphone_friend_new_from_vcard(lvc);
	linphone_friend_list_add_friend(lfl, lf);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");

	ms_free(stats);
	linphone_friend_unref(lf);
	linphone_friend_list_unref(lfl);
	linphone_core_manager_destroy(manager);
}
示例#21
0
bctbx_list_t* bctbx_list_insert(bctbx_list_t* list, bctbx_list_t* before, void *data) {
    bctbx_list_t* elem;
    if (list==NULL || before==NULL) return bctbx_list_append(list,data);
    for(elem=list; elem!=NULL; elem=bctbx_list_next(elem)) {
        if (elem==before) {
            if (elem->prev==NULL)
                return bctbx_list_prepend(list,data);
            else {
                bctbx_list_t* nelem=bctbx_list_new(data);
                nelem->prev=elem->prev;
                nelem->next=elem;
                elem->prev->next=nelem;
                elem->prev=nelem;
            }
        }
    }
    return list;
}
示例#22
0
void bctbx_shm_close(void *mem){
#ifdef BCTBX_WINDOWS_DESKTOP
	bctbx_list_t *elem;
	for(elem=maplist;elem;elem=bctbx_list_next(elem)){
		MapInfo *i=(MapInfo*)bctbx_list_get_data(elem);
		if (i->mem==mem){
			CloseHandle(i->h);
			UnmapViewOfFile(mem);
			bctbx_free(i);
			maplist=bctbx_list_erase_link(maplist,elem);
			return;
		}
	}
	bctbx_error("No shared memory at %p was found.",mem);
#else
	bctbx_error("%s not supported!", __FUNCTION__);
#endif
}
示例#23
0
void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
	bctbx_list_t *dirty_friends = list->dirty_friends_to_update;

	while (dirty_friends) {
		LinphoneCardDavContext *cdc = linphone_carddav_context_new(list);
		if (cdc) {
			LinphoneFriend *lf = (LinphoneFriend *)dirty_friends->data;
			cdc->sync_done_cb = carddav_done;
			if (lf) {
				if (cdc->friend_list->cbs->sync_state_changed_cb) {
					cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL);
				}
				linphone_carddav_put_vcard(cdc, lf);
			}
		}
		dirty_friends = bctbx_list_next(dirty_friends);
	}
	list->dirty_friends_to_update = bctbx_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref);
}
示例#24
0
static void carddav_server_to_client_and_client_to_sever_sync(void) {
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
	LinphoneVcard *lvc1 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n");
	LinphoneFriend *lf1 = linphone_friend_new_from_vcard(lvc1);
	LinphoneVcard *lvc2 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n");
	LinphoneFriend *lf2 = linphone_friend_new_from_vcard(lvc2);
	bctbx_list_t *friends = NULL, *friends_iterator = NULL;

	linphone_friend_list_cbs_set_user_data(cbs, stats);
	linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
	linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted);
	linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
	linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);

	linphone_friend_list_add_friend(lfl, lf1);
	linphone_friend_unref(lf1);
	linphone_friend_list_synchronize_friends_from_server(lfl);
	linphone_friend_list_add_friend(lfl, lf2);
	linphone_friend_unref(lf2);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 3, 15000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 3, int, "%i");

	stats->sync_done_count = 0;
	friends = bctbx_list_copy(lfl->friends);
	friends_iterator = friends;
	while (friends_iterator) {
		LinphoneFriend *lf = (LinphoneFriend *)friends_iterator->data;
		if (lf && strcmp(linphone_friend_get_name(lf), "Sylvain Berfini") != 0) {
			linphone_friend_list_remove_friend(lfl, lf);
			wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
			BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");
			stats->sync_done_count = 0;
		}
		friends_iterator = bctbx_list_next(friends_iterator);
	}
示例#25
0
int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *list, const char *vcard_buffer) {
	bctbx_list_t *vcards = NULL;
	bctbx_list_t *vcards_iterator = NULL;
	int count = 0;

#ifndef VCARD_ENABLED
	ms_error("vCard support wasn't enabled at compilation time");
	return -1;
#endif
	if (!list) {
		ms_error("Can't import into a NULL list");
		return -1;
	}
	
	vcards = linphone_vcard_list_from_vcard4_buffer(list->lc->vcard_context, vcard_buffer);
	vcards_iterator = vcards;
	if (!vcards) {
		ms_error("Failed to parse the buffer");
		return -1;
	}

	while (vcards_iterator != NULL && vcards_iterator->data != NULL) {
		LinphoneVcard *vcard = (LinphoneVcard *)vcards_iterator->data;
		LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard);
		if (lf) {
			if (LinphoneFriendListOK == linphone_friend_list_import_friend(list, lf, TRUE)) {
				count++;
			}
			linphone_friend_unref(lf);
		} else {
			linphone_vcard_free(vcard);
		}
		vcards_iterator = bctbx_list_next(vcards_iterator);
	}
	bctbx_list_free(vcards);
	linphone_core_store_friends_list_in_db(list->lc, list);
	return count;
}