]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
blinking lights for xmas presence(3rd time's a charm)
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 18 Dec 2007 03:12:51 +0000 (03:12 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 18 Dec 2007 03:12:51 +0000 (03:12 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6855 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/autoload_configs/conference.conf.xml
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 430b095b9a68a73dd6f35a23899a67752cd336b6..8e28c110201b23db5f7a107d5624ea0a64c1ae81 100644 (file)
@@ -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 -->
index 67045ee7c52cb8e5cfd677a41138be3d81240a9a..587eacc74a1f8e3f6ef4dc8f2c95412364912441 100644 (file)
@@ -1160,10 +1160,10 @@ void sofia_event_callback(nua_event_t event,
 
                 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);
index f2975d08dbf23496ef067015ace5c0c827fed310..4d715c31e6a8aed0f96aaa5dafea8220a6236c7d 100644 (file)
@@ -398,10 +398,8 @@ void sofia_presence_event_handler(switch_event_t *event)
                                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 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
                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 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
                        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 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
                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 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
                        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\" "