diff -ur sofia-sip-1.12.3.3/libsofia-sip-ua/msg/msg.c ../sofia-sip-1.12.3.3/libsofia-sip-ua/msg/msg.c --- sofia-sip-1.12.3.3/libsofia-sip-ua/msg/msg.c 2006-10-09 13:57:21.000000000 -0500 +++ ../sofia-sip-1.12.3.3/libsofia-sip-ua/msg/msg.c 2006-10-13 22:01:55.980878152 -0500 @@ -204,7 +204,7 @@ */ msg_pub_t *msg_public(msg_t const *msg, void *tag) { - if (msg && msg->m_class->mc_tag == tag) + if (msg && msg->m_class->mc_tag == tag) return msg->m_object; else return NULL; diff -ur sofia-sip-1.12.3.3/libsofia-sip-ua/nta/nta.c ../sofia-sip-1.12.3.3/libsofia-sip-ua/nta/nta.c --- sofia-sip-1.12.3.3/libsofia-sip-ua/nta/nta.c 2006-10-09 13:57:21.000000000 -0500 +++ ../sofia-sip-1.12.3.3/libsofia-sip-ua/nta/nta.c 2006-10-14 23:16:39.419417056 -0500 @@ -6513,8 +6513,9 @@ url_param(sip->sip_route->r_url->url_params, "lr", NULL, 0)) route_url = (url_string_t *)sip->sip_route->r_url; - if (!(orq = su_zalloc(agent->sa_home, sizeof(*orq)))) + if (!(orq = su_zalloc(agent->sa_home, sizeof(*orq)))) { return NULL; + } tp_ident = tpn ? tpn->tpn_ident : NULL; @@ -6709,14 +6710,12 @@ retval = NULL, orq->orq_request = NULL; outgoing_free(orq); - return retval; } assert(orq->orq_queue); outgoing_insert(agent, orq); - return orq; } diff -ur sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_notifier.c ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_notifier.c --- sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_notifier.c 2006-10-09 13:57:21.000000000 -0500 +++ ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_notifier.c 2006-10-14 23:15:26.102562912 -0500 @@ -122,27 +122,26 @@ enter; - if (nh) - du = nua_dialog_usage_get(ds = nh->nh_ds, nua_notify_usage, o); + if (nh == NULL) + if (!(nh = nua_stack_incoming_handle(nua, irq, sip, 0))) + return 500; /* Respond with 500 Internal Server Error */ - if (nh == NULL || du == NULL) { - /* Hard-coded support only for refer subscriptions */ - if (o && str0cmp(o->o_type, "refer") == 0) - nta_incoming_treply(irq, SET_STATUS1(SIP_403_FORBIDDEN), TAG_END()); - else - nta_incoming_treply(irq, - SET_STATUS1(SIP_489_BAD_EVENT), - SIPTAG_ALLOW_EVENTS_STR("refer"), - SIPTAG_ACCEPT_STR("message/sipfrag"), - TAG_END()); - nua_stack_event(nua, nh, nta_incoming_getrequest(irq), - nua_i_subscribe, status, phrase, - NUTAG_SUBSTATE(nua_substate_terminated), - TAG_END()); + //if (nh) + //du = nua_dialog_usage_get(ds = nh->nh_ds, nua_notify_usage, o); - return status; - } + //if (nh == NULL || du == NULL) { + + /* Let the callback decide */ + nh->nh_suber = irq; + + nua_stack_event(nua, nh, nta_incoming_getrequest(irq), + nua_i_subscribe, SIP_100_TRYING, + NUTAG_SUBSTATE(nua_substate_pending), + TAG_END()); + + return 0; + //} /* Refresh existing subscription */ nu = nua_dialog_usage_private(du); assert(nh && du && nu); @@ -234,9 +233,10 @@ SIP_METHOD_NOTIFY, NUTAG_ADD_CONTACT(1), TAG_NEXT(tags)); - + sip = sip_object(msg); - if (!sip) + + if (!sip) return UA_EVENT1(e, NUA_INTERNAL_ERROR); du = nua_dialog_usage_get(nh->nh_ds, nua_notify_usage, sip->sip_event); @@ -315,16 +315,20 @@ msg_header_insert(msg, (void *)sip, (void *)ss); } - if (du) { - if (nu->nu_substate == nua_substate_terminated) - du->du_terminating = 1; + if (1 || du) { + // if (nu->nu_substate == nua_substate_terminated) + //du->du_terminating = 1; cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta, process_response_to_notify, nh, NULL, msg, SIPTAG_END(), TAG_NEXT(tags)); + } else { + printf("XXXXXXXXXXXXXXXXXXXXXXXXX FUCK\n"); } + if (!cr->cr_orq) { + msg_destroy(msg); return UA_EVENT1(e, NUA_INTERNAL_ERROR); } diff -ur sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_publish.c ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_publish.c --- sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_publish.c 2006-10-09 13:57:21.000000000 -0500 +++ ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_publish.c 2006-10-14 14:47:56.749947424 -0500 @@ -409,8 +409,8 @@ if (!(nh = nua_stack_incoming_handle(nua, irq, sip, 0))) return 500; /* Respond with 500 Internal Server Error */ + nh->nh_publisher = irq; nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq), - nua_i_publish, SIP_501_NOT_IMPLEMENTED, TAG_END()); - - return 501; /* Respond automatically with 501 Not Implemented */ + nua_i_publish, SIP_200_OK, TAG_END()); + return 0; } diff -ur sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.c ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.c --- sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.c 2006-10-09 13:57:21.000000000 -0500 +++ ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.c 2006-10-14 14:47:05.340762808 -0500 @@ -1761,6 +1761,18 @@ return; } + if (nh->nh_suber) { + nta_incoming_treply(nh->nh_suber, status, phrase, + TAG_NEXT(tags)); + return; + } + + if (nh->nh_publisher) { + nta_incoming_treply(nh->nh_publisher, status, phrase, + TAG_NEXT(tags)); + return; + } + if (nh->nh_registrar) { tagi_t const *t = tl_find_last(tags, nutag_with); diff -ur sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.h ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.h --- sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.h 2006-10-09 13:57:21.000000000 -0500 +++ ../sofia-sip-1.12.3.3/libsofia-sip-ua/nua/nua_stack.h 2006-10-14 14:46:49.183219128 -0500 @@ -248,6 +248,8 @@ nea_server_t *nh_notifier; /**< SIP notifier */ nta_incoming_t * nh_registrar; + nta_incoming_t * nh_suber; + nta_incoming_t * nh_publisher; }; #define NH_IS_VALID(nh) ((nh) && (nh)->nh_valid)