Exemple #1
0
LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
	LinphoneCall *call=ms_new0(LinphoneCall,1);
	char *from_str;

	call->dir=LinphoneCallIncoming;
	sal_op_set_user_pointer(op,call);
	call->op=op;
	call->core=lc;

	if (lc->sip_conf.ping_with_options){
		/*the following sends an option request back to the caller so that
		 we get a chance to discover our nat'd address before answering.*/
		call->ping_op=sal_op_new(lc->sal);
		from_str=linphone_address_as_string(from);
		sal_op_set_route(call->ping_op,sal_op_get_network_origin(call->op));
		sal_op_set_user_pointer(call->ping_op,call);
		sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str);
		ms_free(from_str);
	}
	
	linphone_address_clean(from);
	linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip);
	linphone_call_init_common(call, from, to);
	call->params.has_video=linphone_core_video_enabled(lc);
	call->localdesc=create_local_media_description (lc,call);
	call->camera_active=call->params.has_video;
	if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun)
		linphone_core_run_stun_tests(call->core,call);
	discover_mtu(lc,linphone_address_get_domain(from));
	return call;
}
Exemple #2
0
static LinphoneEvent * linphone_event_new_base(LinphoneCore *lc, LinphoneSubscriptionDir dir, const char *name, SalOp *op){
	LinphoneEvent *lev=belle_sip_object_new(LinphoneEvent);
	lev->lc=lc;
	lev->dir=dir;
	lev->op=op;
	lev->name=ms_strdup(name);
	sal_op_set_user_pointer(lev->op,lev);
	return lev;
}
Exemple #3
0
void sal_op_release(SalOp *op){
	/*if in terminating state, keep this state because it means we are waiting for a response to be able to terminate the operation.*/
	if (op->state!=SalOpStateTerminating)
		op->state=SalOpStateTerminated;
	sal_op_set_user_pointer(op,NULL);/*mandatory because releasing op doesn't not mean freeing op. Make sure back pointer will not be used later*/
	if (op->refresher) {
		belle_sip_refresher_stop(op->refresher);
	}
	sal_op_unref(op);
}
Exemple #4
0
static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
	if (obj->reg_sendregister){
		char *contact;
		if (obj->op)
			sal_op_release(obj->op);
		obj->op=sal_op_new(obj->lc->sal);
		contact=guess_contact_for_register(obj);
		sal_op_set_contact(obj->op,contact);
		ms_free(contact);
		sal_op_set_user_pointer(obj->op,obj);
		if (sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) {
			linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress");
		} else {
			linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed");
		}
	}
}
Exemple #5
0
static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage* msg){
	SalOp *op=NULL;
	LinphoneCall *call;
	char* content_type;
	const char *identity=NULL;
	time_t t=time(NULL);
	
	if (lp_config_get_int(cr->lc->config,"sip","chat_use_call_dialogs",0)){
		if((call = linphone_core_get_call_by_remote_address(cr->lc,cr->peer))!=NULL){
			if (call->state==LinphoneCallConnected ||
			call->state==LinphoneCallStreamsRunning ||
			call->state==LinphoneCallPaused ||
			call->state==LinphoneCallPausing ||
			call->state==LinphoneCallPausedByRemote){
				ms_message("send SIP message through the existing call.");
				op = call->op;
				call->pending_message=msg;
				identity=linphone_core_find_best_identity(cr->lc,linphone_call_get_remote_address(call));
			}
		}
	}
	msg->time=t;
	if (op==NULL){
		LinphoneProxyConfig *proxy=linphone_core_lookup_known_proxy(cr->lc,cr->peer_url);
		if (proxy){
			identity=linphone_proxy_config_get_identity(proxy);
		}else identity=linphone_core_get_primary_contact(cr->lc);
		/*sending out of calls*/
		op = sal_op_new(cr->lc->sal);
		linphone_configure_op(cr->lc,op,cr->peer_url,msg->custom_headers,lp_config_get_int(cr->lc->config,"sip","chat_msg_with_contact",0));
		sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/
	}
	if (msg->external_body_url) {
		content_type=ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"",msg->external_body_url);
		sal_message_send(op,identity,cr->peer,content_type, NULL);
		ms_free(content_type);
	} else {
		sal_text_send(op, identity, cr->peer,msg->message);
	}
	msg->dir=LinphoneChatMessageOutgoing;
	msg->from=linphone_address_new(identity);
	msg->storage_id=linphone_chat_message_store(msg);
}
Exemple #6
0
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params)
{
	LinphoneCall *call=ms_new0(LinphoneCall,1);
	call->dir=LinphoneCallOutgoing;
	call->op=sal_op_new(lc->sal);
	sal_op_set_user_pointer(call->op,call);
	call->core=lc;
	linphone_core_get_local_ip(lc,linphone_address_get_domain(to),call->localip);
	linphone_call_init_common(call,from,to);
	call->params=*params;
	call->localdesc=create_local_media_description (lc,call);
	call->camera_active=params->has_video;
	if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun)
		linphone_core_run_stun_tests(call->core,call);
	discover_mtu(lc,linphone_address_get_domain (to));
	if (params->referer){
		sal_call_set_referer (call->op,params->referer->op);
	}
	return call;
}
Exemple #7
0
static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage* msg) {
    const char *route=NULL;
    const char *identity=linphone_core_find_best_identity(cr->lc,cr->peer_url,&route);
    SalOp *op=NULL;
    LinphoneCall *call;
    char* content_type;

    if (lp_config_get_int(cr->lc->config,"sip","chat_use_call_dialogs",1)) {
        if((call = linphone_core_get_call_by_remote_address(cr->lc,cr->peer))!=NULL) {
            if (call->state==LinphoneCallConnected ||
                    call->state==LinphoneCallStreamsRunning ||
                    call->state==LinphoneCallPaused ||
                    call->state==LinphoneCallPausing ||
                    call->state==LinphoneCallPausedByRemote) {
                ms_message("send SIP message through the existing call.");
                op = call->op;
                call->pending_message=msg;
            }
        }
    }
    if (op==NULL) {
        /*sending out of calls*/
        op = sal_op_new(cr->lc->sal);
        sal_op_set_route(op,route);
        sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/
    }
    if (msg->external_body_url) {
        content_type=ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"",msg->external_body_url);
        sal_message_send(op,identity,cr->peer,content_type,NULL);
        ms_free(content_type);
    } else {
        sal_text_send(op, identity, cr->peer, msg->message);
    }


}