]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Recent CDR fixes moved execution of the 'h' exten into the bridging code, so variable...
authorTerry Wilson <twilson@digium.com>
Fri, 31 Oct 2008 15:45:29 +0000 (15:45 +0000)
committerTerry Wilson <twilson@digium.com>
Fri, 31 Oct 2008 15:45:29 +0000 (15:45 +0000)
(closes issue #13793)
Reported by: greenfieldtech

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@153095 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_dial.c
include/asterisk/channel.h
res/res_features.c

index 1dae16dd50904ad241b5eb9fbb4d3db8dd350f5d..db2e43b2d6f8189cd0a406a324451717fa0f1316 100644 (file)
@@ -1434,9 +1434,9 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                /* almost done, although the 'else' block is 400 lines */
        } else {
                const char *number;
-               time_t end_time, answer_time = time(NULL);
 
                strcpy(status, "ANSWER");
+               pbx_builtin_setvar_helper(chan, "DIALSTATUS", status);
                /* Ah ha!  Someone answered within the desired timeframe.  Of course after this
                   we will always return with -1 so that it is hung up properly after the 
                   conversation.  */
@@ -1731,10 +1731,31 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                                res = ast_dtmf_stream(chan,peer,dtmfcalling,250);
                        }
                }
-               
+
                if (!res) {
                        struct ast_bridge_config config;
 
+                       auto void end_bridge_callback(void);
+                       void end_bridge_callback (void)
+                       {
+                               char buf[80];
+                               time_t end;
+
+                               time(&end);
+
+                               ast_channel_lock(chan);
+                               if (chan->cdr->answer.tv_sec) {
+                                       snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+                                       pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+                               }
+
+                               if (chan->cdr->start.tv_sec) {
+                                       snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+                                       pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+                               }
+                               ast_channel_unlock(chan);
+                       }
+
                        memset(&config,0,sizeof(struct ast_bridge_config));
                        if (play_to_caller)
                                ast_set_flag(&(config.features_caller), AST_FEATURE_PLAY_WARNING);
@@ -1765,6 +1786,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                        config.warning_sound = warning_sound;
                        config.end_sound = end_sound;
                        config.start_sound = start_sound;
+                       config.end_bridge_callback = end_bridge_callback;
                        if (moh) {
                                moh = 0;
                                ast_moh_stop(chan);
@@ -1795,21 +1817,10 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                                        AST_OPTION_OPRMODE,&oprmode,sizeof(struct oprmode),0);
                        }
                        res = ast_bridge_call(chan,peer,&config);
-                       time(&end_time);
-                       if (res != AST_PBX_KEEPALIVE) { /* if keepalive is set, don't even think about accessing chan! */
-                               char toast[80];
-                               snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
-                               pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast);
-                       }
                } else {
-                       time(&end_time);
                        res = -1;
                }
-               if (res != AST_PBX_KEEPALIVE) { /* if keepalive is set, don't even think about accessing chan! */
-                       char toast[80];
-                       snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
-                       pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
-               }
+
                if (res != AST_PBX_NO_HANGUP_PEER && res != AST_PBX_NO_HANGUP_PEER_PARKED) {
                        if (res != AST_PBX_KEEPALIVE && !chan->_softhangup)
                                chan->hangupcause = peer->hangupcause;
index 5e42953cb861728bcb26eec19240a9a95de73b46..82055be1494d71f147807ce088f01c8eb8a1b54d 100644 (file)
@@ -540,6 +540,7 @@ struct ast_bridge_config {
        const char *start_sound;
        int firstpass;
        unsigned int flags;
+       void (* end_bridge_callback)(void);   /*!< A callback that is called after a bridge attempt */
 };
 
 struct chanmon;
index 3fe942a93842f74c5d9b918c9e93964af5c0b221..18e7555ba101c668990bb5f0b15751e6f1348e42 100644 (file)
@@ -1712,6 +1712,10 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
 
        }
   before_you_go:
+       if (res != AST_PBX_KEEPALIVE && config->end_bridge_callback) {
+               config->end_bridge_callback();
+       }
+
        if (res != AST_PBX_KEEPALIVE && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
                struct ast_cdr *swapper;
                char savelastapp[AST_MAX_EXTENSION];