]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
closes issue #11379; OK, this is an attempt to make both sides happy. To the cdr...
authorSteve Murphy <murf@digium.com>
Tue, 27 Nov 2007 06:24:02 +0000 (06:24 +0000)
committerSteve Murphy <murf@digium.com>
Tue, 27 Nov 2007 06:24:02 +0000 (06:24 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@89622 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_dial.c
configs/cdr.conf.sample
include/asterisk/cdr.h
main/cdr.c

index c1bb40b95baa49dfc237a5e16a813559d252ccf4..73d2d4c152cc61266a0cfe3e26ebf79ab2ab6793 100644 (file)
@@ -57,6 +57,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/app.h"
 #include "asterisk/causes.h"
 #include "asterisk/rtp.h"
+#include "asterisk/cdr.h"
 #include "asterisk/manager.h"
 #include "asterisk/privacy.h"
 #include "asterisk/stringfields.h"
@@ -762,7 +763,26 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct dial_l
                }
                
        }
-
+       if (peer && !ast_cdr_log_unanswered()) {
+               /* suppress the CDR's that didn't win */
+               struct dial_localuser *o;
+               for (o = outgoing; o; o = o->next) {
+                       struct ast_channel *c = o->chan;
+                       if (c && c != peer && c->cdr) {
+                               ast_set_flag(c->cdr, AST_CDR_FLAG_POST_DISABLED);
+                       }
+               }
+       } else if (!peer && !ast_cdr_log_unanswered()) {
+                       /* suppress the CDR's that didn't win */
+               struct dial_localuser *o;
+               for (o = outgoing; o; o = o->next) {
+                       struct ast_channel *c = o->chan;
+                       if (c && c->cdr) {
+                               ast_set_flag(c->cdr, AST_CDR_FLAG_POST_DISABLED);               
+                       }
+               }
+       }
+       
        return peer;
 }
 
index 6137eb40235093b7c9e8c035f245bc8dfd62b128..c2882c1f0dc52371e437d6ef248d0a0e22fb0d8d 100644 (file)
 ; any loading of backend CDR modules.  Default is "yes".
 ;enable=yes
 
+; Define whether or not to log unanswered calls. Setting this to "yes" will
+; report every attempt to ring a phone in dialing attempts, when it was not 
+; answered. For example, if you try to dial 3 extensions, and this option is "yes",
+; you will get 3 CDR's, one for each phone that was rung. Default is "no". Some
+; find this information horribly useless. Others find it very valuable. Note, in "yes"
+; mode, you will see one CDR, with one of the call targets on one side, and the originating
+; channel on the other, and then one CDR for each channel attempted. This may seem 
+; redundant, but cannot be helped.
+;unanswered = no
+
 ; Define the CDR batch mode, where instead of posting the CDR at the end of
 ; every call, the data will be stored in a buffer to help alleviate load on the
 ; asterisk server.  Default is "no".
index b61e250145aca69c644e0b7a377c25b5ca593893..b88234a391db39863d917715a88414862203a5a0 100644 (file)
@@ -100,6 +100,7 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int
 int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur);
 void ast_cdr_free_vars(struct ast_cdr *cdr, int recur);
 int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
+int ast_cdr_log_unanswered(void);
 
 typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
 
index 5aa7a24f1c7a81a0bb14b5dcc5d68afe88a72eed..0bed0cfdaa3f0338d8db49a6165d287eeb9f6e43 100644 (file)
@@ -89,6 +89,7 @@ static pthread_t cdr_thread = AST_PTHREADT_NULL;
 #define BATCH_SAFE_SHUTDOWN_DEFAULT 1
 
 static int enabled;            /*! Is the CDR subsystem enabled ? */
+static int unanswered;
 static int batchmode;
 static int batchsize;
 static int batchtime;
@@ -102,6 +103,11 @@ AST_MUTEX_DEFINE_STATIC(cdr_pending_lock);
 static ast_cond_t cdr_pending_cond;
 
 
+int ast_cdr_log_unanswered(void)
+{
+       return unanswered;
+}
+
 /*! Register a CDR driver. Each registered CDR driver generates a CDR 
        \return 0 on success, -1 on failure 
 */
@@ -984,8 +990,6 @@ static void post_cdr(struct ast_cdr *cdr)
        struct ast_cdr_beitem *i;
 
        for ( ; cdr ; cdr = cdr->next) {
-               if (cdr->disposition < AST_CDR_ANSWERED && (ast_strlen_zero(cdr->channel) || ast_strlen_zero(cdr->dstchannel)))
-                       continue; /* people don't want to see unanswered single-channel events */
                chan = S_OR(cdr->channel, "<unknown>");
                check_post(cdr);
                if (ast_tvzero(cdr->end))
@@ -1247,6 +1251,7 @@ static int handle_cli_status(int fd, int argc, char *argv[])
        ast_cli(fd, "CDR logging: %s\n", enabled ? "enabled" : "disabled");
        ast_cli(fd, "CDR mode: %s\n", batchmode ? "batch" : "simple");
        if (enabled) {
+               ast_cli(fd, "CDR output unanswered calls: %s\n", unanswered ? "yes" : "no");
                if (batchmode) {
                        if (batch)
                                cnt = batch->size;
@@ -1298,6 +1303,7 @@ static int do_reload(void)
 {
        struct ast_config *config;
        const char *enabled_value;
+       const char *unanswered_value;
        const char *batched_value;
        const char *scheduleronly_value;
        const char *batchsafeshutdown_value;
@@ -1329,6 +1335,9 @@ static int do_reload(void)
                if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
                        enabled = ast_true(enabled_value);
                }
+               if ((unanswered_value = ast_variable_retrieve(config, "general", "unanswered"))) {
+                       unanswered = ast_true(unanswered_value);
+               }
                if ((batched_value = ast_variable_retrieve(config, "general", "batch"))) {
                        batchmode = ast_true(batched_value);
                }