git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9652 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-09-26 14:37:50 +00:00
parent 1ec3bf6818
commit f428a89f4c

View File

@ -2099,34 +2099,32 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
return cause; return cause;
} }
static void general_event_handler(switch_event_t *event)
static int notify_callback(void *pArg, int argc, char **argv, char **columnNames)
{ {
switch (event->event_id) {
case SWITCH_EVENT_NOTIFY:
{
const char *profile_name = switch_event_get_header(event, "profile");
const char *ct = switch_event_get_header(event, "content-type");
const char *es = switch_event_get_header(event, "event-string");
const char *user = switch_event_get_header(event, "user");
const char *host = switch_event_get_header(event, "host");
const char *body = switch_event_get_body(event);
sofia_profile_t *profile;
nua_handle_t *nh; nua_handle_t *nh;
sofia_profile_t *ext_profile = NULL, *profile = (sofia_profile_t *) pArg;
if (profile_name && ct && es && user && host && (profile = sofia_glue_find_profile(profile_name))) { char *user = argv[0];
char *host = argv[1];
char *contact_in = argv[2];
char *profile_name = argv[3];
char *ct = argv[4];
char *es = argv[5];
char *body = argv[6];
char *id = NULL; char *id = NULL;
char *contact, *p; char *p , *contact;
char buf[512] = "";
if (!sofia_reg_find_reg_url(profile, user, host, buf, sizeof(buf))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find user %s@%s\n", user, host); if (profile_name && strcasecmp(profile_name, profile->name)) {
return; if ((ext_profile = sofia_glue_find_profile(profile_name))) {
profile = ext_profile;
}
} }
id = switch_mprintf("sip:%s@%s", user, host); id = switch_mprintf("sip:%s@%s", user, host);
switch_assert(id); switch_assert(id);
contact = sofia_glue_get_url_from_contact(buf, 0); contact = sofia_glue_get_url_from_contact(contact_in, 1);
if ((p = strstr(contact, ";fs_"))) { if ((p = strstr(contact, ";fs_"))) {
*p = '\0'; *p = '\0';
@ -2149,6 +2147,38 @@ static void general_event_handler(switch_event_t *event)
free(id); free(id);
free(contact);
if (ext_profile) {
sofia_glue_release_profile(ext_profile);
}
return 0;
}
static void general_event_handler(switch_event_t *event)
{
switch (event->event_id) {
case SWITCH_EVENT_NOTIFY:
{
const char *profile_name = switch_event_get_header(event, "profile");
const char *ct = switch_event_get_header(event, "content-type");
const char *es = switch_event_get_header(event, "event-string");
const char *user = switch_event_get_header(event, "user");
const char *host = switch_event_get_header(event, "host");
const char *body = switch_event_get_body(event);
sofia_profile_t *profile;
if (profile_name && ct && es && user && host && (profile = sofia_glue_find_profile(profile_name))) {
char *sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
"from sip_registrations where sip_user='%s' and sip_host='%q'",
ct, es, body, user, host
);
switch_mutex_lock(profile->ireg_mutex);
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, notify_callback, profile);
switch_mutex_unlock(profile->ireg_mutex);
sofia_glue_release_profile(profile); sofia_glue_release_profile(profile);
} }