]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
legs option to cdr_csv
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 May 2008 21:35:58 +0000 (21:35 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 May 2008 21:35:58 +0000 (21:35 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8725 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/autoload_configs/cdr_csv.conf.xml
src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c

index e6645c26d9c3ef7174aa1a1dc728546001d8d851..7658e396ac77a42b815f4ed37d94ea8a5b21370d 100644 (file)
@@ -6,6 +6,8 @@
     <!-- This is like the info app but after the call is hung up -->
     <!--<param name="debug" value="true"/>-->
     <param name="rotate-on-hup" value="true"/>
+    <!-- may be a b or ab -->
+    <param name="legs" value="a"/>
   </settings>
   <templates>
     <template name="sql">INSERT INTO cdr VALUES ("${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}");</template>
index 6f8ba4abca9723f15a19bc8482d03b8adbf90cb1..bb9d01c7c27dee015191de626e754f5a2bfb5858 100644 (file)
 #include <sys/stat.h>
 #include <switch.h>
 
+typedef enum {
+       CDR_LEG_A = (1 << 0),
+       CDR_LEG_B = (1 << 1)
+} cdr_leg_t;
+
 struct cdr_fd {
        int fd;
        char *path;
@@ -50,6 +55,7 @@ static struct {
        int shutdown;
        int rotate;
        int debug;
+       cdr_leg_t legs;
 } globals;
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_csv_load);
@@ -166,8 +172,16 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
        const char *log_dir = NULL, *accountcode = NULL, *a_template_str = NULL, *g_template_str = NULL;
        char *log_line, *path = NULL;
 
-       if (switch_channel_get_originator_caller_profile(channel)) {
-               return SWITCH_STATUS_SUCCESS;
+       if (!((globals.legs && CDR_LEG_A) && (globals.legs & CDR_LEG_B))) {
+               if ((globals.legs && CDR_LEG_A)) {
+                       if (switch_channel_get_originator_caller_profile(channel)) {
+                               return SWITCH_STATUS_SUCCESS;
+                       }
+               } else {
+                       if (switch_channel_get_originatee_caller_profile(channel)) {
+                               return SWITCH_STATUS_SUCCESS;
+                       }
+               }
        }
 
        if (!(log_dir = switch_channel_get_variable(channel, "cdr_csv_base"))) {
@@ -278,10 +292,11 @@ static switch_status_t load_config(switch_memory_pool_t *pool)
        switch_core_hash_init(&globals.template_hash, pool);
 
        globals.pool = pool;
-
+       
        switch_core_hash_insert(globals.template_hash, "default", default_template);
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template.\n");
-
+       globals.legs = CDR_LEG_A;
+       
        if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 
                if ((settings = switch_xml_child(cfg, "settings"))) {
@@ -290,6 +305,16 @@ static switch_status_t load_config(switch_memory_pool_t *pool)
                                char *val = (char *) switch_xml_attr_soft(param, "value");
                                if (!strcasecmp(var, "debug")) {
                                        globals.debug = switch_true(val);
+                               } else if (!strcasecmp(var, "legs")) {
+                                       globals.legs = 0;
+
+                                       if (strchr(val, 'a')) {
+                                               globals.legs |= CDR_LEG_A;
+                                       }
+
+                                       if (strchr(val, 'a')) {
+                                               globals.legs |= CDR_LEG_B;
+                                       }
                                } else if (!strcasecmp(var, "log-base")) {
                                        globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", val, SWITCH_PATH_SEPARATOR);
                                } else if (!strcasecmp(var, "rotate-on-hup")) {