]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4681 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Nov 2012 18:07:42 +0000 (13:07 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Nov 2012 18:07:47 +0000 (13:07 -0500)
src/include/switch_core.h
src/mod/applications/mod_conference/mod_conference.c
src/switch_core_session.c

index bc8b403961479dd7e7a53b0427ecc9ec8271a60d..ead85fdf4af4b961d0159a583c9b9ce7eaa12b30 100644 (file)
@@ -825,14 +825,22 @@ SWITCH_DECLARE(void) switch_core_dump_variables(_In_ switch_stream_handle_t *str
 */
 SWITCH_DECLARE(void) switch_core_session_hupall(_In_ switch_call_cause_t cause);
 
+typedef enum {
+       SHT_NONE = 0,
+       SHT_UNANSWERED = (1 << 0),
+       SHT_ANSWERED = (1 << 1)
+} switch_hup_type_t;
+
 /*! 
   \brief Hangup all sessions which match a specific channel variable
   \param var_name The variable name to look for
   \param var_val The value to look for 
   \param cause the hangup cause to apply to the hungup channels
 */
-SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause);
+SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const char *var_name, _In_ const char *var_val, _In_ 
+                                                                                                                                        switch_call_cause_t cause, switch_hup_type_t type);
 SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall_matching_var(const char *var_name, const char *var_val);
+#define switch_core_session_hupall_matching_var(_vn, _vv, _c) switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED)
 
 /*! 
   \brief Hangup all sessions that belong to an endpoint
index 57e063664716fd2e657bc32524ecf1bc2f0a82bd..d5ea7e702aa303d72bc3acf8ca4396d3f50ff856 100644 (file)
@@ -8539,11 +8539,13 @@ static void conference_send_presence(conference_obj_t *conference)
        }
        
 }
-
-static void kickall_matching_var(conference_obj_t *conference, const char *var, const char *val)
+#if 0
+static uint32_t kickall_matching_var(conference_obj_t *conference, const char *var, const char *val)
 {
        conference_member_t *member = NULL;
        const char *vval = NULL;
+       uint32_t r = 0;
+
        switch_mutex_lock(conference->mutex);
        switch_mutex_lock(conference->member_mutex);
 
@@ -8560,14 +8562,18 @@ static void kickall_matching_var(conference_obj_t *conference, const char *var,
                if (vval && !strcmp(vval, val)) {
                        switch_set_flag_locked(member, MFLAG_KICKED);
                        switch_clear_flag_locked(member, MFLAG_RUNNING);
-                       switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);                    
+                       switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+                       r++;
                }
 
        }       
 
        switch_mutex_unlock(conference->member_mutex);
        switch_mutex_unlock(conference->mutex);
+
+       return r;
 }
+#endif
 
 static void call_setup_event_handler(switch_event_t *event)
 {
@@ -8631,8 +8637,11 @@ static void call_setup_event_handler(switch_event_t *event)
                                }
                                
                        } else if (!strcasecmp(action, "end")) {
-                               //switch_core_session_hupall_matching_var("conference_call_key", key, SWITCH_CAUSE_NORMAL_CLEARING);
-                               kickall_matching_var(conference, "conference_call_key", key);
+                               if (switch_core_session_hupall_matching_var("conference_call_key", key, SWITCH_CAUSE_NORMAL_CLEARING)) {
+                                       send_conference_notify(conference, "SIP/2.0 200 OK\r\n", call_id, SWITCH_TRUE);
+                               } else {
+                                       send_conference_notify(conference, "SIP/2.0 481 Failure\r\n", call_id, SWITCH_TRUE);
+                               }
                                status = SWITCH_STATUS_SUCCESS;
                        }
 
index 4148267da6245faa19f0f162b0e099e1a34468e8..cf7daaac1603dfc5d96d50ba2ecc7721b3bdef24 100644 (file)
@@ -204,18 +204,20 @@ struct str_node {
        struct str_node *next;
 };
 
-SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_name, const char *var_val, switch_call_cause_t cause)
+SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(const char *var_name, const char *var_val, switch_call_cause_t cause, 
+                                                                                                                                        switch_hup_type_t type)
 {
        switch_hash_index_t *hi;
        void *val;
        switch_core_session_t *session;
        switch_memory_pool_t *pool;
        struct str_node *head = NULL, *np;
+       uint32_t r = 0;
 
        switch_core_new_memory_pool(&pool);
 
        if (!var_val)
-               return;
+               return r;
 
        switch_mutex_lock(runtime.session_hash_mutex);
        for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
@@ -223,10 +225,13 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam
                if (val) {
                        session = (switch_core_session_t *) val;
                        if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
-                               np = switch_core_alloc(pool, sizeof(*np));
-                               np->str = switch_core_strdup(pool, session->uuid_str);
-                               np->next = head;
-                               head = np;
+                               int ans = switch_channel_test_flag(switch_core_session_get_channel(session), CF_ANSWERED);
+                               if ((ans && (type & SHT_ANSWERED)) || (!ans && (type & SHT_UNANSWERED))) {
+                                       np = switch_core_alloc(pool, sizeof(*np));
+                                       np->str = switch_core_strdup(pool, session->uuid_str);
+                                       np->next = head;
+                                       head = np;
+                               }
                                switch_core_session_rwunlock(session);
                        }
                }
@@ -239,6 +244,7 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam
                        if (switch_channel_up_nosig(session->channel) &&
                                (this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) {                 
                                switch_channel_hangup(session->channel, cause);
+                               r++;
                        }
                        switch_core_session_rwunlock(session);
                }
@@ -246,6 +252,7 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam
 
        switch_core_destroy_memory_pool(&pool);
 
+       return r;
 }