Commit 5183b217 authored by Simon Morlat's avatar Simon Morlat
Browse files

change info api so that INFO message can only be sent through calls (as requested by the RFC)

parent 01f746a4
......@@ -167,9 +167,9 @@ static void process_request_event(void *sal, const belle_sip_request_event_t *ev
belle_sip_provider_send_response(((Sal*)sal)->prov,resp);
return;
}else if (strcmp("INFO",belle_sip_request_get_method(req))==0) {
op=sal_op_new((Sal*)sal);
op->dir=SalOpDirIncoming;
sal_op_info_fill_cbs(op);
resp=belle_sip_response_create_from_request(req,481);/*INFO out of call dialogs are not allowed*/
belle_sip_provider_send_response(((Sal*)sal)->prov,resp);
return;
}else {
ms_error("sal process_request_event not implemented yet for method [%s]",belle_sip_request_get_method(req));
resp=belle_sip_response_create_from_request(req,501);
......
......@@ -66,7 +66,6 @@ typedef enum SalOpType {
SalOpMessage,
SalOpPresence,
SalOpPublish,
SalOpInfo,
SalOpSubscribe
}SalOpType_t;
const char* sal_op_type_to_string(const SalOpType_t type);
......@@ -125,9 +124,6 @@ void sal_op_presence_fill_cbs(SalOp*op);
/*messaging*/
void sal_op_message_fill_cbs(SalOp*op);
/*info*/
void sal_op_info_fill_cbs(SalOp*op);
void sal_op_subscribe_fill_cbs(SalOp*op);
/*call transfer*/
......
......@@ -192,6 +192,7 @@ static void cancelling_invite(SalOp* op ){
sal_op_send_request(op,cancel);
op->state=SalOpStateTerminating;
}
static void call_response_event(void *op_base, const belle_sip_response_event_t *event){
SalOp* op = (SalOp*)op_base;
belle_sip_request_t* ack;
......@@ -438,7 +439,7 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t
resp=sal_op_create_response_from_request(op,req,200);
belle_sip_server_transaction_send_response(server_transaction,resp);
} else {
belle_sip_error("Unexpected method [%s] for dialog state BELLE_SIP_DIALOG_EARLY");
belle_sip_error("Unexpected method [%s] for dialog state BELLE_SIP_DIALOG_EARLY",belle_sip_request_get_method(req));
unsupported_method(server_transaction,req);
}
break;
......@@ -480,8 +481,8 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t
process_sdp_for_invite(op,req);
op->base.root->callbacks.call_updating(op);
} else if (strcmp("INFO",belle_sip_request_get_method(req))==0
&& belle_sip_message_get_body(BELLE_SIP_MESSAGE(req))
} else if (strcmp("INFO",belle_sip_request_get_method(req))==0){
if (belle_sip_message_get_body(BELLE_SIP_MESSAGE(req))
&& strstr(belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)),"picture_fast_update")) {
/*vfu request*/
ms_message("Receiving VFU request on op [%p]",op);
......@@ -489,8 +490,16 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t
op->base.root->callbacks.vfu_request(op);
}
resp=sal_op_create_response_from_request(op,req,200);
belle_sip_server_transaction_send_response(server_transaction,resp);
}else{
SalBody salbody;
if (sal_op_get_body(op,(belle_sip_message_t*)req,&salbody)) {
op->base.root->callbacks.info_received(op,&salbody);
} else {
op->base.root->callbacks.info_received(op,NULL);
}
}
resp=sal_op_create_response_from_request(op,req,200);
belle_sip_server_transaction_send_response(server_transaction,resp);
}else if (strcmp("REFER",belle_sip_request_get_method(req))==0) {
sal_op_process_refer(op,event);
} else if (strcmp("NOTIFY",belle_sip_request_get_method(req))==0) {
......
......@@ -85,6 +85,7 @@ static void subscribe_response_event(void *op_base, const belle_sip_response_eve
if (expires>0){
op->refresher=belle_sip_client_transaction_create_refresher(client_transaction);
}
if (sss==SalSubscribeNone) sss=SalSubscribeActive; /*without Subscription-state header, consider subscription is accepted.*/
op->base.root->callbacks.subscribe_response(op,sss,SalErrorNone,SalReasonUnknown);
}
break;
......
......@@ -18,43 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sal_impl.h"
static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
}
static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *event) {
}
static void process_response_event(void *op_base, const belle_sip_response_event_t *event){
}
static void process_request_event(void *op_base, const belle_sip_request_event_t *event) {
SalOp* op = (SalOp*)op_base;
belle_sip_request_t* req = belle_sip_request_event_get_request(event);
belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(op->base.root->prov,req);
belle_sip_response_t* resp;
SalBody salbody;
if (sal_op_get_body(op,(belle_sip_message_t*)req,&salbody)) {
op->base.root->callbacks.info_received(op,&salbody);
} else {
op->base.root->callbacks.info_received(op,NULL);
}
resp = belle_sip_response_create_from_request(req,200);
belle_sip_server_transaction_send_response(server_transaction,resp);
sal_op_release(op);
}
int sal_send_info(SalOp *op, const char *from, const char *to, const SalBody *body){
belle_sip_request_t *req=sal_op_build_request(op,"INFO");
sal_op_info_fill_cbs(op);
sal_op_add_body(op,(belle_sip_message_t*)req,body);
return sal_op_send_request(op,req);
if (op->dialog){
belle_sip_request_t *req=belle_sip_dialog_create_request(op->dialog,"INFO");
sal_op_add_body(op,(belle_sip_message_t*)req,body);
return sal_op_send_request(op,req);
}
return -1;
}
void sal_op_info_fill_cbs(SalOp*op) {
op->callbacks.process_io_error=process_io_error;
op->callbacks.process_response_event=process_response_event;
op->callbacks.process_timeout=process_timeout;
op->callbacks.process_request_event=process_request_event;
op->type=SalOpInfo;
}
......@@ -112,11 +112,14 @@ int linphone_event_accept_subscription(LinphoneEvent *lev){
}
int linphone_event_deny_subscription(LinphoneEvent *lev, LinphoneReason reason){
int err;
if (lev->state!=LinphoneSubscriptionIncomingReceived){
ms_error("linphone_event_deny_subscription(): cannot deny subscription if subscription wasn't just received.");
return -1;
}
return sal_subscribe_decline(lev->op,linphone_reason_to_sal(reason));
err=sal_subscribe_decline(lev->op,linphone_reason_to_sal(reason));
linphone_event_set_state(lev,LinphoneSubscriptionTerminated);
return err;
}
int linphone_event_notify(LinphoneEvent *lev, const LinphoneContent *body){
......
......@@ -30,7 +30,6 @@
struct _LinphoneInfoMessage{
LinphoneContent content;
SalOp *op;
SalCustomHeader *headers;
};
......@@ -105,8 +104,6 @@ SalBody *sal_body_from_content(SalBody *body, const LinphoneContent *lc){
* Destroy a LinphoneInfoMessage
**/
void linphone_info_message_destroy(LinphoneInfoMessage *im){
/* FIXME: op is leaked. If we release it now, there is a high risk that the request won't be resent with authentication*/
/*if (im->op) sal_op_release(im->op);*/
linphone_content_uninit(&im->content);
sal_custom_header_free(im->headers);
ms_free(im);
......@@ -117,13 +114,12 @@ LinphoneInfoMessage *linphone_info_message_copy(const LinphoneInfoMessage *orig)
LinphoneInfoMessage *im=ms_new0(LinphoneInfoMessage,1);
linphone_content_copy(&im->content,&orig->content);
if (orig->headers) im->headers=sal_custom_header_clone(orig->headers);
if (orig->op) im->op=sal_op_ref(orig->op);
return im;
}
/**
* Creates an empty info message.
* @param lc the LinphoneCore object.
* @param lc the LinphoneCore
* @return a new LinphoneInfoMessage.
*
* The info message can later be filled with information using linphone_info_message_add_header() or linphone_info_message_set_content(),
......@@ -131,20 +127,18 @@ LinphoneInfoMessage *linphone_info_message_copy(const LinphoneInfoMessage *orig)
**/
LinphoneInfoMessage *linphone_core_create_info_message(LinphoneCore *lc){
LinphoneInfoMessage *im=ms_new0(LinphoneInfoMessage,1);
im->op=sal_op_new(lc->sal);
return im;
}
/**
* Send a LinphoneInfoMessage to a specified address.
* @param lc the LinphoneCore
* Send a LinphoneInfoMessage through an established call
* @param call the call
* @param info the info message
* @param addr the destination address
**/
int linphone_core_send_info_message(LinphoneCore *lc, const LinphoneInfoMessage *info, const LinphoneAddress *addr){
int linphone_call_send_info_message(LinphoneCall *call, const LinphoneInfoMessage *info){
SalBody body;
linphone_configure_op(lc,info->op,addr,info->headers,FALSE);
return sal_send_info(info->op,NULL, NULL, sal_body_from_content(&body,&info->content));
sal_op_set_sent_custom_header(call->op,info->headers);
return sal_send_info(call->op,NULL, NULL, sal_body_from_content(&body,&info->content));
}
/**
......@@ -164,15 +158,7 @@ void linphone_info_message_add_header(LinphoneInfoMessage *im, const char *name,
* @return the corresponding header's value, or NULL if not exists.
**/
const char *linphone_info_message_get_header(const LinphoneInfoMessage *im, const char *name){
const SalCustomHeader *ch=sal_op_get_recv_custom_header(im->op);
return sal_custom_header_find(ch,name);
}
/**
* Returns origin of received LinphoneInfoMessage
**/
const char *linphone_info_message_get_from(const LinphoneInfoMessage *im){
return sal_op_get_from(im->op);
return sal_custom_header_find(im->headers,name);
}
/**
......@@ -193,11 +179,13 @@ const LinphoneContent * linphone_info_message_get_content(const LinphoneInfoMess
}
void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, const SalBody *body){
LinphoneInfoMessage *info=ms_new0(LinphoneInfoMessage,1);
info->op=sal_op_ref(op);
info->headers=sal_custom_header_clone(sal_op_get_recv_custom_header(op));
if (body) linphone_content_copy_from_sal_body(&info->content,body);
if (lc->vtable.info_received)
lc->vtable.info_received(lc,info);
linphone_info_message_destroy(info);
LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
if (call){
LinphoneInfoMessage *info=ms_new0(LinphoneInfoMessage,1);
info->headers=sal_custom_header_clone(sal_op_get_recv_custom_header(op));
if (body) linphone_content_copy_from_sal_body(&info->content,body);
if (lc->vtable.info_received)
lc->vtable.info_received(lc,call,info);
linphone_info_message_destroy(info);
}
}
......@@ -109,6 +109,17 @@ struct _LinphoneContent{
**/
typedef struct _LinphoneContent LinphoneContent;
/**
* The LinphoneCall object represents a call issued or received by the LinphoneCore
* @ingroup call_control
**/
struct _LinphoneCall;
/**
* The LinphoneCall object represents a call issued or received by the LinphoneCore
* @ingroup call_control
**/
typedef struct _LinphoneCall LinphoneCall;
/**
* Enum describing failure reasons.
* @ingroup misc
......@@ -277,8 +288,8 @@ struct _LinphoneInfoMessage;
**/
typedef struct _LinphoneInfoMessage LinphoneInfoMessage;
LINPHONE_PUBLIC LinphoneInfoMessage *linphone_core_create_info_message(LinphoneCore *lc);
LINPHONE_PUBLIC int linphone_core_send_info_message(LinphoneCore *lc, const LinphoneInfoMessage *info, const LinphoneAddress *addr);
LINPHONE_PUBLIC LinphoneInfoMessage *linphone_core_create_info_message(LinphoneCore*lc);
LINPHONE_PUBLIC int linphone_call_send_info_message(struct _LinphoneCall *call, const LinphoneInfoMessage *info);
LINPHONE_PUBLIC void linphone_info_message_add_header(LinphoneInfoMessage *im, const char *name, const char *value);
LINPHONE_PUBLIC const char *linphone_info_message_get_header(const LinphoneInfoMessage *im, const char *name);
LINPHONE_PUBLIC void linphone_info_message_set_content(LinphoneInfoMessage *im, const LinphoneContent *content);
......@@ -305,16 +316,7 @@ struct _LinphoneVideoPolicy{
**/
typedef struct _LinphoneVideoPolicy LinphoneVideoPolicy;
/**
* The LinphoneCall object represents a call issued or received by the LinphoneCore
* @ingroup call_control
**/
struct _LinphoneCall;
/**
* The LinphoneCall object represents a call issued or received by the LinphoneCore
* @ingroup call_control
**/
typedef struct _LinphoneCall LinphoneCall;
/**
......@@ -872,7 +874,7 @@ typedef void (*LinphoneTransferStateChanged)(struct _LinphoneCore *lc, LinphoneC
typedef void (*CallStatsUpdated)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
/** Callback prototype for receiving info messages*/
typedef void (*LinphoneInfoReceivedCb)(struct _LinphoneCore *lc, const LinphoneInfoMessage *msg);
typedef void (*LinphoneInfoReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
/**
* This structure holds all callbacks that the application should implement.
* None is mandatory.
......
......@@ -34,7 +34,7 @@ void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState
,linphone_call_state_to_string(cstate));
ms_free(to);
ms_free(from);
counters = (stats*)linphone_core_get_user_data(lc);
counters = get_stats(lc);
switch (cstate) {
case LinphoneCallIncomingReceived:counters->number_of_LinphoneCallIncomingReceived++;break;
case LinphoneCallOutgoingInit :counters->number_of_LinphoneCallOutgoingInit++;break;
......@@ -67,7 +67,7 @@ void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered,
ms_free(to);
ms_free(from);
counters = (stats*)linphone_core_get_user_data(lc);
counters = get_stats(lc);
switch (new_call_state) {
case LinphoneCallOutgoingInit :counters->number_of_LinphoneTransferCallOutgoingInit++;break;
case LinphoneCallOutgoingProgress :counters->number_of_LinphoneTransferCallOutgoingProgress++;break;
......@@ -88,7 +88,7 @@ static void linphone_call_cb(LinphoneCall *call,void * user_data) {
ms_message("call from [%s] to [%s] receive iFrame",from,to);
ms_free(to);
ms_free(from);
counters = (stats*)linphone_core_get_user_data(lc);
counters = (stats*)get_stats(lc);
counters->number_of_IframeDecoded++;
}
......@@ -444,8 +444,11 @@ static void call_with_ice(void) {
CU_ASSERT_TRUE(call(pauline,marie));
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
/*wait for the ICE reINVITE to complete*/
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
/*just to sleep*/
/*then close the call*/
linphone_core_terminate_all_calls(pauline->lc);
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
......
......@@ -31,7 +31,8 @@ void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *
}
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
stats* counters = (stats*)linphone_core_get_user_data(lc);
stats* counters = get_stats(lc);
LinphoneCoreManager *mgr=get_manager(lc);
LinphoneContent content;
content.type="application";
......@@ -44,7 +45,10 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
break;
case LinphoneSubscriptionIncomingReceived:
counters->number_of_LinphoneSubscriptionIncomingReceived++;
linphone_event_accept_subscription(lev);
if (!mgr->decline_subscribe)
linphone_event_accept_subscription(lev);
else
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
break;
case LinphoneSubscriptionOutoingInit:
counters->number_of_LinphoneSubscriptionOutgoingInit++;
......@@ -54,48 +58,95 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
break;
case LinphoneSubscriptionActive:
counters->number_of_LinphoneSubscriptionActive++;
if (linphone_event_get_dir(lev)==LinphoneSubscriptionIncoming)
if (linphone_event_get_dir(lev)==LinphoneSubscriptionIncoming){
mgr->lev=lev;
linphone_event_notify(lev,&content);
}
break;
case LinphoneSubscriptionTerminated:
counters->number_of_LinphoneSubscriptionTerminated++;
mgr->lev=NULL;
break;
case LinphoneSubscriptionError:
counters->number_of_LinphoneSubscriptionError++;
mgr->lev=NULL;
break;
}
}
static void subscribe_test_declined(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneContent content;
MSList* lcs=ms_list_append(NULL,marie->lc);
lcs=ms_list_append(lcs,pauline->lc);
content.type="application";
content.subtype="somexml";
content.data=(char*)subscribe_content;
content.size=strlen(subscribe_content);
pauline->decline_subscribe=TRUE;
linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,&content);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionError,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void subscribe_test() {
static void subscribe_test_with_args(bool_t terminated_by_subscriber) {
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneContent content;
LinphoneEvent *lev;
MSList* lcs=ms_list_append(NULL,marie->lc);
lcs=ms_list_append(lcs,pauline->lc);
content.type="application";
content.subtype="somexml";
content.data=(char*)subscribe_content;
content.size=strlen(subscribe_content);
linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,&content);
lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,&content);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000));
if (terminated_by_subscriber){
linphone_event_terminate(lev);
}else{
linphone_event_terminate(pauline->lev);
}
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void subscribe_test_terminated_by_subscriber(void){
subscribe_test_with_args(TRUE);
}
static void subscribe_test_terminated_by_notifier(void){
subscribe_test_with_args(FALSE);
}
test_t subscribe_tests[] = {
{ "Subscribe", subscribe_test },
{ "Subscribe declined" , subscribe_test_declined },
{ "Subscribe terminated by subscriber", subscribe_test_terminated_by_subscriber },
{ "Subscribe terminated by notifier", subscribe_test_terminated_by_notifier }
};
test_suite_t subscribe_test_suite = {
......
......@@ -75,7 +75,7 @@ void auth_info_requested(LinphoneCore *lc, const char *realm, const char *userna
ms_message("Auth info requested for user id [%s] at realm [%s]\n"
,username
,realm);
counters = (stats*)linphone_core_get_user_data(lc);
counters = get_stats(lc);
counters->number_of_auth_info_requested++;
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
......@@ -116,7 +116,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
sprintf(filepath, "%s/%s", path, file);
lc = linphone_core_new(v_table,NULL,filepath,NULL);
linphone_core_set_user_data(lc,&global_stat);
counters = (stats*)linphone_core_get_user_data(lc);
counters = get_stats(lc);
/* until we have good certificates on our test server...
linphone_core_verify_server_certificates(lc,FALSE);*/
......@@ -180,8 +180,18 @@ static void enable_codec(LinphoneCore* lc,const char* type,int rate) {
ms_list_free(codecs);
}
stats * get_stats(LinphoneCore *lc){
LinphoneCoreManager *manager=(LinphoneCoreManager *)linphone_core_get_user_data(lc);
return &manager->stat;
}
LinphoneCoreManager *get_manager(LinphoneCore *lc){
LinphoneCoreManager *manager=(LinphoneCoreManager *)linphone_core_get_user_data(lc);
return manager;
}
LinphoneCoreManager* linphone_core_manager_new2(const char* path, const char* rc_file, int check_for_proxies) {
LinphoneCoreManager* mgr= malloc(sizeof(LinphoneCoreManager));
LinphoneCoreManager* mgr= ms_new0(LinphoneCoreManager,1);
LinphoneProxyConfig* proxy;
memset (mgr,0,sizeof(LinphoneCoreManager));
mgr->v_table.registration_state_changed=registration_state_changed;
......@@ -196,7 +206,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* path, const char* rc
mgr->v_table.notify_received=linphone_notify_received;
mgr->lc=configure_lc_from(&mgr->v_table, path, rc_file, check_for_proxies?(rc_file?1:0):0);
enable_codec(mgr->lc,"PCMU",8000);
linphone_core_set_user_data(mgr->lc,&mgr->stat);
linphone_core_set_user_data(mgr->lc,mgr);
linphone_core_get_default_proxy(mgr->lc,&proxy);
if (proxy) {
mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy));
......@@ -212,7 +222,7 @@ LinphoneCoreManager* linphone_core_manager_new(const char* path, const char* rc_
void linphone_core_manager_destroy(LinphoneCoreManager* mgr) {
if (mgr->lc) linphone_core_destroy(mgr->lc);
if (mgr->identity) linphone_address_destroy(mgr->identity);
free(mgr);
ms_free(mgr);
}
......
......@@ -152,6 +152,8 @@ typedef struct _LinphoneCoreManager {
LinphoneCore* lc;
stats stat;
LinphoneAddress* identity;
LinphoneEvent *lev;
bool_t decline_subscribe;
} LinphoneCoreManager;
LinphoneCoreManager* linphone_core_manager_new2(const char* path, const char* rc_file, int check_for_proxies);
......@@ -166,7 +168,7 @@ void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered,
void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf);
void text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from_address, const char *message);
void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* message);
void info_message_received(LinphoneCore *lc, const LinphoneInfoMessage *msg);
void info_message_received(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
void new_subscribtion_request(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username);
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *ev, LinphoneSubscriptionState state);
......@@ -179,5 +181,8 @@ bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value);
bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms);
bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr);
stats * get_stats(LinphoneCore *lc);
LinphoneCoreManager *get_manager(LinphoneCore *lc);
#endif /* LIBLINPHONE_TESTER_H_ */
......@@ -24,7 +24,7 @@
void text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from_address, const char *message) {
stats* counters = (stats*)linphone_core_get_user_data(lc);
stats* counters = get_stats(lc);
counters->number_of_LinphoneMessageReceivedLegacy++;
}
......@@ -35,7 +35,7 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess
,linphone_chat_message_get_text(message)
,linphone_chat_message_get_external_body_url(message));
ms_free(from);
counters = (stats*)linphone_core_get_user_data(lc);
counters = get_stats(lc);
counters->number_of_LinphoneMessageReceived++;
if (linphone_chat_message_get_external_body_url(message))
counters->number_of_LinphoneMessageExtBodyReceived++;
......@@ -43,7 +43,7 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess
void linphone_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud) {
LinphoneCore* lc=(LinphoneCore*)ud;
stats* counters = (stats*)linphone_core_get_user_data(lc);
stats* counters = get_stats(lc);
ms_message("Message [%s] [%s]",linphone_chat_message_get_text(msg),linphone_chat_message_state_to_string(state));
switch (state) {
case LinphoneChatMessageStateDelivered:
......@@ -163,8 +163,8 @@ static void text_message_with_send_error(void) {
static const char *info_content="<somexml>blabla</somexml>";
void info_message_received(LinphoneCore *lc, const LinphoneInfoMessage *msg){
stats* counters = (stats*)linphone_core_get_user_data(lc);
void info_message_received(LinphoneCore *lc, LinphoneCall* call, const LinphoneInfoMessage *msg){
stats* counters = get_stats(lc);
const char *hvalue=linphone_info_message_get_header(msg, "Weather");
const LinphoneContent *content=linphone_info_message_get_content(msg);
CU_ASSERT_PTR_NOT_NULL_FATAL(hvalue);
......@@ -189,7 +189,11 @@ void info_message_received(LinphoneCore *lc, const LinphoneInfoMessage *msg){
static void info_message_with_args(bool_t with_content) {
LinphoneCoreManager* marie = linphone_core_manager_new(liblinphone_tester_file_prefix, "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(liblinphone_tester_file_prefix, "pauline_rc");
LinphoneInfoMessage *info=linphone_core_create_info_message(marie->lc);
LinphoneInfoMessage *info;
CU_ASSERT_TRUE(call(pauline,marie));
info=linphone_core_create_info_message(marie->lc);
linphone_info_message_add_header(info,"Weather","still bad");
if (with_content) {
LinphoneContent ct;
......@@ -199,7 +203,7 @@ static void info_message_with_args(bool_t with_content) {
ct.size=strlen(info_content);
linphone_info_message_set_content(info,&ct);
}
linphone_core_send_info_message(marie->lc,info,pauline->identity);
linphone_call_send_info_message(linphone_core_get_current_call(marie->lc),info);
linphone_info_message_destroy(info);