Commit bd95305d authored by Simon Morlat's avatar Simon Morlat
Browse files

add reference counting to LinphoneAddress and SalAddress

parent 88add42e
......@@ -43,6 +43,20 @@ LinphoneAddress * linphone_address_clone(const LinphoneAddress *addr){
return sal_address_clone(addr);
}
/**
* Increment reference count of LinphoneAddress object.
**/
LinphoneAddress * linphone_address_ref(LinphoneAddress *addr){
return sal_address_ref(addr);
}
/**
* Decrement reference count of LinphoneAddress object. When dropped to zero, memory is freed.
**/
void linphone_address_unref(LinphoneAddress *addr){
sal_address_unref(addr);
}
/**
* Returns the address scheme, normally "sip".
**/
......@@ -153,10 +167,10 @@ bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddr
}
/**
* Destroys a LinphoneAddress object.
* Destroys a LinphoneAddress object (actually calls linphone_address_unref()).
**/
void linphone_address_destroy(LinphoneAddress *u){
sal_address_destroy(u);
sal_address_unref(u);
}
int linphone_address_get_port_int(const LinphoneAddress *u) {
......
......@@ -103,18 +103,23 @@ void sal_address_set_display_name(SalAddress *addr, const char *display_name){
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
belle_sip_header_address_set_displayname(header_addr,display_name);
}
void sal_address_set_username(SalAddress *addr, const char *username){
SAL_ADDRESS_SET(addr,user,username);
}
void sal_address_set_domain(SalAddress *addr, const char *host){
SAL_ADDRESS_SET(addr,host,host);
}
void sal_address_set_port(SalAddress *addr, const char *port){
SAL_ADDRESS_SET(addr,port,atoi(port));
}
void sal_address_set_port_int(SalAddress *addr, int port){
SAL_ADDRESS_SET(addr,port,port);
}
void sal_address_clean(SalAddress *addr){
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
belle_sip_uri_t* uri=belle_sip_header_address_get_uri(header_addr);
......@@ -122,19 +127,17 @@ void sal_address_clean(SalAddress *addr){
belle_sip_parameters_clean(BELLE_SIP_PARAMETERS(header_addr));
return ;
}
char *sal_address_as_string(const SalAddress *addr){
return belle_sip_object_to_string(BELLE_SIP_OBJECT(addr));
}
char *sal_address_as_string_uri_only(const SalAddress *addr){
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
belle_sip_uri_t* uri = belle_sip_header_address_get_uri(header_addr);
return belle_sip_object_to_string(BELLE_SIP_OBJECT(uri));
}
void sal_address_destroy(SalAddress *addr){
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
belle_sip_object_unref(header_addr);
return ;
}
void sal_address_set_param(SalAddress *addr,const char* name,const char* value){
belle_sip_parameters_t* parameters = BELLE_SIP_PARAMETERS(addr);
belle_sip_parameters_set_parameter(parameters,name,value);
......@@ -148,3 +151,16 @@ void sal_address_set_transport(SalAddress* addr,SalTransport transport){
void sal_address_set_transport_name(SalAddress* addr,const char *transport){
SAL_ADDRESS_SET(addr,transport_param,transport);
}
SalAddress *sal_address_ref(SalAddress *addr){
return (SalAddress*)belle_sip_object_ref(BELLE_SIP_HEADER_ADDRESS(addr));
}
void sal_address_unref(SalAddress *addr){
belle_sip_object_unref(BELLE_SIP_HEADER_ADDRESS(addr));
}
void sal_address_destroy(SalAddress *addr){
sal_address_unref(addr);
}
......@@ -161,8 +161,10 @@ const char *linphone_reason_to_string(LinphoneReason err);
#include "linphone/event.h"
#endif
LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *uri);
LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *addr);
LinphoneAddress * linphone_address_clone(const LinphoneAddress *addr);
LinphoneAddress * linphone_address_ref(LinphoneAddress *addr);
void linphone_address_unref(LinphoneAddress *addr);
const char *linphone_address_get_scheme(const LinphoneAddress *u);
LINPHONE_PUBLIC const char *linphone_address_get_display_name(const LinphoneAddress* u);
LINPHONE_PUBLIC const char *linphone_address_get_username(const LinphoneAddress *u);
......
......@@ -76,6 +76,8 @@ SalTransport sal_transport_parse(const char*);
/* Address manipulation API*/
SalAddress * sal_address_new(const char *uri);
SalAddress * sal_address_clone(const SalAddress *addr);
SalAddress * sal_address_ref(SalAddress *addr);
void sal_address_unref(SalAddress *addr);
const char *sal_address_get_scheme(const SalAddress *addr);
const char *sal_address_get_display_name(const SalAddress* addr);
const char *sal_address_get_display_name_unquoted(const SalAddress *addr);
......
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