Commit 2d1c999f authored by jehan's avatar jehan

add proxy config setter for publish expiration

parent 25a3df80
......@@ -789,6 +789,7 @@ LINPHONE_PUBLIC int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *o
LINPHONE_PUBLIC int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity);
LINPHONE_PUBLIC int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route);
LINPHONE_PUBLIC void linphone_proxy_config_set_expires(LinphoneProxyConfig *obj, int expires);
#define linphone_proxy_config_expires linphone_proxy_config_set_expires
/**
* Indicates either or not, REGISTRATION must be issued for this #LinphoneProxyConfig .
......@@ -808,6 +809,21 @@ LINPHONE_PUBLIC int linphone_proxy_config_done(LinphoneProxyConfig *obj);
*
*/
LINPHONE_PUBLIC void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
/**
* Set the publish expiration time in second.
* @param obj proxy config
* @param exires in second
* */
LINPHONE_PUBLIC void linphone_proxy_config_set_publish_expires(LinphoneProxyConfig *obj, int expires);
/**
* get the publish expiration time in second. Default value is the registration expiration value.
* @param obj proxy config
* @return expires in second
* */
LINPHONE_PUBLIC int linphone_proxy_config_get_publish_expires(const LinphoneProxyConfig *obj);
LINPHONE_PUBLIC void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val);
LINPHONE_PUBLIC void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix);
......
......@@ -408,6 +408,7 @@ struct _LinphoneProxyConfig
char *contact_params;
char *contact_uri_params;
int expires;
int publish_expires;
SalOp *op;
char *type;
struct _SipSetupContext *ssctx;
......
......@@ -64,6 +64,7 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *ob
obj->send_statistics = lc ? lp_config_get_default_int(lc->config, "proxy", "send_statistics", 0) : 0;
obj->contact_params = contact_params ? ms_strdup(contact_params) : NULL;
obj->contact_uri_params = contact_uri_params ? ms_strdup(contact_uri_params) : NULL;
obj->publish_expires=-1;
}
/**
......@@ -872,7 +873,11 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese
sal_address_unref(addr);
}
}
err=sal_publish_presence(proxy->publish_op,NULL,NULL,proxy->expires,(SalPresenceModel *)presence);
err=sal_publish_presence(proxy->publish_op
,NULL
,NULL
,linphone_proxy_config_get_publish_expires(proxy)
,(SalPresenceModel *)presence);
}else proxy->send_publish=TRUE; /*otherwise do not send publish if registration is in progress, this will be done later*/
return err;
}
......@@ -1456,3 +1461,14 @@ void linphone_proxy_config_set_privacy(LinphoneProxyConfig *params, LinphonePriv
LinphonePrivacyMask linphone_proxy_config_get_privacy(const LinphoneProxyConfig *params) {
return params->privacy;
}
void linphone_proxy_config_set_publish_expires(LinphoneProxyConfig *obj, int expires) {
obj->publish_expires=expires;
}
int linphone_proxy_config_get_publish_expires(const LinphoneProxyConfig *obj) {
if (obj->publish_expires<0) {
return obj->expires; /*default value is same as register*/
} else {
return obj->publish_expires;
}
}
......@@ -22,6 +22,8 @@ liblinphonetester_la_SOURCES = tester.c \
stun_tester.c \
remote_provisioning_tester.c
liblinphonetester_la_LDFLAGS= -no-undefined
liblinphonetester_la_LIBADD= ../coreapi/liblinphone.la $(CUNIT_LIBS)
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/coreapi
AM_CFLAGS = $(STRICT_OPTIONS) -DIN_LINPHONE $(ORTP_CFLAGS) $(MEDIASTREAMER_CFLAGS) $(CUNIT_CFLAGS) $(BELLESIP_CFLAGS) $(LIBXML2_CFLAGS)
......@@ -31,7 +33,7 @@ if !BUILD_IOS
noinst_PROGRAMS = liblinphone_tester
liblinphone_tester_SOURCES = liblinphone_tester.c
liblinphone_tester_LDADD = $(top_builddir)/coreapi/liblinphone.la liblinphonetester.la $(SIPSTACK_LIBS) $(LIBXML2_LIBS) $(CUNIT_LIBS)
liblinphone_tester_LDADD = $(top_builddir)/coreapi/liblinphone.la liblinphonetester.la
endif
......
......@@ -95,6 +95,10 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state){
stats* counters = get_stats(lc);
const LinphoneAddress* from_addr = linphone_event_get_from(ev);
char* from = linphone_address_as_string(from_addr);
ms_message("Publish state [%s] from [%s]",linphone_publish_state_to_string(state),from);
ms_free(from);
switch(state){
case LinphonePublishProgress: counters->number_of_LinphonePublishProgress++; break;
case LinphonePublishOk:
......
......@@ -123,13 +123,16 @@ static void wait_core(LinphoneCore *core) {
}
}
static void simple_publish(void) {
static void simple_publish_with_expire(int expires) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneProxyConfig* proxy;
LinphonePresenceModel* presence;
linphone_core_get_default_proxy(marie->lc,&proxy);
linphone_proxy_config_edit(proxy);
if (expires >0) {
linphone_proxy_config_set_publish_expires(proxy,expires);
}
linphone_proxy_config_enable_publish(proxy,TRUE);
linphone_proxy_config_done(proxy);
wait_core(marie->lc);
......@@ -139,6 +142,14 @@ static void simple_publish(void) {
linphone_core_manager_destroy(marie);
}
static void simple_publish() {
simple_publish_with_expire(-1);
}
static void publish_with_expires() {
simple_publish_with_expire(1);
}
static bool_t subscribe_to_callee_presence(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr) {
stats initial_caller=caller_mgr->stat;
stats initial_callee=callee_mgr->stat;
......@@ -340,6 +351,7 @@ static void presence_information(void) {
test_t presence_tests[] = {
{ "Simple Subscribe", simple_subscribe },
{ "Simple Publish", simple_publish },
{ "Simple Publish with expires", publish_with_expires },
/*{ "Call with presence", call_with_presence },*/
{ "Unsubscribe while subscribing", unsubscribe_while_subscribing },
{ "Presence information", presence_information },
......
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