Commit 4cc7c7c0 authored by Simon Morlat's avatar Simon Morlat
Browse files

info api in progress, but test is failed due to flexisip not forking info

parent a1c566ff
......@@ -46,14 +46,14 @@ struct Sal{
bool_t use_dates;
};
typedef enum SalOpSate {
typedef enum SalOpState {
SalOpStateEarly=0
,SalOpStateActive
,SalOpStateTerminating /*this state is used to wait until a proceeding state, so we can send the cancel*/
,SalOpStateTerminated
}SalOpSate_t;
}SalOpState;
const char* sal_op_state_to_string(const SalOpSate_t value);
const char* sal_op_state_to_string(SalOpState value);
typedef enum SalOpDir {
SalOpDirIncoming=0
......@@ -85,7 +85,7 @@ struct SalOp{
SalMediaDescription *result;
belle_sdp_session_description_t *sdp_answer;
bool_t supports_session_timers;
SalOpSate_t state;
SalOpState state;
SalOpDir_t dir;
belle_sip_refresher_t* refresher;
int ref;
......
......@@ -375,14 +375,14 @@ int sal_op_send_and_create_refresher(SalOp* op,belle_sip_request_t* req, int exp
return -1;
}
const char* sal_op_state_to_string(const SalOpSate_t value) {
const char* sal_op_state_to_string(const SalOpState value) {
switch(value) {
case SalOpStateEarly: return"SalOpStateEarly";
case SalOpStateActive: return "SalOpStateActive";
case SalOpStateTerminating: return "SalOpStateTerminating";
case SalOpStateTerminated: return "SalOpStateTerminated";
default:
return "Unknon";
return "Unknown";
}
}
......
......@@ -448,6 +448,7 @@ void sal_op_set_from(SalOp *op, const char *from);
void sal_op_set_from_address(SalOp *op, const SalAddress *from);
void sal_op_set_to(SalOp *op, const char *to);
void sal_op_set_to_address(SalOp *op, const SalAddress *to);
SalOp *sal_op_ref(SalOp* h);
void sal_op_release(SalOp *h);
void sal_op_authenticate(SalOp *h, const SalAuthInfo *info);
void sal_op_cancel_authentication(SalOp *h);
......
......@@ -133,6 +133,9 @@ typedef struct _stats {
int number_of_LinphoneStatusAltService;
int number_of_LinphoneStatusPending;
int number_of_LinphoneStatusEnd;
int number_of_inforeceived;
int number_of_inforeceived_with_body;
}stats;
......@@ -156,6 +159,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, 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);
......
......@@ -161,13 +161,68 @@ static void text_message_with_send_error(void) {
linphone_core_manager_destroy(pauline);
}
static const char *info_content="<somexml>blabla</somexml>";
void info_message_received(LinphoneCore *lc, LinphoneInfoMessage *msg){
stats* counters = (stats*)linphone_core_get_user_data(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(hvalue);
CU_ASSERT_TRUE(strcmp(hvalue,"still bad")==0);
if (!content){
counters->number_of_inforeceived++;
}else{
CU_ASSERT_PTR_NOT_NULL(content->data);
CU_ASSERT_TRUE(strcmp((const char*)content->data,info_content)==0);
CU_ASSERT_EQUAL(content->size,strlen(info_content));
counters->number_of_inforeceived_with_body++;
}
}
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);
linphone_info_message_add_header(info,"Wheather","still bad");
if (with_content) {
LinphoneContent ct;
ct.type="application";
ct.subtype="somexml";
ct.data=(void*)info_content;
ct.size=strlen(info_content);
linphone_info_message_set_content(info,&ct);
}
linphone_core_send_info_message(marie->lc,info,pauline->identity);
linphone_info_message_destroy(info);
if (with_content){
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_inforeceived_with_body,1));
}else{
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_inforeceived,1));
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void info_message(){
info_message_with_args(FALSE);
}
static void info_message_with_body(){
info_message_with_args(TRUE);
}
test_t message_tests[] = {
{ "Text message", text_message },
{ "Text message compatibility mode", text_message_compatibility_mode },
{ "Text message with ack", text_message_with_ack },
{ "Text message with send error", text_message_with_send_error },
{ "Text message with external body", text_message_with_external_body }
{ "Text message with external body", text_message_with_external_body },
{ "Info message", info_message },
{ "Info message with body", info_message_with_body }
};
test_suite_t message_test_suite = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment