Commit db7440f2 authored by Simon Morlat's avatar Simon Morlat

fix listener execution

parent 35a71156
......@@ -76,6 +76,7 @@ BELLESIP_EXPORT belle_sip_header_t* belle_sip_header_create (const char* name,co
BELLESIP_EXPORT const char* belle_sip_header_get_name (const belle_sip_header_t* obj);
BELLESIP_EXPORT void belle_sip_header_set_name (belle_sip_header_t* obj,const char* value);
BELLESIP_EXPORT int belle_sip_header_marshal(belle_sip_header_t* header, char* buff, unsigned int offset,unsigned int buff_size);
BELLESIP_EXPORT const char *belle_sip_header_get_unparsed_value(belle_sip_header_t* obj);
#define BELLE_SIP_HEADER(t) BELLE_SIP_CAST(t,belle_sip_header_t)
......
......@@ -37,28 +37,51 @@ GET_SET_STRING(belle_sip_header,name);
belle_sip_header_t* belle_sip_header_create (const char* name,const char* value) {
return BELLE_SIP_HEADER(belle_sip_header_extension_create(name,value));
}
void belle_sip_header_init(belle_sip_header_t *header) {
}
static void belle_sip_header_clone(belle_sip_header_t *header, const belle_sip_header_t *orig){
CLONE_STRING(belle_sip_header,name,header,orig)
if (belle_sip_header_get_next(orig)) {
belle_sip_header_set_next(header,BELLE_SIP_HEADER(belle_sip_object_clone(BELLE_SIP_OBJECT(belle_sip_header_get_next(orig))))) ;
}
}
static void belle_sip_header_destroy(belle_sip_header_t *header){
if (header->name) belle_sip_free((void*)header->name);
if (header->name) belle_sip_free(header->name);
if (header->unparsed_value) belle_sip_free(header->unparsed_value);
if (header->next) belle_sip_object_unref(BELLE_SIP_OBJECT(header->next));
}
void belle_sip_header_set_next(belle_sip_header_t* header,belle_sip_header_t* next) {
if (next) belle_sip_object_ref(next);
if(header->next) belle_sip_object_unref(header->next);
header->next = next;
}
belle_sip_header_t* belle_sip_header_get_next(const belle_sip_header_t* header) {
return header->next;
}
const char *belle_sip_header_get_unparsed_value(belle_sip_header_t* obj){
char *tmp=belle_sip_object_to_string(obj);
char *ret;
char *end;
if (obj->unparsed_value){
belle_sip_free(obj->unparsed_value);
obj->unparsed_value=NULL;
}
obj->unparsed_value=tmp;
ret=tmp;
ret+=strlen(obj->name)+1; /* name + semicolon*/
for(;*ret==' ';ret++){};/*skip spaces*/
end=strchr(ret,'\r');
if (end) *end='\0'; /*remove \r\n*/
return ret;
}
int belle_sip_header_marshal(belle_sip_header_t* header, char* buff,unsigned int offset,unsigned int buff_size) {
if (header->name) {
return snprintf(buff+offset,buff_size-offset,"%s: ",header->name);
......
......@@ -70,18 +70,18 @@
#define __BELLE_SIP_INVOKE_LISTENER_BEGIN(list,interface_name,method) \
if (list!=NULL) {\
const belle_sip_list_t *__elem=list;\
belle_sip_list_t *__copy=belle_sip_list_copy_with_data((list), (void* (*)(void*))belle_sip_object_ref);\
const belle_sip_list_t *__elem=__copy;\
do{\
void *__method;\
interface_name *__obj=(interface_name*)__elem->data;\
belle_sip_object_ref(__obj);\
__method=BELLE_SIP_INTERFACE_GET_METHODS(__obj,interface_name)->method;\
if (__method) BELLE_SIP_INTERFACE_GET_METHODS(__obj,interface_name)->
#define __BELLE_SIP_INVOKE_LISTENER_END \
__elem=__elem->next;\
belle_sip_object_unref(__obj);\
}while(__elem!=NULL);\
belle_sip_list_free_with_data(__copy,belle_sip_object_unref);\
}
#define BELLE_SIP_INVOKE_LISTENERS_VOID(list,interface_name,method) \
......@@ -430,7 +430,8 @@ void belle_sip_header_address_set_quoted_displayname(belle_sip_header_address_t*
struct _belle_sip_header {
belle_sip_object_t base;
belle_sip_header_t* next;
const char* name;
char *name;
char *unparsed_value;
};
void belle_sip_header_set_next(belle_sip_header_t* header,belle_sip_header_t* next);
......@@ -527,7 +528,7 @@ typedef struct listener_ctx{
}listener_ctx_t;
#define BELLE_SIP_PROVIDER_INVOKE_LISTENERS_FOR_TRANSACTION(t,callback,event) \
BELLE_SIP_PROVIDER_INVOKE_LISTENERS((t)->is_internal?t->provider->internal_listeners:t->provider->listeners,callback,event)
BELLE_SIP_PROVIDER_INVOKE_LISTENERS((t)->is_internal?(t)->provider->internal_listeners:(t)->provider->listeners,callback,event)
#define BELLE_SIP_PROVIDER_INVOKE_LISTENERS(listeners,callback,event) \
BELLE_SIP_INVOKE_LISTENERS_ARG((listeners),belle_sip_listener_t,callback,(event))
......
......@@ -396,14 +396,10 @@ belle_sip_message_t* belle_sip_channel_pick_message(belle_sip_channel_t *obj) {
}
static void channel_invoke_state_listener(belle_sip_channel_t *obj){
belle_sip_list_t* list=belle_sip_list_copy(obj->listeners); /*copy list because error state alter this list (I.E by provider)*/
if (obj->state==BELLE_SIP_CHANNEL_DISCONNECTED || obj->state==BELLE_SIP_CHANNEL_ERROR){
belle_sip_channel_close(obj);
}
BELLE_SIP_INVOKE_LISTENERS_ARG1_ARG2(list,belle_sip_channel_listener_t,on_state_changed,obj,obj->state);
belle_sip_list_free(list);
BELLE_SIP_INVOKE_LISTENERS_ARG1_ARG2(obj->listeners,belle_sip_channel_listener_t,on_state_changed,obj,obj->state);
}
static void channel_invoke_state_listener_defered(belle_sip_channel_t *obj){
......
......@@ -30,7 +30,7 @@
#define IPV4_MULTIRES_DOMAIN "google.fr"
#define IPV6_SIP_DOMAIN "videolan.org"
#define IPV6_SIP_IP "2a01:e0d:1:3:58bf:fa02:0:1"
#define SRV_DOMAIN "ekiga.net"
#define SRV_DOMAIN "linphone.org"
#define SIP_PORT 5060
......
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