コード例 #1
0
ファイル: eventapi_tester.c プロジェクト: 42p/linphone
static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTestType refresh_type) {
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
	LinphoneContent* content;
	LinphoneEvent *lev;
	int expires= refresh_type!=NoRefresh ? 4 : 600;
	bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc);

	lcs=bctbx_list_append(lcs,pauline->lc);

	if (refresh_type==ManualRefresh){
		lp_config_set_int(marie->lc->config,"sip","refresh_generic_subscribe",0);
	}

	content = linphone_core_create_content(marie->lc);
	linphone_content_set_type(content,"application");
	linphone_content_set_subtype(content,"somexml");
	linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content));

	lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",expires,content);

	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,3000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000));

	/*make sure marie receives first notification before terminating*/
	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000));

	if (refresh_type==AutoRefresh){
		wait_for_list(lcs,NULL,0,6000);
		BC_ASSERT_EQUAL(linphone_event_get_subscription_state(pauline->lev), LinphoneSubscriptionActive, int, "%d");
	}else if (refresh_type==ManualRefresh){
コード例 #2
0
ファイル: eventapi_tester.c プロジェクト: 42p/linphone
static void subscribe_test_declined(void) {
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
	LinphoneContent* content;
	LinphoneEvent *lev;
	const LinphoneErrorInfo *ei;
	bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc);
	lcs=bctbx_list_append(lcs,pauline->lc);

	content = linphone_core_create_content(marie->lc);
	linphone_content_set_type(content,"application");
	linphone_content_set_subtype(content,"somexml");
	linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content));

	pauline->decline_subscribe=TRUE;

	lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,content);
	linphone_event_ref(lev);

	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionError,1,21000));/*yes flexisip may wait 20 secs in case of forking*/
	ei=linphone_event_get_error_info(lev);
	BC_ASSERT_PTR_NOT_NULL(ei);
	if (ei){
		BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),603, int, "%d");
		BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(ei));
	}
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));

	linphone_content_unref(content);
	linphone_event_unref(lev);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
コード例 #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
ファイル: video_tester.c プロジェクト: 42p/linphone
bool_t wait_for_three_cores(LinphoneCore *lc1, LinphoneCore *lc2, LinphoneCore *lc3, int timeout) {
	bctbx_list_t *lcs = NULL;
	bool_t result;
	int dummy = 0;
	if (lc1) lcs = bctbx_list_append(lcs, lc1);
	if (lc2) lcs = bctbx_list_append(lcs, lc2);
	if (lc3) lcs = bctbx_list_append(lcs, lc3);
	result = wait_for_list(lcs, &dummy, 1, timeout);
	bctbx_list_free(lcs);
	return result;
}
コード例 #5
0
ファイル: friendlist.c プロジェクト: smking1122/heqinphone
LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) {
	if (!lf->uri || lf->friend_list) {
		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 LinphoneFriendListInvalidFriend;
	}
	lf->friend_list = list;
	lf->lc = list->lc;
	list->friends = bctbx_list_append(list->friends, linphone_friend_ref(lf));
	if (synchronize) {
		list->dirty_friends_to_update = bctbx_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf));
	}
	return LinphoneFriendListOK;
}
コード例 #6
0
bctbx_list_t* bctbx_list_insert_sorted(bctbx_list_t* list, void *data, bctbx_compare_func compare_func) {
    bctbx_list_t* it,*previt=NULL;
    bctbx_list_t* nelem;
    bctbx_list_t* ret=list;
    if (list==NULL) return bctbx_list_append(list,data);
    else {
        nelem=bctbx_list_new(data);
        for(it=list; it!=NULL; it=it->next) {
            previt=it;
            if (compare_func(data,it->data)<=0) {
                nelem->prev=it->prev;
                nelem->next=it;
                if (it->prev!=NULL)
                    it->prev->next=nelem;
                else {
                    ret=nelem;
                }
                it->prev=nelem;
                return ret;
            }
        }
        previt->next=nelem;
        nelem->prev=previt;
    }
    return ret;
}
コード例 #7
0
ファイル: friend.c プロジェクト: 42p/linphone
/* DB layout:
 * | 0  | storage_id
 * | 1  | friend_list_id
 * | 2  | sip_uri
 * | 3  | subscribe_policy
 * | 4  | send_subscribe
 * | 5  | ref_key
 * | 6  | vCard
 * | 7  | vCard eTag
 * | 8  | vCard URL
 * | 9  | presence_received
 */
static int create_friend(void *data, int argc, char **argv, char **colName) {
	LinphoneVcardContext *context = (LinphoneVcardContext *)data;
	bctbx_list_t **list = (bctbx_list_t **)linphone_vcard_context_get_user_data(context);
	LinphoneFriend *lf = NULL;
	LinphoneVcard *vcard = NULL;
	unsigned int storage_id = (unsigned int)atoi(argv[0]);

	vcard = linphone_vcard_context_get_vcard_from_buffer(context, argv[6]);
	if (vcard) {
		linphone_vcard_set_etag(vcard, argv[7]);
		linphone_vcard_set_url(vcard, argv[8]);
		lf = linphone_friend_new_from_vcard(vcard);
	}
	if (!lf) {
		LinphoneAddress *addr = linphone_address_new(argv[2]);
		lf = linphone_friend_new();
		linphone_friend_set_address(lf, addr);
		linphone_address_unref(addr);
	}
	linphone_friend_set_inc_subscribe_policy(lf, atoi(argv[3]));
	linphone_friend_send_subscribe(lf, atoi(argv[4]));
	linphone_friend_set_ref_key(lf, ms_strdup(argv[5]));
	lf->presence_received = atoi(argv[9]);
	lf->storage_id = storage_id;

	*list = bctbx_list_append(*list, linphone_friend_ref(lf));
	linphone_friend_unref(lf);
	return 0;
}
コード例 #8
0
ファイル: ldapprovider.c プロジェクト: CTA/linphone
static LinphoneLDAPContactSearch* linphone_ldap_contact_provider_begin_search ( LinphoneLDAPContactProvider* obj,
		const char* predicate,
		ContactSearchCallback cb,
		void* cb_data )
{
	bool_t connected = obj->connected;
	LinphoneLDAPContactSearch* request;

	// if we're not yet connected, bind
	if( !connected ) {
		if( !obj->bind_thread ) linphone_ldap_contact_provider_bind(obj);
	}

	request = linphone_ldap_contact_search_create( obj, predicate, cb, cb_data );

	if( connected ){
		int ret = linphone_ldap_contact_provider_perform_search(obj, request);
		ms_message ( "Created search %d for '%s', msgid %d, @%p", obj->req_count, predicate, request->msgid, request );
		if( ret != LDAP_SUCCESS ){
			belle_sip_object_unref(request);
			request = NULL;
		}
	} else {
		ms_message("Delayed search, wait for connection");
	}

	if( request != NULL ) {
		obj->requests = bctbx_list_append ( obj->requests, request );
		obj->req_count++;
	}

	return request;
}
コード例 #9
0
ファイル: sal_impl.c プロジェクト: CTA/linphone
void sal_add_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){
		ctx->supported_tags=bctbx_list_append(ctx->supported_tags,ms_strdup(tag));
		make_supported_header(ctx);
	}

}
コード例 #10
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;
}
コード例 #11
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;
}
コード例 #12
0
ファイル: sal.c プロジェクト: artur/linphone
void sal_op_add_route_address(SalOp *op, const SalAddress *address){
	SalOpBase* op_base = (SalOpBase*)op;
	if (op_base->route_addresses) {
		op_base->route_addresses=bctbx_list_append(op_base->route_addresses,(void*)sal_address_clone(address));
	} else {
		sal_op_set_route_address(op,address);
	}
}
コード例 #13
0
ファイル: nat_policy.c プロジェクト: 42p/linphone
static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config, int index) {
	char *section;
	bctbx_list_t *l = NULL;

	section = belle_sip_strdup_printf("nat_policy_%i", index);
	lp_config_set_string(config, section, "ref", policy->ref);
	lp_config_set_string(config, section, "stun_server", policy->stun_server);
	lp_config_set_string(config, section, "stun_server_username", policy->stun_server_username);
	if (linphone_nat_policy_upnp_enabled(policy)) {
		l = bctbx_list_append(l, "upnp");
	} else {
		if (linphone_nat_policy_stun_enabled(policy)) l = bctbx_list_append(l, "stun");
		if (linphone_nat_policy_turn_enabled(policy)) l = bctbx_list_append(l, "turn");
		if (linphone_nat_policy_ice_enabled(policy)) l = bctbx_list_append(l, "ice");
	}
	lp_config_set_string_list(config, section, "protocols", l);
	belle_sip_free(section);
	bctbx_list_free(l);
}
コード例 #14
0
ファイル: msticker.c プロジェクト: duh931/mediastreamer2
static bctbx_list_t *get_sources(bctbx_list_t *filters){
	bctbx_list_t *sources=NULL;
	MSFilter *f;
	for(;filters!=NULL;filters=filters->next){
		f=(MSFilter*)filters->data;
		if (f->desc->ninputs==0){
			sources=bctbx_list_append(sources,f);
		}
	}
	return sources;
}
コード例 #15
0
ファイル: presence_tester.c プロジェクト: CTA/linphone
static void subscribe_presence_expired(void){
	LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
	LinphoneFriend *lf;
	bctbx_list_t *lcs = NULL;

	lcs = bctbx_list_append(lcs, marie->lc);
	lcs = bctbx_list_append(lcs, pauline1->lc);

	lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 10);

	lf = linphone_core_create_friend(marie->lc);
	linphone_friend_set_address(lf, pauline1->identity);
	linphone_friend_enable_subscribes(lf, TRUE);

	linphone_core_add_friend(marie->lc, lf);
	linphone_friend_unref(lf);
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_NewSubscriptionRequest,1, 5000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 2000));

	lf = linphone_core_find_friend(pauline1->lc, marie->identity);
	BC_ASSERT_PTR_NOT_NULL(lf);
	if (lf) {
		BC_ASSERT_PTR_NOT_NULL(lf->insubs);

		/*marie comes offline suddenly*/
		linphone_core_set_network_reachable(marie->lc, FALSE);
		/*after a certain time, pauline shall see the incoming SUBSCRIBE expired*/
		wait_for_list(lcs,NULL, 0, 11000);
		BC_ASSERT_PTR_NULL(lf->insubs);

		/*just make network reachable so that marie can unregister properly*/
		linphone_core_set_network_reachable(marie->lc, TRUE);
		BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,2, 10000));
	}
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline1);

	bctbx_list_free(lcs);
}
コード例 #16
0
ファイル: friend.c プロジェクト: 42p/linphone
void linphone_friend_done(LinphoneFriend *fr) {
	ms_return_if_fail(fr);
	if (!fr->lc || !fr->friend_list) return;
	linphone_friend_apply(fr, fr->lc);
	linphone_friend_save(fr, fr->lc);

	if (fr && fr->vcard) {
		if (linphone_vcard_compare_md5_hash(fr->vcard) != 0) {
			ms_debug("vCard's md5 has changed, mark friend as dirty");
			fr->friend_list->dirty_friends_to_update = bctbx_list_append(fr->friend_list->dirty_friends_to_update, linphone_friend_ref(fr));
		}
	}
}
コード例 #17
0
ファイル: presence_tester.c プロジェクト: CTA/linphone
static void subscribe_presence_forked(void){
	LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_tcp_rc" : "pauline_tcp_rc");
	LinphoneCoreManager* pauline2 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_tcp_rc" : "pauline_tcp_rc");
	LinphoneFriend *lf;
	bctbx_list_t *lcs = NULL;

	lcs = bctbx_list_append(lcs, marie->lc);
	lcs = bctbx_list_append(lcs, pauline1->lc);
	lcs = bctbx_list_append(lcs, pauline2->lc);

	lf = linphone_core_create_friend(marie->lc);
	linphone_friend_set_address(lf, pauline1->identity);
	linphone_friend_enable_subscribes(lf, TRUE);

	linphone_core_add_friend(marie->lc, lf);
	linphone_friend_unref(lf);

	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_NewSubscriptionRequest,1, 10000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline2->stat.number_of_NewSubscriptionRequest,1, 2000));

	/*we should get only one notify*/
	BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 10000));
	BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,2, 2000));

	/*marie also shall receive two SUBSCRIBEs from the two paulines, but won't be notified to the app since
	 Marie set Pauline as a friend.*/
	BC_ASSERT_EQUAL(marie->stat.number_of_NewSubscriptionRequest, 0, int, "%d");
	/*and the two paulines shall be notified of marie's presence*/
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphonePresenceActivityOnline,1, 3000));
	BC_ASSERT_TRUE(wait_for_list(lcs,&pauline2->stat.number_of_LinphonePresenceActivityOnline,1, 2000));

	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline1);
	linphone_core_manager_destroy(pauline2);

	bctbx_list_free(lcs);
}
コード例 #18
0
bctbx_list_t *ms_parse_equalizer_string(const char *str) {
    bctbx_list_t *eq_list = NULL;
	do {
		int bytes;
		MSEqualizerGain g;
		if (sscanf(str, "%f:%f:%f %n", &g.frequency, &g.gain, &g.width, &bytes) == 3) {
			MSEqualizerGain *gain = ms_new(MSEqualizerGain, 1);
			*gain = g;
			eq_list = bctbx_list_append(eq_list, gain);
			str += bytes;
		} else break;
	} while (1);
	return eq_list;
}
コード例 #19
0
ファイル: sal.c プロジェクト: artur/linphone
void sal_op_set_route(SalOp *op, const char *route){
	char* route_string=(void *)0;
	SalOpBase* op_base = (SalOpBase*)op;
	if (op_base->route_addresses) {
		bctbx_list_for_each(op_base->route_addresses,(void (*)(void *))sal_address_destroy);
		op_base->route_addresses=bctbx_list_free(op_base->route_addresses);
	}
	if (route) {
		op_base->route_addresses=bctbx_list_append(NULL,NULL);
		assign_address((SalAddress**)&(op_base->route_addresses->data),route);
		route_string=sal_address_as_string((SalAddress*)op_base->route_addresses->data); \
	}
	assign_string(&op_base->route,route_string); \
	if(route_string) ms_free(route_string);
}
コード例 #20
0
ファイル: friend.c プロジェクト: 42p/linphone
/* DB layout:
 * | 0  | storage_id
 * | 1  | display_name
 * | 2  | rls_uri
 * | 3  | uri
 * | 4  | revision
 */
static int create_friend_list(void *data, int argc, char **argv, char **colName) {
	bctbx_list_t **list = (bctbx_list_t **)data;
	unsigned int storage_id = (unsigned int)atoi(argv[0]);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(NULL);

	lfl->storage_id = storage_id;
	linphone_friend_list_set_display_name(lfl, argv[1]);
	linphone_friend_list_set_rls_uri(lfl, argv[2]);
	linphone_friend_list_set_uri(lfl, argv[3]);
	lfl->revision = atoi(argv[4]);

	*list = bctbx_list_append(*list, linphone_friend_list_ref(lfl));
	linphone_friend_list_unref(lfl);
	return 0;
}
コード例 #21
0
ファイル: sal_impl.c プロジェクト: CTA/linphone
void sal_set_supported_tags(Sal *ctx, const char* tags){
	ctx->supported_tags=bctbx_list_free_with_data(ctx->supported_tags,ms_free);
	if (tags){
		char *iter;
		char *buffer=ms_strdup(tags);
		char *tag;
		char *context=NULL;
		iter=buffer;
		while((tag=strtok_r(iter,", ",&context))!=NULL){
			iter=NULL;
			ctx->supported_tags=bctbx_list_append(ctx->supported_tags,ms_strdup(tag));
		}
		ms_free(buffer);
	}
	make_supported_header(ctx);
}
コード例 #22
0
ファイル: call_log.c プロジェクト: 42p/linphone
/* DB layout:
 * | 0  | storage_id
 * | 1  | from
 * | 2  | to
 * | 3  | direction flag
 * | 4  | duration
 * | 5  | start date time (time_t)
 * | 6  | connected date time (time_t)
 * | 7  | status
 * | 8  | video enabled (1 or 0)
 * | 9  | quality
 * | 10 | call_id
 * | 11 | refkey
 */
static int create_call_log(void *data, int argc, char **argv, char **colName) {
	bctbx_list_t **list = (bctbx_list_t **)data;
	LinphoneAddress *from;
	LinphoneAddress *to;
	LinphoneCallDir dir;
	LinphoneCallLog *log;

	unsigned int storage_id = (unsigned int)atoi(argv[0]);
	from = linphone_address_new(argv[1]);
	to = linphone_address_new(argv[2]);
	
	if (from == NULL || to == NULL) goto error;
	
	dir = (LinphoneCallDir) atoi(argv[3]);
	log = linphone_call_log_new(dir, from, to);

	log->storage_id = storage_id;
	log->duration = atoi(argv[4]);
	log->start_date_time = (time_t)atol(argv[5]);
	set_call_log_date(log,log->start_date_time);
	log->connected_date_time = (time_t)atol(argv[6]);
	log->status = (LinphoneCallStatus) atoi(argv[7]);
	log->video_enabled = atoi(argv[8]) == 1;
	log->quality = (float)atof(argv[9]);

	if (argc > 10) {
		if (argv[10] != NULL) {
			log->call_id = ms_strdup(argv[10]);
		}
		if (argv[10] != NULL) {
			log->refkey = ms_strdup(argv[11]);
		}
	}

	*list = bctbx_list_append(*list, log);
	return 0;
	
error:
	if (from){
		linphone_address_destroy(from);
	}
	if (to){
		linphone_address_destroy(to);
	}
	ms_error("Bad call log at storage_id %u", storage_id);
	return 0;
}
コード例 #23
0
void *bctbx_shm_open(unsigned int keyid, int size, int create){
#ifdef BCTBX_WINDOWS_DESKTOP
	HANDLE h;
	char name[64];
	void *buf;

	snprintf(name,sizeof(name),"%x",keyid);
	if (create){
		h = CreateFileMapping(
			INVALID_HANDLE_VALUE,    // use paging file
			NULL,                    // default security
			PAGE_READWRITE,          // read/write access
			0,                       // maximum object size (high-order DWORD)
			size,                // maximum object size (low-order DWORD)
			name);                 // name of mapping object
	}else{
		h = OpenFileMapping(
			FILE_MAP_ALL_ACCESS,   // read/write access
			FALSE,                 // do not inherit the name
			name);               // name of mapping object
	}
	if (h==(HANDLE)-1) {
		bctbx_error("Fail to open file mapping (create=%i)",create);
		return NULL;
	}
	buf = (LPTSTR) MapViewOfFile(h, // handle to map object
		FILE_MAP_ALL_ACCESS,  // read/write permission
		0,
		0,
		size);
	if (buf!=NULL){
		MapInfo *i=(MapInfo*)bctbx_new(MapInfo,1);
		i->h=h;
		i->mem=buf;
		maplist=bctbx_list_append(maplist,i);
	}else{
		CloseHandle(h);
		bctbx_error("MapViewOfFile failed");
	}
	return buf;
#else
	bctbx_error("%s not supported!", __FUNCTION__);
	return NULL;
#endif
}
コード例 #24
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;
}
コード例 #25
0
ファイル: call_log.c プロジェクト: 42p/linphone
void call_logs_read_from_config_file(LinphoneCore *lc){
	char logsection[32];
	int i;
	const char *tmp;
	uint64_t sec;
	LpConfig *cfg=lc->config;
	for(i=0;;++i){
		snprintf(logsection,sizeof(logsection),"call_log_%i",i);
		if (lp_config_has_section(cfg,logsection)){
			LinphoneCallLog *cl;
			LinphoneAddress *from=NULL,*to=NULL;
			tmp=lp_config_get_string(cfg,logsection,"from",NULL);
			if (tmp) from=linphone_address_new(tmp);
			tmp=lp_config_get_string(cfg,logsection,"to",NULL);
			if (tmp) to=linphone_address_new(tmp);
			if (!from || !to)
				continue;
			cl=linphone_call_log_new(lp_config_get_int(cfg,logsection,"dir",0),from,to);
			cl->status=lp_config_get_int(cfg,logsection,"status",0);
			sec=lp_config_get_int64(cfg,logsection,"start_date_time",0);
			if (sec) {
				/*new call log format with date expressed in seconds */
				cl->start_date_time=(time_t)sec;
				set_call_log_date(cl,cl->start_date_time);
			}else{
				tmp=lp_config_get_string(cfg,logsection,"start_date",NULL);
				if (tmp) {
					strncpy(cl->start_date,tmp,sizeof(cl->start_date));
					cl->start_date_time=string_to_time(cl->start_date);
				}
			}
			cl->duration=lp_config_get_int(cfg,logsection,"duration",0);
			tmp=lp_config_get_string(cfg,logsection,"refkey",NULL);
			if (tmp) cl->refkey=ms_strdup(tmp);
			cl->quality=lp_config_get_float(cfg,logsection,"quality",-1);
			cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0);
			tmp=lp_config_get_string(cfg,logsection,"call_id",NULL);
			if (tmp) cl->call_id=ms_strdup(tmp);
			lc->call_logs=bctbx_list_append(lc->call_logs,cl);
		}else break;
	}
}
コード例 #26
0
ファイル: friend.c プロジェクト: 42p/linphone
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op){
	/*ownership of the op is transfered from sal to the LinphoneFriend*/
	lf->insubs = bctbx_list_append(lf->insubs, op);
}
コード例 #27
0
ファイル: sal_impl.c プロジェクト: CTA/linphone
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;
	}
}
コード例 #28
0
ファイル: ldapprovider.c プロジェクト: CTA/linphone
static void linphone_ldap_contact_provider_handle_search_result( LinphoneLDAPContactProvider* obj, LinphoneLDAPContactSearch* req, LDAPMessage* message )
{
	int msgtype = ldap_msgtype(message);

	switch(msgtype){

	case LDAP_RES_SEARCH_ENTRY:
	case LDAP_RES_EXTENDED:
	{
		LDAPMessage *entry = ldap_first_entry(obj->ld, message);
		LinphoneCore*   lc = LINPHONE_CONTACT_PROVIDER(obj)->lc;

		while( entry != NULL ){

			struct LDAPFriendData ldap_data = {0};
			bool_t contact_complete = FALSE;
			BerElement*  ber = NULL;
			char*       attr = ldap_first_attribute(obj->ld, entry, &ber);

			while( attr ){
				struct berval** values = ldap_get_values_len(obj->ld, entry, attr);
				struct berval**     it = values;

				while( values && *it && (*it)->bv_val && (*it)->bv_len )
				{
					contact_complete = linphone_ldap_contact_provider_complete_contact(obj, &ldap_data, attr, (*it)->bv_val);
					if( contact_complete ) break;

					it++;
				}

				if( values ) ldap_value_free_len(values);
				ldap_memfree(attr);

				if( contact_complete ) break;

				attr = ldap_next_attribute(obj->ld, entry, ber);
			}

			if( contact_complete ) {
				LinphoneAddress* la = linphone_core_interpret_url(lc, ldap_data.sip);
				if( la ){
					LinphoneFriend* lf = linphone_core_create_friend(lc);
					linphone_friend_set_address(lf, la);
					linphone_friend_set_name(lf, ldap_data.name);
					req->found_entries = bctbx_list_append(req->found_entries, lf);
					req->found_count++;
					//ms_message("Added friend %s / %s", ldap_data.name, ldap_data.sip);
					ms_free(ldap_data.sip);
					ms_free(ldap_data.name);
					linphone_address_destroy(la);
				}
			}

			if( ber ) ber_free(ber, 0);

			entry = ldap_next_entry(obj->ld, entry);
		}
	}
	break;

	case LDAP_RES_SEARCH_RESULT:
	{
		// this one is received when a request is finished
		req->complete = TRUE;
		linphone_contact_search_invoke_cb(LINPHONE_CONTACT_SEARCH(req), req->found_entries);
	}
	break;


	default: ms_message("[LDAP] Unhandled message type %x", msgtype); break;
	}
}
コード例 #29
0
ファイル: stun_tester.c プロジェクト: 42p/linphone
static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled, bool_t rtcp_mux_enabled) {
	LinphoneCoreManager *marie;
	LinphoneCoreManager *pauline;
	LinphoneCall *lcall;
	LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection;
	LinphoneMediaDirection expected_video_dir = LinphoneMediaDirectionInactive;
	bctbx_list_t *lcs = NULL;

	marie = linphone_core_manager_new("marie_rc");
	lcs = bctbx_list_append(lcs, marie->lc);
	pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
	lcs = bctbx_list_append(lcs, pauline->lc);

	configure_nat_policy(marie->lc, caller_turn_enabled);
	configure_nat_policy(pauline->lc, callee_turn_enabled);
	if (forced_relay == TRUE) {
		linphone_core_enable_forced_ice_relay(marie->lc, TRUE);
		linphone_core_enable_forced_ice_relay(pauline->lc, TRUE);
		linphone_core_enable_short_turn_refresh(marie->lc, TRUE);
		linphone_core_enable_short_turn_refresh(pauline->lc, TRUE);
		expected_ice_state = LinphoneIceStateRelayConnection;
	}
	if (rtcp_mux_enabled == TRUE) {
		lp_config_set_int(linphone_core_get_config(marie->lc), "rtp", "rtcp_mux", 1);
		lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1);
	}

	if (video_enabled) {
#ifdef VIDEO_ENABLED
		video_call_base_2(marie, pauline, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE);
		expected_video_dir = LinphoneMediaDirectionSendRecv;
#endif
	} else {
		BC_ASSERT_TRUE(call(marie, pauline));
	}

	/* Wait for the ICE reINVITE to complete */
	BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
	BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
	BC_ASSERT_TRUE(check_ice(pauline, marie, expected_ice_state));
	check_nb_media_starts(pauline, marie, 1, 1);
	check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, expected_video_dir);
	check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, expected_video_dir);
	liblinphone_tester_check_rtcp(marie, pauline);
	lcall = linphone_core_get_current_call(marie->lc);
	BC_ASSERT_PTR_NOT_NULL(lcall->ice_session);
	if (lcall->ice_session != NULL) {
		IceCheckList *cl = ice_session_check_list(lcall->ice_session, 0);
		BC_ASSERT_PTR_NOT_NULL(cl);
		if (cl != NULL) {
			check_turn_context_statistics(cl->rtp_turn_context, forced_relay);
			if (!rtcp_mux_enabled) check_turn_context_statistics(cl->rtcp_turn_context, forced_relay);
		}
	}

	end_call(marie, pauline);

	linphone_core_manager_destroy(pauline);
	linphone_core_manager_destroy(marie);
	bctbx_list_free(lcs);
}
コード例 #30
0
ファイル: sipsetup.c プロジェクト: JonathanRadesa/linphone
void sip_setup_register(SipSetup *ss){
	registered_sip_setups=bctbx_list_append(registered_sip_setups,ss);
}