use this one
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8296 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a869f867d2
commit
6c17e72694
|
@ -196,6 +196,7 @@ struct mod_sofia_globals {
|
|||
switch_queue_t *presence_queue;
|
||||
switch_queue_t *mwi_queue;
|
||||
struct sofia_private destroy_private;
|
||||
struct sofia_private keep_private;
|
||||
};
|
||||
extern struct mod_sofia_globals mod_sofia_globals;
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ void sofia_event_callback(nua_event_t event,
|
|||
switch_channel_t *channel = NULL;
|
||||
sofia_gateway_t *gateway = NULL;
|
||||
|
||||
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private) {
|
||||
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
|
||||
if ((gateway = sofia_private->gateway)) {
|
||||
if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile %s is locked\n", gateway->profile->name);
|
||||
|
@ -339,9 +339,15 @@ void sofia_event_callback(nua_event_t event,
|
|||
|
||||
done:
|
||||
|
||||
if ((sofia_private && sofia_private->destroy_nh) || !nua_handle_magic(nh)) {
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy handle requested.\n");
|
||||
nua_handle_destroy(nh);
|
||||
switch (event) {
|
||||
case nua_i_subscribe:
|
||||
break;
|
||||
default:
|
||||
if (nh && ((sofia_private && sofia_private->destroy_nh) || !nua_handle_magic(nh))) {
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Destroy handle [%s]\n", nua_event_name(event));
|
||||
nua_handle_destroy(nh);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (gateway) {
|
||||
|
|
|
@ -107,7 +107,6 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char
|
|||
SIPTAG_CONTACT_STR(profile->url), TAG_END());
|
||||
|
||||
switch_safe_free(contact);
|
||||
nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private);
|
||||
nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
||||
switch_safe_free(ffrom);
|
||||
|
@ -1043,7 +1042,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
}
|
||||
|
||||
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);
|
||||
|
||||
nua_handle_bind(nh, &mod_sofia_globals.keep_private);
|
||||
nua_notify(nh,
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
||||
|
@ -1096,7 +1095,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
|||
expire_sec = 3600;
|
||||
}
|
||||
exp = switch_mprintf("active;expires=%ld", expire_sec);
|
||||
|
||||
nua_handle_bind(nh, &mod_sofia_globals.keep_private);
|
||||
nua_notify(nh,
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
@ -1140,7 +1139,6 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
|
|||
SIPTAG_CONTACT_STR(profile->url),
|
||||
TAG_END());
|
||||
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
@ -1338,7 +1336,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||
sent_reply++;
|
||||
|
||||
#if 0
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event),
|
||||
|
|
|
@ -97,6 +97,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
|||
|
||||
switch (ostate) {
|
||||
case REG_STATE_NOREG:
|
||||
gateway_ptr->status = SOFIA_GATEWAY_UP;
|
||||
break;
|
||||
case REG_STATE_REGISTER:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "registered %s\n", gateway_ptr->name);
|
||||
|
@ -110,7 +111,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
|||
gateway_ptr->state = REG_STATE_NOREG;
|
||||
break;
|
||||
case REG_STATE_UNREGED:
|
||||
|
||||
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
|
||||
if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL,
|
||||
|
@ -204,6 +205,20 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sofia_sub_del_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
{
|
||||
sofia_profile_t *profile = (sofia_profile_t *) pArg;
|
||||
nua_handle_t *nh;
|
||||
|
||||
if (argv[0]) {
|
||||
if ((nh = nua_handle_by_call_id(profile->nua, argv[0]))) {
|
||||
nua_handle_destroy(nh);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
{
|
||||
switch_event_t *s_event;
|
||||
|
@ -262,13 +277,15 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "select *,'%s' from sip_registrations where expires > 0 and expires <= %ld", profile->name, (long) now);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "select *,'%s' from sip_registrations where expires > 0", profile->name);
|
||||
}
|
||||
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
|
@ -291,6 +308,21 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
|||
|
||||
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||
|
||||
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where expires > 0");
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
sql,
|
||||
sofia_sub_del_callback,
|
||||
profile);
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue