mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9652 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1ec3bf6818
commit
f428a89f4c
@ -2099,6 +2099,63 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int notify_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||||
|
{
|
||||||
|
|
||||||
|
nua_handle_t *nh;
|
||||||
|
sofia_profile_t *ext_profile = NULL, *profile = (sofia_profile_t *) pArg;
|
||||||
|
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 *p , *contact;
|
||||||
|
|
||||||
|
|
||||||
|
if (profile_name && strcasecmp(profile_name, profile->name)) {
|
||||||
|
if ((ext_profile = sofia_glue_find_profile(profile_name))) {
|
||||||
|
profile = ext_profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id = switch_mprintf("sip:%s@%s", user, host);
|
||||||
|
switch_assert(id);
|
||||||
|
contact = sofia_glue_get_url_from_contact(contact_in, 1);
|
||||||
|
|
||||||
|
if ((p = strstr(contact, ";fs_"))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
nh = nua_handle(profile->nua,
|
||||||
|
NULL,
|
||||||
|
NUTAG_URL(contact),
|
||||||
|
SIPTAG_FROM_STR(id),
|
||||||
|
SIPTAG_TO_STR(id),
|
||||||
|
SIPTAG_CONTACT_STR(profile->url),
|
||||||
|
TAG_END());
|
||||||
|
|
||||||
|
nua_notify(nh,
|
||||||
|
NUTAG_NEWSUB(1),
|
||||||
|
SIPTAG_EVENT_STR(es),
|
||||||
|
SIPTAG_CONTENT_TYPE_STR(ct),
|
||||||
|
TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)),
|
||||||
|
TAG_END());
|
||||||
|
|
||||||
|
|
||||||
|
free(id);
|
||||||
|
free(contact);
|
||||||
|
|
||||||
|
if (ext_profile) {
|
||||||
|
sofia_glue_release_profile(ext_profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void general_event_handler(switch_event_t *event)
|
static void general_event_handler(switch_event_t *event)
|
||||||
{
|
{
|
||||||
switch (event->event_id) {
|
switch (event->event_id) {
|
||||||
@ -2111,47 +2168,20 @@ static void general_event_handler(switch_event_t *event)
|
|||||||
const char *host = switch_event_get_header(event, "host");
|
const char *host = switch_event_get_header(event, "host");
|
||||||
const char *body = switch_event_get_body(event);
|
const char *body = switch_event_get_body(event);
|
||||||
sofia_profile_t *profile;
|
sofia_profile_t *profile;
|
||||||
nua_handle_t *nh;
|
|
||||||
|
|
||||||
if (profile_name && ct && es && user && host && (profile = sofia_glue_find_profile(profile_name))) {
|
if (profile_name && ct && es && user && host && (profile = sofia_glue_find_profile(profile_name))) {
|
||||||
char *id = NULL;
|
char *sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
|
||||||
char *contact, *p;
|
"from sip_registrations where sip_user='%s' and sip_host='%q'",
|
||||||
char buf[512] = "";
|
ct, es, body, user, host
|
||||||
|
);
|
||||||
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);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
id = switch_mprintf("sip:%s@%s", user, host);
|
|
||||||
|
|
||||||
switch_assert(id);
|
|
||||||
contact = sofia_glue_get_url_from_contact(buf, 0);
|
|
||||||
|
|
||||||
if ((p = strstr(contact, ";fs_"))) {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
nh = nua_handle(profile->nua,
|
switch_mutex_lock(profile->ireg_mutex);
|
||||||
NULL,
|
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, notify_callback, profile);
|
||||||
NUTAG_URL(contact),
|
switch_mutex_unlock(profile->ireg_mutex);
|
||||||
SIPTAG_FROM_STR(id),
|
|
||||||
SIPTAG_TO_STR(id),
|
|
||||||
SIPTAG_CONTACT_STR(profile->url),
|
|
||||||
TAG_END());
|
|
||||||
|
|
||||||
nua_notify(nh,
|
|
||||||
NUTAG_NEWSUB(1),
|
|
||||||
SIPTAG_EVENT_STR(es),
|
|
||||||
SIPTAG_CONTENT_TYPE_STR(ct),
|
|
||||||
TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)),
|
|
||||||
TAG_END());
|
|
||||||
|
|
||||||
|
|
||||||
free(id);
|
|
||||||
sofia_glue_release_profile(profile);
|
sofia_glue_release_profile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_EVENT_SEND_MESSAGE:
|
case SWITCH_EVENT_SEND_MESSAGE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user