char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
- if (status >= 300 && sip) {
- const char *call_id = sip->sip_call_id->i_id;
+ if (status >= 300 && sip && sip->sip_call_id) {
char *sql;
- switch_core_hash_delete(profile->sub_hash, call_id);
- sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
+ sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", sip->sip_call_id->i_id);
switch_assert(sql != NULL);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
nua_handle_destroy(nh);
sofia_glue_del_profile(profile);
switch_core_hash_destroy(&profile->chat_hash);
- switch_core_hash_destroy(&profile->sub_hash);
switch_thread_rwlock_unlock(profile->rwlock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
profile->dbname = switch_core_strdup(profile->pool, url);
switch_core_hash_init(&profile->chat_hash, profile->pool);
- switch_core_hash_init(&profile->sub_hash, profile->pool);
switch_thread_rwlock_create(&profile->rwlock, profile->pool);
switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
profile->dtmf_duration = 100;
}
}
- //if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
- if (!(nh = (nua_handle_t *) switch_core_hash_find(profile->sub_hash, call_id))) {
+ if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
return 0;
}
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);
nua_notify(nh,
- //NUTAG_NEWSUB(1),
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
- if (done) {
- switch_core_hash_delete(profile->sub_hash, call_id);
- }
-
end:
switch_safe_free(id);
return 0;
}
- //if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
- if (!(nh = (nua_handle_t *) switch_core_hash_find(profile->sub_hash, call_id))) {
+ if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
return 0;
}
exp = switch_mprintf("active;expires=%ld", expire_sec);
nua_notify(nh,
- //NUTAG_NEWSUB(1),
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
if (sub_state == nua_substate_terminated) {
sstr = switch_mprintf("terminated");
- switch_core_hash_delete(profile->sub_hash, call_id);
} else {
sip_accept_t *ap = sip->sip_accept;
char accept[256] = "";
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
sstr = switch_mprintf("active;expires=%ld", exp_raw);
- if (status < 200) {
- switch_core_hash_insert(profile->sub_hash, call_id, nh);
- }
}
switch_mutex_unlock(profile->ireg_mutex);