From 151fd91711c9836a71b0c9468720859134051e0f Mon Sep 17 00:00:00 2001 From: Andrey Volk <andywolk@gmail.com> Date: Mon, 3 Aug 2020 23:41:46 +0400 Subject: [PATCH] Add various accessors and helpers to nua. Cleanup header files in packages. --- debian/libsofia-sip-ua-dev.install | 1 - debian/rules | 7 ---- libsofia-sip-ua/nua/nua.c | 63 ++++++++++++++++++++++++++++- libsofia-sip-ua/nua/sofia-sip/nua.h | 14 +++++++ sofia-sip.spec | 4 -- 5 files changed, 76 insertions(+), 13 deletions(-) diff --git a/debian/libsofia-sip-ua-dev.install b/debian/libsofia-sip-ua-dev.install index 1132a089..2494770e 100644 --- a/debian/libsofia-sip-ua-dev.install +++ b/debian/libsofia-sip-ua-dev.install @@ -1,4 +1,3 @@ -usr/include/*/*.h usr/include/*/*/*.h usr/include/*/*/*.h.in usr/lib/libsofia-sip-ua.a diff --git a/debian/rules b/debian/rules index 0726c57a..a3585ba4 100755 --- a/debian/rules +++ b/debian/rules @@ -11,10 +11,3 @@ override_dh_auto_configure: --disable-stun override_dh_auto_test: - -override_dh_auto_install: - dh_auto_install - cp -a libsofia-sip-ua/nua/*.h debian/tmp/usr/include/sofia-sip-1.12/ - cp -a ./config.h.in debian/tmp/usr/include/sofia-sip-1.12/sofia-sip/ - cp -a ./config.h debian/tmp/usr/include/sofia-sip-1.12/sofia-sip/ - diff --git a/libsofia-sip-ua/nua/nua.c b/libsofia-sip-ua/nua/nua.c index 451cebb1..419fbc86 100644 --- a/libsofia-sip-ua/nua/nua.c +++ b/libsofia-sip-ua/nua/nua.c @@ -234,10 +234,14 @@ void nua_destroy(nua_t *nua) #if HAVE_SMIME /* Start NRC Boston */ sm_destroy(nua->sm); #endif /* End NRC Boston */ - su_home_unref(nua->nua_home); + nua_unref(nua); } } +void nua_unref(nua_t *nua) { + if (nua) su_home_unref(nua->nua_home); +} + /** Fetch callback context from nua. * * @param nua Pointer to @nua stack object @@ -1089,3 +1093,60 @@ nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id) } return NULL; } + +/** Get leg from dialog. */ +const nta_leg_t *nua_get_dialog_state_leg(nua_handle_t *nh) +{ + if (nh && nh->nh_ds) + return nh->nh_ds->ds_leg; + else + return NULL; +} + +/** Get su_home_t from nua handle. */ +su_home_t *nua_handle_get_home(nua_handle_t *nh) +{ + if (nh && nh->nh_home) + return nh->nh_home; + else + return NULL; +} + +/** Get su_home_t from nua. */ +su_home_t *nua_get_home(nua_t *nua) +{ + if (nua && nua->nua_home) + return nua->nua_home; + else + return NULL; +} + +/** Get nta_agent_t from nua. */ +nta_agent_t *nua_get_agent(nua_t *nua) +{ + if (nua && nua->nua_nta) + return nua->nua_nta; + else + return NULL; +} + +/** Set has invite of a nua handle */ +void nua_handle_set_has_invite(nua_handle_t *nh, unsigned val) +{ + if (nh) + nh->nh_has_invite = val; +} + +/** Check if nua handle is destroyed */ +unsigned nua_handle_is_destroyed(nua_handle_t *nh) +{ + assert(nh); + return nh->nh_destroyed; +} + +void nua_handle_dialog_usage_set_refresh_range(nua_handle_t *nh, + unsigned min, unsigned max) { + if (nh && nh->nh_ds && nh->nh_ds->ds_usage) { + nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, min, max); + } +} diff --git a/libsofia-sip-ua/nua/sofia-sip/nua.h b/libsofia-sip-ua/nua/sofia-sip/nua.h index 37b76677..5a698359 100644 --- a/libsofia-sip-ua/nua/sofia-sip/nua.h +++ b/libsofia-sip-ua/nua/sofia-sip/nua.h @@ -47,6 +47,10 @@ #include <sofia-sip/sip.h> #endif +#ifndef NTA_H +#include <sofia-sip/nta.h> +#endif + #ifndef NUA_TAG_H #include <sofia-sip/nua_tag.h> #endif @@ -386,6 +390,16 @@ SOFIAPUBFUN nua_handle_t *nua_handle_by_replaces(nua_t *nua, nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id); +SOFIAPUBFUN const nta_leg_t *nua_get_dialog_state_leg(nua_handle_t *nh); +SOFIAPUBFUN su_home_t *nua_handle_get_home(nua_handle_t *nh); +SOFIAPUBFUN void nua_unref(nua_t *nua); +SOFIAPUBFUN su_home_t *nua_get_home(nua_t *nua); +SOFIAPUBFUN nta_agent_t *nua_get_agent(nua_t *nua); +SOFIAPUBFUN void nua_handle_set_has_invite(nua_handle_t *nh, unsigned val); +SOFIAPUBFUN unsigned nua_handle_is_destroyed(nua_handle_t *nh); +SOFIAPUBFUN void nua_handle_dialog_usage_set_refresh_range(nua_handle_t *nh, + unsigned min, unsigned max); + SOFIA_END_DECLS #endif diff --git a/sofia-sip.spec b/sofia-sip.spec index 168379cb..58de7c27 100644 --- a/sofia-sip.spec +++ b/sofia-sip.spec @@ -50,9 +50,6 @@ make %{?_smp_mflags} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} -cp -a libsofia-sip-ua/nua/*.h %{buildroot}/usr/include/sofia-sip-1.12/ -cp -a config.h.in %{buildroot}/usr/include/sofia-sip-1.12/sofia-sip/ -cp -a config.h %{buildroot}/usr/include/sofia-sip-1.12/sofia-sip/ find %{buildroot} -name \*.la -delete find %{buildroot} -name \*.h.in -delete find . -name installdox -delete @@ -67,7 +64,6 @@ find . -name installdox -delete %dir %{_includedir}/sofia-sip-1.12 %dir %{_includedir}/sofia-sip-1.12/sofia-sip %{_includedir}/sofia-sip-1.12/sofia-sip/*.h -%{_includedir}/sofia-sip-1.12/*.h %dir %{_includedir}/sofia-sip-1.12/sofia-resolv %{_includedir}/sofia-sip-1.12/sofia-resolv/*.h %{_libdir}/libsofia-sip-ua.so