wip
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6802 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
3f581d06d0
commit
da8d9bc20f
|
@ -2,7 +2,7 @@
|
||||||
<!--the domain or ip (the right hand side of the @ in the addr-->
|
<!--the domain or ip (the right hand side of the @ in the addr-->
|
||||||
<domain name="$${domain}">
|
<domain name="$${domain}">
|
||||||
<params>
|
<params>
|
||||||
<param name="dial-string" value="sofia/${dialed_domain}/${dialed_user}"/>
|
<param name="dial-string" value="{presence_id=${dialed_user}@${dialed_domain}}sofia/${dialed_domain}/${dialed_user}"/>
|
||||||
</params>
|
</params>
|
||||||
|
|
||||||
<X-PRE-PROCESS cmd="include" data="default/*.xml"/>
|
<X-PRE-PROCESS cmd="include" data="default/*.xml"/>
|
||||||
|
|
|
@ -2125,7 +2125,7 @@ int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (du->du_cr && cr != du->du_cr) {
|
if (du->du_cr && cr != du->du_cr) {
|
||||||
assert(!nua_client_is_queued(du->du_cr));
|
|
||||||
if (nua_client_is_queued(du->du_cr))
|
if (nua_client_is_queued(du->du_cr))
|
||||||
return -1;
|
return -1;
|
||||||
if (nua_client_is_reporting(du->du_cr)) {
|
if (nua_client_is_reporting(du->du_cr)) {
|
||||||
|
|
|
@ -998,9 +998,13 @@ static int show_reg_callback(void *pArg, int argc, char **argv, char **columnNam
|
||||||
"Call-ID \t%s\n"
|
"Call-ID \t%s\n"
|
||||||
"User \t%s@%s\n"
|
"User \t%s@%s\n"
|
||||||
"Contact \t%s\n"
|
"Contact \t%s\n"
|
||||||
|
"Agent \t%s\n"
|
||||||
"Status \t%s(%s) EXP(%s)\n\n",
|
"Status \t%s(%s) EXP(%s)\n\n",
|
||||||
switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]),
|
switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]),
|
||||||
switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf);
|
switch_str_nil(argv[7]),
|
||||||
|
switch_str_nil(argv[4]),
|
||||||
|
switch_str_nil(argv[5]),
|
||||||
|
exp_buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,17 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
|
||||||
char const *phrase,
|
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[])
|
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 == 481 && sip) {
|
||||||
|
const char *call_id = sip->sip_call_id->i_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);
|
||||||
|
switch_assert(sql != NULL);
|
||||||
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
||||||
|
free(sql);
|
||||||
|
nua_handle_destroy(nh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
|
void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
|
||||||
|
@ -318,7 +329,7 @@ void event_handler(switch_event_t *event)
|
||||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
|
|
||||||
sql = switch_mprintf("insert into sip_registrations values ('%q', '%q','%q','%q','Regestered', '%q', %ld, '%q')",
|
sql = switch_mprintf("insert into sip_registrations values ('%q', '%q','%q','%q','Registered', '%q', %ld, '%q')",
|
||||||
call_id, from_user, from_host, contact_str, rpid, expires, user_agent);
|
call_id, from_user, from_host, contact_str, rpid, expires, user_agent);
|
||||||
|
|
||||||
if (sql) {
|
if (sql) {
|
||||||
|
@ -398,6 +409,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||||
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
|
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
|
||||||
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence")),
|
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence")),
|
||||||
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("dialog")),
|
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("dialog")),
|
||||||
|
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("call-info")),
|
||||||
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence.winfo")),
|
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence.winfo")),
|
||||||
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("message-summary")),
|
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("message-summary")),
|
||||||
SIPTAG_SUPPORTED_STR("100rel, precondition, timer"), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
|
SIPTAG_SUPPORTED_STR("100rel, precondition, timer"), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
|
||||||
|
|
|
@ -1233,6 +1233,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
|
if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
|
||||||
const char *stream;
|
const char *stream;
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||||
|
switch_channel_presence(tech_pvt->channel, "unknown", "hold");
|
||||||
if (tech_pvt->max_missed_packets) {
|
if (tech_pvt->max_missed_packets) {
|
||||||
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets * 10);
|
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets * 10);
|
||||||
}
|
}
|
||||||
|
@ -1251,6 +1252,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
||||||
}
|
}
|
||||||
switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
|
switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
|
||||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||||
|
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,11 @@ static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, ch
|
||||||
static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames);
|
static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char **columnNames);
|
||||||
static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames);
|
static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames);
|
||||||
|
|
||||||
|
struct presence_helper {
|
||||||
|
sofia_profile_t *profile;
|
||||||
|
switch_event_t *event;
|
||||||
|
};
|
||||||
|
|
||||||
switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
|
switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -117,7 +122,8 @@ void sofia_presence_cancel(void)
|
||||||
sofia_profile_t *profile;
|
sofia_profile_t *profile;
|
||||||
switch_hash_index_t *hi;
|
switch_hash_index_t *hi;
|
||||||
void *val;
|
void *val;
|
||||||
|
struct presence_helper helper;
|
||||||
|
|
||||||
if ((sql = switch_mprintf("select *,-1,'unavailable','unavailable' from sip_subscriptions where event='presence'"))) {
|
if ((sql = switch_mprintf("select *,-1,'unavailable','unavailable' from sip_subscriptions where event='presence'"))) {
|
||||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||||
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||||
|
@ -126,8 +132,9 @@ void sofia_presence_cancel(void)
|
||||||
if (!(profile->pflags & PFLAG_PRESENCE)) {
|
if (!(profile->pflags & PFLAG_PRESENCE)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
helper.profile = profile;
|
||||||
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_sub_callback, profile) != SWITCH_TRUE) {
|
helper.event = NULL;
|
||||||
|
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_sub_callback, &helper) != SWITCH_TRUE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,6 +282,7 @@ void sofia_presence_event_handler(switch_event_t *event)
|
||||||
char *rpid = switch_event_get_header(event, "rpid");
|
char *rpid = switch_event_get_header(event, "rpid");
|
||||||
char *status = switch_event_get_header(event, "status");
|
char *status = switch_event_get_header(event, "status");
|
||||||
char *event_type = switch_event_get_header(event, "event_type");
|
char *event_type = switch_event_get_header(event, "event_type");
|
||||||
|
char *alt_event_type = switch_event_get_header(event, "alt_event_type");
|
||||||
char *sql = NULL;
|
char *sql = NULL;
|
||||||
char *euser = NULL, *user = NULL, *host = NULL;
|
char *euser = NULL, *user = NULL, *host = NULL;
|
||||||
|
|
||||||
|
@ -309,7 +317,8 @@ void sofia_presence_event_handler(switch_event_t *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->event_id == SWITCH_EVENT_ROSTER) {
|
if (event->event_id == SWITCH_EVENT_ROSTER) {
|
||||||
|
struct presence_helper helper;
|
||||||
|
|
||||||
if (from) {
|
if (from) {
|
||||||
sql = switch_mprintf("select *,1,'%q','%q' from sip_subscriptions where event='presence' and full_from like '%%%q%%'", status, rpid, from);
|
sql = switch_mprintf("select *,1,'%q','%q' from sip_subscriptions where event='presence' and full_from like '%%%q%%'", status, rpid, from);
|
||||||
} else {
|
} else {
|
||||||
|
@ -324,13 +333,14 @@ void sofia_presence_event_handler(switch_event_t *event)
|
||||||
if (!(profile->pflags & PFLAG_PRESENCE)) {
|
if (!(profile->pflags & PFLAG_PRESENCE)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
helper.profile = profile;
|
||||||
|
helper.event = NULL;
|
||||||
sofia_glue_execute_sql_callback(profile,
|
sofia_glue_execute_sql_callback(profile,
|
||||||
SWITCH_FALSE,
|
SWITCH_FALSE,
|
||||||
profile->ireg_mutex,
|
profile->ireg_mutex,
|
||||||
sql,
|
sql,
|
||||||
sofia_presence_sub_callback,
|
sofia_presence_sub_callback,
|
||||||
profile);
|
&helper);
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||||
free(sql);
|
free(sql);
|
||||||
|
@ -341,6 +351,10 @@ void sofia_presence_event_handler(switch_event_t *event)
|
||||||
event_type = "presence";
|
event_type = "presence";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_strlen_zero(alt_event_type)) {
|
||||||
|
alt_event_type = "presence";
|
||||||
|
}
|
||||||
|
|
||||||
if ((user = strdup(from))) {
|
if ((user = strdup(from))) {
|
||||||
if ((host = strchr(user, '@'))) {
|
if ((host = strchr(user, '@'))) {
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -399,14 +413,14 @@ void sofia_presence_event_handler(switch_event_t *event)
|
||||||
case SWITCH_EVENT_PRESENCE_IN:
|
case SWITCH_EVENT_PRESENCE_IN:
|
||||||
sql =
|
sql =
|
||||||
switch_mprintf
|
switch_mprintf
|
||||||
("select *,1,'%q','%q' from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'",
|
("select *,1,'%q','%q' from sip_subscriptions where proto='%q' and (event='%q' or event='%q') and sub_to_user='%q' and sub_to_host='%q'",
|
||||||
status, rpid, proto, event_type, euser, host);
|
status, rpid, proto, event_type, alt_event_type, euser, host);
|
||||||
break;
|
break;
|
||||||
case SWITCH_EVENT_PRESENCE_OUT:
|
case SWITCH_EVENT_PRESENCE_OUT:
|
||||||
sql =
|
sql =
|
||||||
switch_mprintf
|
switch_mprintf
|
||||||
("select *,0,'%q','%q' from sip_subscriptions where proto='%q' and event='%q' and sub_to_user='%q' and sub_to_host='%q'",
|
("select *,0,'%q','%q' from sip_subscriptions where proto='%q' and (event='%q' or event='%q') and sub_to_user='%q' and sub_to_host='%q'",
|
||||||
status, rpid, proto, event_type, euser, host);
|
status, rpid, proto, event_type, alt_event_type, euser, host);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -421,12 +435,15 @@ void sofia_presence_event_handler(switch_event_t *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sql) {
|
if (sql) {
|
||||||
|
struct presence_helper helper;
|
||||||
|
helper.profile = profile;
|
||||||
|
helper.event = event;
|
||||||
sofia_glue_execute_sql_callback(profile,
|
sofia_glue_execute_sql_callback(profile,
|
||||||
SWITCH_FALSE,
|
SWITCH_FALSE,
|
||||||
profile->ireg_mutex,
|
profile->ireg_mutex,
|
||||||
sql,
|
sql,
|
||||||
sofia_presence_sub_callback,
|
sofia_presence_sub_callback,
|
||||||
profile);
|
&helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||||
|
@ -455,13 +472,14 @@ static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, ch
|
||||||
if (switch_strlen_zero(status)) {
|
if (switch_strlen_zero(status)) {
|
||||||
status = "Available";
|
status = "Available";
|
||||||
}
|
}
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->url);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", user, host);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", user, host);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_subtype", "probe");
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_subtype", "probe");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto-specific-event-name", "%s", event_name);
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +547,8 @@ static char *translate_rpid(char *in)
|
||||||
|
|
||||||
static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames)
|
static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||||
{
|
{
|
||||||
sofia_profile_t *profile = (sofia_profile_t *) pArg;
|
struct presence_helper *helper = (struct presence_helper *) pArg;
|
||||||
|
sofia_profile_t *profile = helper->profile;
|
||||||
char *pl;
|
char *pl;
|
||||||
char *id, *note;
|
char *id, *note;
|
||||||
uint32_t in = atoi(argv[13]);
|
uint32_t in = atoi(argv[13]);
|
||||||
|
@ -584,34 +603,68 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||||
}
|
}
|
||||||
|
|
||||||
to = switch_mprintf("sip:%s@%s", user, host);
|
to = switch_mprintf("sip:%s@%s", user, host);
|
||||||
pl = switch_mprintf("<?xml version='1.0' encoding='UTF-8'?>\r\n"
|
|
||||||
"<presence xmlns='urn:ietf:params:xml:ns:pidf'\r\n"
|
if (!strcmp(event, "dialog") && helper->event) {
|
||||||
"xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model'\r\n"
|
switch_stream_handle_t stream = { 0 };
|
||||||
"xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid'\r\n"
|
//const char *direction = switch_str_nil(switch_event_get_header(helper->event, "call-direction"));
|
||||||
"xmlns:c='urn:ietf:params:xml:ns:pidf:cipid'\r\n"
|
const char *uuid = switch_str_nil(switch_event_get_header(helper->event, "unique-id"));
|
||||||
"entity='pres:%s'>\r\n"
|
const char *state = switch_str_nil(switch_event_get_header(helper->event, "channel-state"));
|
||||||
"<presentity uri=\"%s;method=SUBSCRIBE\"/>\r\n"
|
const char *status = switch_str_nil(switch_event_get_header(helper->event, "status"));
|
||||||
"<atom id=\"1002\">\r\n"
|
|
||||||
"<address uri=\"%s\" priority=\"0.800000\">\r\n"
|
SWITCH_STANDARD_STREAM(stream);
|
||||||
"<status status=\"%s\">\r\n"
|
|
||||||
"<note>%s</note>\r\n"
|
|
||||||
"</status>\r\n"
|
stream.write_function(&stream,
|
||||||
"<msnsubstatus substatus=\"%s\"/>\r\n"
|
"<?xml version=\"1.0\"?>\n"
|
||||||
"</address>\r\n"
|
"<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" "
|
||||||
"</atom>\r\n"
|
"version=\"%s\" state=\"full\" entity=\"%s\">\n",
|
||||||
"<tuple id='t6a5ed77e'>\r\n"
|
switch_str_nil(switch_event_get_header(helper->event, "event_count")), to);
|
||||||
"<status>\r\n"
|
|
||||||
"<basic>%s</basic>\r\n"
|
if (!strcasecmp(state, "RING")) {
|
||||||
"</status>\r\n"
|
stream.write_function(&stream, "<dialog id=\"%s\" direction=\"recipient\">\n", uuid);
|
||||||
"</tuple>\r\n"
|
} else {
|
||||||
"<dm:person id='p06360c4a'>\r\n"
|
stream.write_function(&stream, "<dialog id=\"%s\">\n", uuid);
|
||||||
"<rpid:activities>\r\n" "<rpid:%s/>\r\n"
|
}
|
||||||
"</rpid:activities>%s</dm:person>\r\n"
|
|
||||||
"</presence>", id,
|
stream.write_function(&stream, "<state>%s</state>\n", switch_str_nil(switch_event_get_header(helper->event, "answer-state")));
|
||||||
id, profile->url, open, status, prpid,
|
if (!strcasecmp(status, "hold")) {
|
||||||
open, rpid, note);
|
stream.write_function(&stream, "<local>\n<target uri=\"%s\">\n"
|
||||||
|
"<param pname=\"+sip.rendering\" pvalue=\"no\">\n"
|
||||||
|
"</target>\n</local>\n", to);
|
||||||
|
}
|
||||||
|
stream.write_function(&stream, "</dialog>\n</dialog-info>\n");
|
||||||
|
pl = stream.data;
|
||||||
|
} else {
|
||||||
|
pl = switch_mprintf("<?xml version='1.0' encoding='UTF-8'?>\r\n"
|
||||||
|
"<presence xmlns='urn:ietf:params:xml:ns:pidf'\r\n"
|
||||||
|
"xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model'\r\n"
|
||||||
|
"xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid'\r\n"
|
||||||
|
"xmlns:c='urn:ietf:params:xml:ns:pidf:cipid'\r\n"
|
||||||
|
"entity='pres:%s'>\r\n"
|
||||||
|
"<presentity uri=\"%s;method=SUBSCRIBE\"/>\r\n"
|
||||||
|
"<atom id=\"1002\">\r\n"
|
||||||
|
"<address uri=\"%s\" priority=\"0.800000\">\r\n"
|
||||||
|
"<status status=\"%s\">\r\n"
|
||||||
|
"<note>%s</note>\r\n"
|
||||||
|
"</status>\r\n"
|
||||||
|
"<msnsubstatus substatus=\"%s\"/>\r\n"
|
||||||
|
"</address>\r\n"
|
||||||
|
"</atom>\r\n"
|
||||||
|
"<tuple id='t6a5ed77e'>\r\n"
|
||||||
|
"<status>\r\n"
|
||||||
|
"<basic>%s</basic>\r\n"
|
||||||
|
"</status>\r\n"
|
||||||
|
"</tuple>\r\n"
|
||||||
|
"<dm:person id='p06360c4a'>\r\n"
|
||||||
|
"<rpid:activities>\r\n" "<rpid:%s/>\r\n"
|
||||||
|
"</rpid:activities>%s</dm:person>\r\n"
|
||||||
|
"</presence>", id,
|
||||||
|
id, profile->url, open, status, prpid,
|
||||||
|
open, rpid, note);
|
||||||
|
}
|
||||||
|
|
||||||
nua_notify(nh,
|
nua_notify(nh,
|
||||||
|
NUTAG_NEWSUB(1),
|
||||||
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=3600"),
|
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=3600"),
|
||||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
||||||
|
|
||||||
|
@ -666,6 +719,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
||||||
exp = switch_mprintf("active;expires=%ld", expire_sec);
|
exp = switch_mprintf("active;expires=%ld", expire_sec);
|
||||||
|
|
||||||
nua_notify(nh,
|
nua_notify(nh,
|
||||||
|
NUTAG_NEWSUB(1),
|
||||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||||
|
|
||||||
|
@ -745,10 +799,13 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
const char *display = "\"user\"";
|
const char *display = "\"user\"";
|
||||||
switch_event_t *sevent;
|
switch_event_t *sevent;
|
||||||
int sub_state;
|
int sub_state;
|
||||||
|
int sent_reply = 0;
|
||||||
|
|
||||||
tl_gets(tags,
|
tl_gets(tags,
|
||||||
NUTAG_SUBSTATE_REF(sub_state), TAG_END());
|
NUTAG_SUBSTATE_REF(sub_state), TAG_END());
|
||||||
|
|
||||||
|
event = sip_header_as_string(profile->home, (void *) sip->sip_event);
|
||||||
|
|
||||||
if (contact) {
|
if (contact) {
|
||||||
char *port = (char *) contact->m_url->url_port;
|
char *port = (char *) contact->m_url->url_port;
|
||||||
|
|
||||||
|
@ -818,7 +875,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host);
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", from_user, from_host);
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, to_host);
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, to_host);
|
||||||
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto-specific-event-name", "%s", event);
|
||||||
switch_event_fire(&sevent);
|
switch_event_fire(&sevent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,7 +900,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
}
|
}
|
||||||
|
|
||||||
call_id = sip->sip_call_id->i_id;
|
call_id = sip->sip_call_id->i_id;
|
||||||
event = sip_header_as_string(profile->home, (void *) sip->sip_event);
|
|
||||||
full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
|
full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
|
||||||
full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
|
full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
|
||||||
|
|
||||||
|
@ -881,20 +937,31 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
|
|
||||||
switch_mutex_unlock(profile->ireg_mutex);
|
switch_mutex_unlock(profile->ireg_mutex);
|
||||||
sstr = switch_mprintf("active;expires=%ld", exp_raw);
|
sstr = switch_mprintf("active;expires=%ld", exp_raw);
|
||||||
switch_core_hash_insert(profile->sub_hash, call_id, nh);
|
if (status < 200) {
|
||||||
|
switch_core_hash_insert(profile->sub_hash, call_id, nh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status < 200) {
|
||||||
|
nua_respond(nh, SIP_202_ACCEPTED,
|
||||||
|
NUTAG_WITH_THIS(nua),
|
||||||
|
SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
|
||||||
|
SIPTAG_FROM(sip->sip_to),
|
||||||
|
SIPTAG_TO(sip->sip_from),
|
||||||
|
SIPTAG_CONTACT_STR(contact_str),
|
||||||
|
TAG_END());
|
||||||
|
}
|
||||||
|
|
||||||
|
sent_reply++;
|
||||||
|
|
||||||
nua_respond(nh, SIP_202_ACCEPTED,
|
#if 0
|
||||||
NUTAG_WITH_THIS(nua),
|
nua_notify(nh,
|
||||||
SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
|
NUTAG_NEWSUB(1),
|
||||||
SIPTAG_FROM(sip->sip_to),
|
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event),
|
||||||
SIPTAG_TO(sip->sip_from),
|
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
|
||||||
SIPTAG_CONTACT_STR(contact_str),
|
SIPTAG_PAYLOAD_STR("Note: Come to ClueCon http://www.cluecon.com\n\n"),
|
||||||
TAG_END());
|
|
||||||
|
|
||||||
nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/octet-stream"),
|
|
||||||
SIPTAG_PAYLOAD_STR("Come to ClueCon http://www.cluecon.com\n\n"),
|
|
||||||
TAG_END());
|
TAG_END());
|
||||||
|
#endif
|
||||||
|
|
||||||
switch_safe_free(sstr);
|
switch_safe_free(sstr);
|
||||||
|
|
||||||
|
@ -930,7 +997,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
switch_safe_free(d_user);
|
switch_safe_free(d_user);
|
||||||
switch_safe_free(to_str);
|
switch_safe_free(to_str);
|
||||||
switch_safe_free(contact_str);
|
switch_safe_free(contact_str);
|
||||||
|
|
||||||
|
if (!sent_reply) {
|
||||||
|
nua_respond(nh, 481, "INVALID SUBSCRIPTION", TAG_END());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sofia_presence_handle_sip_r_subscribe(int status,
|
void sofia_presence_handle_sip_r_subscribe(int status,
|
||||||
|
|
|
@ -120,6 +120,7 @@ struct switch_channel {
|
||||||
switch_hash_t *private_hash;
|
switch_hash_t *private_hash;
|
||||||
switch_call_cause_t hangup_cause;
|
switch_call_cause_t hangup_cause;
|
||||||
int vi;
|
int vi;
|
||||||
|
int event_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,6 +306,7 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_channel_event_set_data(channel, event);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%s", __FILE__);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%s", __FILE__);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", id);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", id);
|
||||||
|
@ -316,6 +318,8 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
|
||||||
}
|
}
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++);
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,8 +591,11 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
|
||||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n",
|
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n",
|
||||||
channel->name, state_names[channel->state]);
|
channel->name, state_names[channel->state]);
|
||||||
channel->running_state = channel->state;
|
channel->running_state = channel->state;
|
||||||
|
|
||||||
|
|
||||||
|
if (channel->state >= CS_RING) {
|
||||||
|
switch_channel_presence(channel, "unknown", (char *) state_names[channel->state]);
|
||||||
|
}
|
||||||
|
|
||||||
if (channel->state < CS_HANGUP) {
|
if (channel->state < CS_HANGUP) {
|
||||||
switch_event_t *event;
|
switch_event_t *event;
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -601,6 +608,14 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%s", (char *) state_num);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%s", (char *) state_num);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", channel->name);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", channel->name);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Call-Direction", "%s", switch_channel_test_flag(channel, CF_OUTBOUND) ? "outbound" : "inbound");
|
||||||
|
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "confirmed");
|
||||||
|
} else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "early");
|
||||||
|
} else {
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "ringing");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
|
@ -799,9 +814,6 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
|
||||||
|
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
if (state > CS_RING) {
|
|
||||||
switch_channel_presence(channel, "unknown", (char *) state_names[state]);
|
|
||||||
}
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
|
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
|
||||||
channel->name, state_names[last_state], state_names[state]);
|
channel->name, state_names[last_state], state_names[state]);
|
||||||
switch_mutex_lock(channel->flag_mutex);
|
switch_mutex_lock(channel->flag_mutex);
|
||||||
|
@ -858,6 +870,15 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", switch_channel_get_name(channel));
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", switch_channel_get_name(channel));
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
|
||||||
|
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Call-Direction", "%s", switch_channel_test_flag(channel, CF_OUTBOUND) ? "outbound" : "inbound");
|
||||||
|
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "answered");
|
||||||
|
} else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "early");
|
||||||
|
} else {
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Answer-State", "ringing");
|
||||||
|
}
|
||||||
|
|
||||||
if ((codec = switch_core_session_get_read_codec(channel->session)) && codec->implementation) {
|
if ((codec = switch_core_session_get_read_codec(channel->session)) && codec->implementation) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", "%s", switch_str_nil(codec->implementation->iananame));
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", "%s", switch_str_nil(codec->implementation->iananame));
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", codec->implementation->actual_samples_per_second);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", codec->implementation->actual_samples_per_second);
|
||||||
|
|
Loading…
Reference in New Issue