Commit 234f2b93 authored by Pekka Pessi's avatar Pekka Pessi

nua: move soa into dialog state struct

parent 261f1b29
......@@ -41,6 +41,10 @@
#include <sofia-sip/nta.h>
#endif
#ifndef SOA_H
#include <sofia-sip/soa.h>
#endif
struct nua_dialog_state
{
/** Dialog owner */
......@@ -54,6 +58,8 @@ struct nua_dialog_state
/** Server requests */
nua_server_request_t *ds_sr;
soa_session_t *ds_soa; /**< Media session */
/* Dialog and subscription state */
unsigned ds_reporting:1; /**< We are reporting */
......
......@@ -542,28 +542,29 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
if (status == 200) {
nua_handle_preferences_t const *nhp = nh->nh_prefs;
nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
nua_dialog_state_t *ds = nh->nh_ds, *dds = dnh->nh_ds;
if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) {
if (!ds->ds_soa && NHP_GET(nhp, dnhp, media_enable)) {
/* Create soa when needed */
char const *soa_name = NHP_GET(nhp, dnhp, soa_name);
if (dnh->nh_soa)
nh->nh_soa = soa_clone(dnh->nh_soa, nua->nua_root, nh);
if (dds->ds_soa)
ds->ds_soa = soa_clone(dds->ds_soa, nua->nua_root, nh);
else
nh->nh_soa = soa_create(soa_name, nua->nua_root, nh);
ds->ds_soa = soa_create(soa_name, nua->nua_root, nh);
if (!nh->nh_soa)
if (!ds->ds_soa)
status = 900, phrase = "Error Creating SOA Object";
else if (soa_set_params(nh->nh_soa, TAG_NEXT(nh->nh_ptags)) < 0)
else if (soa_set_params(ds->ds_soa, TAG_NEXT(nh->nh_ptags)) < 0)
status = 900, phrase = "Error Setting SOA Parameters";
}
else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) {
else if (ds->ds_soa && !NHP_GET(nhp, dnhp, media_enable)) {
/* ... destroy soa when not needed */
soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
soa_destroy(ds->ds_soa), ds->ds_soa = NULL;
}
if (status == 200 && tags && nh->nh_soa &&
soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0)
if (status == 200 && tags && ds->ds_soa &&
soa_set_params(ds->ds_soa, TAG_NEXT(tags)) < 0)
status = 900, phrase = "Error Setting SOA Parameters";
}
......@@ -1651,7 +1652,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
else /* if (nua->nua_from_is_set) */
has_from = 1, *from = *nua->nua_from;
media_params = soa_get_paramlist(nh->nh_soa, TAG_END());
media_params = soa_get_paramlist(nh->nh_ds->ds_soa, TAG_END());
m = nua_stack_get_contact(nua->nua_registrations);
......
......@@ -2107,8 +2107,8 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
su_strlst_append(l, "\"");
}
if (nh->nh_soa) {
char **media = soa_media_features(nh->nh_soa, 0, home);
if (nh->nh_ds->ds_soa) {
char **media = soa_media_features(nh->nh_ds->ds_soa, 0, home);
while (*media) {
if (su_strlst_len(l))
......
......@@ -205,6 +205,7 @@ int nua_stack_process_request(nua_handle_t *nh,
sr->sr_target_refresh = sm->sm_flags.target_refresh;
sr->sr_owner = nh;
sr->sr_dialog = nh->nh_ds;
sr->sr_initial = initial;
sr->sr_irq = irq;
......@@ -248,10 +249,12 @@ int nua_stack_process_request(nua_handle_t *nh,
/* Create handle if request does not fail */
if (initial && sr->sr_status < 300) {
if ((nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog)))
sr->sr_owner = nh;
else
nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog);
if (!nh)
return nua_server_init_response(sr, SIP_500_INTERNAL_SERVER_ERROR);
sr->sr_owner = nh;
sr->sr_dialog = nh->nh_ds;
}
if (sr->sr_status < 300 && sm->sm_preprocess && sm->sm_preprocess(sr)) {
......
......@@ -76,6 +76,7 @@ struct nua_server_request {
nua_server_methods_t const *sr_methods;
nua_owner_t *sr_owner; /**< Backpointer to handle */
nua_dialog_state_t *sr_dialog; /**< Backpointer to dialog state */
nua_dialog_usage_t *sr_usage; /**< Backpointer to usage */
nta_incoming_t *sr_irq; /**< Server transaction object */
......
This diff is collapsed.
......@@ -768,9 +768,8 @@ void nua_stack_shutdown(nua_t *nua)
busy += nua_dialog_repeat_shutdown(nh, ds);
if (nh->nh_soa) {
soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
}
if (nh->nh_ds->ds_soa)
soa_destroy(nh->nh_ds->ds_soa), nh->nh_ds->ds_soa = NULL;
if (nua_client_request_pending(ds->ds_cr))
busy++;
......@@ -906,9 +905,6 @@ void nh_destroy(nua_t *nua, nua_handle_t *nh)
nua_dialog_deinit(nh, nh->nh_ds);
if (nh->nh_soa)
soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
if (nh_is_inserted(nh))
nh_remove(nua, nh);
......
......@@ -152,8 +152,6 @@ struct nua_handle_s
auth_client_t *nh_auth; /**< Authorization objects */
soa_session_t *nh_soa; /**< Media session */
struct nua_referral {
nua_handle_t *ref_handle; /**< Referring handle */
sip_event_t *ref_event; /**< Event used with NOTIFY */
......
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