Author: anthm Date: Mon Dec 17 22:12:51 2007 New Revision: 6855 Modified: freeswitch/trunk/conf/autoload_configs/conference.conf.xml freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Log: blinking lights for xmas presence(3rd time's a charm) Modified: freeswitch/trunk/conf/autoload_configs/conference.conf.xml ============================================================================== --- freeswitch/trunk/conf/autoload_configs/conference.conf.xml (original) +++ freeswitch/trunk/conf/autoload_configs/conference.conf.xml Mon Dec 17 22:12:51 2007 @@ -64,7 +64,7 @@ <!-- File to play if you are alone in the conference --> <!--<param name="alone-sound" value="yactopitc.wav"/>--> <!-- File to play endlessly (nobody will ever be able to talk) --> - <!--<param name="perpetual-sound" value="music.wav"/>--> + <param name="perpetual-sound" value="local_stream://moh"/> <!-- File to play when you join the conference --> <!--<param name="enter-sound" value="welcome.wav"/>--> <!-- File to play when you leave the conference --> Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Dec 17 22:12:51 2007 @@ -1160,10 +1160,10 @@ if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED) && !switch_channel_test_flag(channel, CF_RING_READY)) { - const char *to_user = switch_str_nil(sip->sip_to->a_url->url_user); - const char *to_host = switch_str_nil(sip->sip_to->a_url->url_host); - const char *from_user = switch_str_nil(sip->sip_from->a_url->url_user); + const char *from_user = switch_str_nil(sip->sip_to->a_url->url_user); const char *from_host = switch_str_nil(sip->sip_from->a_url->url_host); + const char *to_user = switch_str_nil(sip->sip_from->a_url->url_user); + const char *to_host = switch_str_nil(sip->sip_from->a_url->url_host); const char *contact_user = switch_str_nil(sip->sip_contact->m_url->url_user); const char *contact_host = switch_str_nil(sip->sip_contact->m_url->url_host); const char *user_agent = switch_str_nil(sip->sip_user_agent->g_string); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Mon Dec 17 22:12:51 2007 @@ -398,10 +398,8 @@ 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 " + "(sip_dialogs.sip_from_user = sip_registrations.sip_user) " + "and sip_dialogs.sip_from_host = sip_registrations.sip_host " "where sip_registrations.sip_user='%q' and sip_registrations.sip_host='%q'", probe_euser, probe_host); switch_assert(sql); @@ -536,7 +534,6 @@ 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"); @@ -545,6 +542,7 @@ 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, "astate", "%s", state); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", direction); } @@ -659,11 +657,11 @@ 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 *astate = switch_str_nil(switch_event_get_header(helper->event, "astate")); const char *dft_state; SWITCH_STANDARD_STREAM(stream); - + if (!strcasecmp(direction, "outbound")) { direction = "recipient"; dft_state = "early"; @@ -671,21 +669,35 @@ direction = "initiator"; dft_state = "confirmed"; } - + if (!strcasecmp(state, "cs_execute")) { goto end; - } if (!strcasecmp(state, "cs_hangup")) { + } else if (!strcasecmp(state, "cs_hangup")) { astate = "terminated"; - } else if (!strcasecmp(astate, "answered")) { - astate = "confirmed"; - } else { - astate = dft_state; - } + } else if (switch_strlen_zero(astate)) { + astate = switch_str_nil(switch_event_get_header(helper->event, "answer-state")); + if (switch_strlen_zero(astate)) { + astate = dft_state; + } + } if (!strcasecmp(event_status, "hold")) { astate = "early"; } + if (!strcasecmp(astate, "answered")) { + astate = "confirmed"; + } + + if (!strcasecmp(astate, "ringing")) { + if (!strcasecmp(direction, "recipient")) { + astate = "early"; + } else { + astate = "confirmed"; + } + } + + stream.write_function(&stream, "<?xml version=\"1.0\"?>\n" "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" "