blinking lights for xmas presence
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6849 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
cc30c441b9
commit
5355075c60
|
@ -3,7 +3,7 @@
|
|||
<configuration name="conference.conf" description="Audio Conference">
|
||||
<!-- Advertise certain presence on startup . -->
|
||||
<advertise>
|
||||
<room name="888@$${server_name}" status="FreeSWITCH"/>
|
||||
<room name="3001@$${domain}" status="FreeSWITCH"/>
|
||||
</advertise>
|
||||
|
||||
<!-- These are the default keys that map when you do not specify a caller control group -->
|
||||
|
@ -30,7 +30,7 @@
|
|||
<!--If no profile is specified it will default to "default"-->
|
||||
<profile name="default">
|
||||
<!-- Domain (for presence) -->
|
||||
<param name="domain" value="$${server_name}"/>
|
||||
<param name="domain" value="$${domain}"/>
|
||||
<!-- Sample Rate-->
|
||||
<param name="rate" value="8000"/>
|
||||
<!-- Number of milliseconds per frame -->
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<action application="answer"/>
|
||||
<action application="sleep" data="1000"/>
|
||||
<action application="voicemail" data="check default $${domain} ${dialed_ext}"/>
|
||||
<anti-action application="set" data="call_timeout=30"/>
|
||||
<anti-action application="set" data="call_timeout=130"/>
|
||||
<anti-action application="set" data="hangup_after_bridge=true"/>
|
||||
<anti-action application="set" data="continue_on_fail=true"/>
|
||||
<anti-action application="db" data="insert/call_return/${dialed_ext}/${caller_id_number}"/>
|
||||
|
|
|
@ -40,6 +40,7 @@ SWITCH_MODULE_DEFINITION(mod_conference, mod_conference_load, mod_conference_shu
|
|||
static const char global_app_name[] = "conference";
|
||||
static char *global_cf_name = "conference.conf";
|
||||
static char *api_syntax;
|
||||
static int EC = 0;
|
||||
|
||||
/* Size to allocate for audio buffers */
|
||||
#define CONF_BUFFER_SIZE 1024 * 128
|
||||
|
@ -542,6 +543,11 @@ static switch_status_t conference_add_member(conference_obj_t * conference, conf
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
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", EC++);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_RING");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "confirmed");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
@ -670,6 +676,11 @@ static switch_status_t conference_del_member(conference_obj_t * conference, conf
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
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", EC++);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_RING");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "confirmed");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
@ -957,7 +968,11 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Inactive");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||
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", EC++);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", conference->name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_HANGUP");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "terminated");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
@ -4866,6 +4881,11 @@ static void pres_event_handler(switch_event_t *event)
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
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", EC++);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", conf_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_RING");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "confirmed");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
} else if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -4875,6 +4895,11 @@ static void pres_event_handler(switch_event_t *event)
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||
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", EC++);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", conf_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_HANGUP");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "terminated");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ static switch_status_t limit_execute_sql(char *sql, switch_mutex_t *mutex)
|
|||
goto end;
|
||||
}
|
||||
|
||||
status = switch_core_db_persistant_execute(db, sql, 25);
|
||||
status = switch_core_db_persistant_execute(db, sql, 1);
|
||||
switch_core_db_close(db);
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
|
|
|
@ -129,7 +129,7 @@ static switch_status_t vm_execute_sql(vm_profile_t *profile, char *sql, switch_m
|
|||
status = SWITCH_STATUS_FALSE;
|
||||
goto end;
|
||||
}
|
||||
status = switch_core_db_persistant_execute(db, sql, 25);
|
||||
status = switch_core_db_persistant_execute(db, sql, 1);
|
||||
switch_core_db_close(db);
|
||||
}
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ static void mdl_execute_sql(mdl_profile_t *profile, char *sql, switch_mutex_t *m
|
|||
goto end;
|
||||
}
|
||||
|
||||
switch_core_db_persistant_execute(db, sql, 25);
|
||||
switch_core_db_persistant_execute(db, sql, 1);
|
||||
switch_core_db_close(db);
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
|
|
|
@ -214,6 +214,15 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||
switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->hash_key);
|
||||
}
|
||||
|
||||
if (session) {
|
||||
const char *call_id = tech_pvt->call_id;
|
||||
char *sql;
|
||||
sql = switch_mprintf("delete from sip_dialogs where call_id='%q'", call_id);
|
||||
switch_assert(sql);
|
||||
sofia_glue_execute_sql(tech_pvt->profile, SWITCH_FALSE, sql, tech_pvt->profile->ireg_mutex);
|
||||
free(sql);
|
||||
}
|
||||
|
||||
if (tech_pvt->kick && (a_session = switch_core_session_locate(tech_pvt->kick))) {
|
||||
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
|
||||
switch_channel_hangup(a_channel, switch_channel_get_cause(channel));
|
||||
|
@ -1593,6 +1602,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
|
||||
if (tech_pvt->local_url) {
|
||||
switch_channel_set_variable(nchannel, "sip_local_url", tech_pvt->local_url);
|
||||
if (sofia_test_pflag(profile, PFLAG_PRESENCE)) {
|
||||
switch_channel_set_variable(nchannel, "presence_id", tech_pvt->local_url);
|
||||
}
|
||||
}
|
||||
switch_channel_set_variable(nchannel, "sip_destination_url", tech_pvt->dest);
|
||||
|
||||
|
@ -1605,6 +1617,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
tech_pvt->caller_profile = caller_profile;
|
||||
*new_session = nsession;
|
||||
cause = SWITCH_CAUSE_SUCCESS;
|
||||
|
||||
if (session) {
|
||||
switch_ivr_transfer_variable(session, nsession, SOFIA_REPLACES_HEADER);
|
||||
switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_HEADER_PREFIX_T);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1696,6 +1696,21 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
" user_agent VARCHAR(255)\n"
|
||||
");\n";
|
||||
|
||||
char dialog_sql[] =
|
||||
"CREATE TABLE sip_dialogs (\n"
|
||||
" call_id VARCHAR(255),\n"
|
||||
" uuid VARCHAR(255),\n"
|
||||
" sip_to_user VARCHAR(255),\n"
|
||||
" sip_to_host VARCHAR(255),\n"
|
||||
" sip_from_user VARCHAR(255),\n"
|
||||
" sip_from_host VARCHAR(255),\n"
|
||||
" contact_user VARCHAR(255),\n"
|
||||
" contact_host VARCHAR(255),\n"
|
||||
" state VARCHAR(255),\n"
|
||||
" direction VARCHAR(255),\n"
|
||||
" user_agent VARCHAR(255)\n"
|
||||
");\n";
|
||||
|
||||
char sub_sql[] =
|
||||
"CREATE TABLE sip_subscriptions (\n"
|
||||
" proto VARCHAR(255),\n"
|
||||
|
@ -1742,6 +1757,11 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
|
||||
}
|
||||
|
||||
if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_dialogs", NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_dialogs", NULL);
|
||||
switch_odbc_handle_exec(profile->master_odbc, dialog_sql, NULL);
|
||||
}
|
||||
|
||||
if (switch_odbc_handle_exec(profile->master_odbc, "select nonce from sip_authentication", NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_authentication", NULL);
|
||||
switch_odbc_handle_exec(profile->master_odbc, auth_sql, NULL);
|
||||
|
@ -1756,6 +1776,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
|
||||
switch_core_db_test_reactive(profile->master_db, "select sip_user,user_agent from sip_registrations", "DROP TABLE sip_registrations", reg_sql);
|
||||
switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions where sip_user != '' or accept != ''", "DROP TABLE sip_subscriptions", sub_sql);
|
||||
switch_core_db_test_reactive(profile->master_db, "delete from sip_dialogs", "DROP TABLE sip_dialogs", dialog_sql);
|
||||
switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
|
||||
|
||||
}
|
||||
|
@ -1813,7 +1834,8 @@ void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
switch_core_db_persistant_execute(db, sql, 25);
|
||||
switch_core_db_persistant_execute(db, sql, 1);
|
||||
|
||||
if (!master) {
|
||||
switch_core_db_close(db);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
struct presence_helper {
|
||||
sofia_profile_t *profile;
|
||||
switch_event_t *event;
|
||||
switch_stream_handle_t stream;
|
||||
};
|
||||
|
||||
switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
|
||||
|
@ -122,7 +123,7 @@ void sofia_presence_cancel(void)
|
|||
sofia_profile_t *profile;
|
||||
switch_hash_index_t *hi;
|
||||
void *val;
|
||||
struct presence_helper helper;
|
||||
struct presence_helper helper = { 0 };
|
||||
|
||||
if ((sql = switch_mprintf("select *,-1,'unavailable','unavailable' from sip_subscriptions where event='presence'"))) {
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
|
@ -317,7 +318,7 @@ void sofia_presence_event_handler(switch_event_t *event)
|
|||
}
|
||||
|
||||
if (event->event_id == SWITCH_EVENT_ROSTER) {
|
||||
struct presence_helper helper;
|
||||
struct presence_helper helper = { 0 };
|
||||
|
||||
if (from) {
|
||||
sql = switch_mprintf("select *,1,'%q','%q' from sip_subscriptions where event='presence' and full_from like '%%%q%%'", status, rpid, from);
|
||||
|
@ -393,10 +394,17 @@ void sofia_presence_event_handler(switch_event_t *event)
|
|||
probe_euser = (p + 1);
|
||||
}
|
||||
|
||||
if (probe_euser && probe_host &&
|
||||
(sql = switch_mprintf("select sip_user,sip_host,status,rpid,'' from sip_registrations where sip_user='%q' and sip_host='%q'",
|
||||
probe_euser, probe_host)) && (profile = sofia_glue_find_profile(probe_host))) {
|
||||
|
||||
if (probe_euser && probe_host && (profile = sofia_glue_find_profile(probe_host))) {
|
||||
sql = switch_mprintf("select sip_registrations.sip_user, sip_registrations.sip_host, sip_registrations.status, "
|
||||
"sip_registrations.rpid,'', sip_dialogs.uuid, sip_dialogs.state, sip_dialogs.direction "
|
||||
"from sip_registrations left join sip_dialogs on "
|
||||
"(sip_dialogs.contact_user = sip_registrations.sip_user or "
|
||||
"sip_dialogs.sip_from_user = sip_registrations.sip_user or "
|
||||
"sip_dialogs.sip_to_user = sip_registrations.sip_user) "
|
||||
"and sip_dialogs.sip_to_host = sip_registrations.sip_host "
|
||||
"where sip_registrations.sip_user='%q' and sip_registrations.sip_host='%q'",
|
||||
probe_euser, probe_host);
|
||||
switch_assert(sql);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
|
@ -407,6 +415,7 @@ void sofia_presence_event_handler(switch_event_t *event)
|
|||
sofia_glue_release_profile(profile);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
|
||||
switch_safe_free(user);
|
||||
}
|
||||
return;
|
||||
|
@ -435,16 +444,23 @@ void sofia_presence_event_handler(switch_event_t *event)
|
|||
}
|
||||
|
||||
if (sql) {
|
||||
struct presence_helper helper;
|
||||
struct presence_helper helper = { 0 };
|
||||
|
||||
helper.profile = profile;
|
||||
helper.event = event;
|
||||
SWITCH_STANDARD_STREAM(helper.stream);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
sql,
|
||||
sofia_presence_sub_callback,
|
||||
&helper);
|
||||
|
||||
|
||||
if (!switch_strlen_zero((char *)helper.stream.data)) {
|
||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, helper.stream.data, profile->ireg_mutex);
|
||||
}
|
||||
switch_safe_free(helper.stream.data);
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
@ -495,8 +511,17 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
|
|||
char *status = argv[2];
|
||||
char *rpid = argv[3];
|
||||
char *proto = argv[4];
|
||||
char *uuid = NULL;
|
||||
char *state = NULL;
|
||||
char *direction = NULL;
|
||||
switch_event_t *event;
|
||||
|
||||
if (argc > 5) {
|
||||
uuid = switch_str_nil(argv[5]);
|
||||
state = switch_str_nil(argv[6]);
|
||||
direction = switch_str_nil(argv[7]);
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(proto)) {
|
||||
proto = NULL;
|
||||
}
|
||||
|
@ -508,11 +533,20 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
|
||||
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", 0);
|
||||
//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", SOFIA_CHAT_PROTO);
|
||||
//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_HANGUP");
|
||||
//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "void");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", 0);
|
||||
|
||||
|
||||
if (switch_strlen_zero(state)) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", SOFIA_CHAT_PROTO);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_HANGUP");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", "terminated");
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", "CS_RING");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", uuid);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", state);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", direction);
|
||||
}
|
||||
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
@ -556,8 +590,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
{
|
||||
struct presence_helper *helper = (struct presence_helper *) pArg;
|
||||
sofia_profile_t *profile = helper->profile;
|
||||
char *pl;
|
||||
char *clean_id = NULL, *id = NULL, *note;
|
||||
char *pl = NULL;
|
||||
char *clean_id = NULL, *id = NULL, *note = NULL;
|
||||
uint32_t in = atoi(argv[13]);
|
||||
char *status = argv[14];
|
||||
char *rpid = argv[15];
|
||||
|
@ -570,7 +604,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
char *event = argv[5];
|
||||
char *call_id = argv[7];
|
||||
nua_handle_t *nh;
|
||||
char *to;
|
||||
char *to = NULL;
|
||||
char *open;
|
||||
char *prpid;
|
||||
int done = 0;
|
||||
|
@ -601,7 +635,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
open = "closed";
|
||||
}
|
||||
|
||||
clean_id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
if (!strcasecmp(proto, SOFIA_CHAT_PROTO)) {
|
||||
clean_id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
} else {
|
||||
clean_id = switch_mprintf("sip:%s+%s@%s", proto, sub_to_user, sub_to_host);
|
||||
}
|
||||
|
||||
if (!strcasecmp(sub_to_host, host)) {
|
||||
/* same host */
|
||||
|
@ -617,34 +655,40 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
|
||||
if (!strcmp(event, "dialog") && helper->event) {
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
//const char *direction = switch_str_nil(switch_event_get_header(helper->event, "call-direction"));
|
||||
const char *direction = switch_str_nil(switch_event_get_header(helper->event, "call-direction"));
|
||||
const char *uuid = switch_str_nil(switch_event_get_header(helper->event, "unique-id"));
|
||||
const char *state = switch_str_nil(switch_event_get_header(helper->event, "channel-state"));
|
||||
const char *event_status = switch_str_nil(switch_event_get_header(helper->event, "status"));
|
||||
const char *astate = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
|
||||
|
||||
const char *dft_state;
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
if (!strcasecmp(state, "cs_hangup")) {
|
||||
if (!strcasecmp(direction, "outbound")) {
|
||||
direction = "recipient";
|
||||
dft_state = "early";
|
||||
} else {
|
||||
direction = "initiator";
|
||||
dft_state = "confirmed";
|
||||
}
|
||||
|
||||
if (!strcasecmp(state, "cs_execute")) {
|
||||
goto end;
|
||||
} if (!strcasecmp(state, "cs_hangup")) {
|
||||
astate = "terminated";
|
||||
} else if (!strcasecmp(astate, "answered")) {
|
||||
astate = "confirmed";
|
||||
} else if (!strcasecmp(astate, "ringing")) {
|
||||
astate = "early";
|
||||
} else {
|
||||
astate = dft_state;
|
||||
}
|
||||
|
||||
|
||||
stream.write_function(&stream,
|
||||
"<?xml version=\"1.0\"?>\n"
|
||||
"<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" "
|
||||
"version=\"%s\" state=\"full\" entity=\"%s\">\n",
|
||||
switch_str_nil(switch_event_get_header(helper->event, "event_count")), clean_id);
|
||||
|
||||
if (!strcasecmp(state, "RING")) {
|
||||
stream.write_function(&stream, "<dialog id=\"%s\" direction=\"recipient\">\n", uuid);
|
||||
} else {
|
||||
stream.write_function(&stream, "<dialog id=\"%s\">\n", uuid);
|
||||
}
|
||||
|
||||
/* astate of aleg/outbound should start @ confirmed not early. direction is recipient or initiator */
|
||||
stream.write_function(&stream, "<dialog id=\"%s\" direction=\"%s\">\n", uuid, direction);
|
||||
|
||||
stream.write_function(&stream, "<state>%s</state>\n", astate);
|
||||
|
||||
|
@ -656,7 +700,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
stream.write_function(&stream, "</dialog>\n</dialog-info>\n");
|
||||
pl = stream.data;
|
||||
ct = "application/dialog-info+xml";
|
||||
//printf("%s\n", pl);
|
||||
|
||||
if (astate && uuid && helper->stream.data) {
|
||||
stream.write_function(&helper->stream, "update sip_dialogs set state='%s' where uuid='%s';\n", astate, uuid);
|
||||
}
|
||||
|
||||
} else {
|
||||
pl = switch_mprintf("<?xml version='1.0' encoding='UTF-8'?>\r\n"
|
||||
"<presence xmlns='urn:ietf:params:xml:ns:pidf'\r\n"
|
||||
|
@ -696,6 +744,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
switch_core_hash_delete(profile->sub_hash, call_id);
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
switch_safe_free(id);
|
||||
switch_safe_free(clean_id);
|
||||
switch_safe_free(note);
|
||||
|
|
|
@ -84,11 +84,12 @@ SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, s
|
|||
|
||||
while(--sane > 0) {
|
||||
ret = sqlite3_exec(db, sql, callback, data, errmsg);
|
||||
|
||||
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
|
||||
switch_safe_free(*errmsg);
|
||||
switch_yield(1000);
|
||||
continue;
|
||||
if (sane > 1) {
|
||||
switch_safe_free(*errmsg);
|
||||
switch_yield(1000);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue