[asterisk-commits] oej: trunk r91408 - /trunk/main/cdr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 6 09:12:18 CST 2007


Author: oej
Date: Thu Dec  6 09:12:18 2007
New Revision: 91408

URL: http://svn.digium.com/view/asterisk?view=rev&rev=91408
Log:
New manager event when a channel changes account code.
Maybe belongs in the new cdr category?
---moremanager---

 Event: NewAccountCode
        Modules: cdr.c
        Purpose: To report a change in account code for a live channel
        Example:
                Event: NewAccountCode
                Privilege: call,all
                Channel: SIP/olle-01844600
                Uniqueid: 1177530895.2
                AccountCode: Stinas account 1234848484
                OldAccountCode: Olles Account 12345


Modified:
    trunk/main/cdr.c

Modified: trunk/main/cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cdr.c?view=diff&rev=91408&r1=91407&r2=91408
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Thu Dec  6 09:12:18 2007
@@ -41,6 +41,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/cdr.h"
 #include "asterisk/callerid.h"
+#include "asterisk/manager.h"
 #include "asterisk/causes.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/utils.h"
@@ -892,6 +893,9 @@
 int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
 {
 	struct ast_cdr *cdr = chan->cdr;
+	char buf[BUFSIZ/2] = "";
+	if (!ast_strlen_zero(chan->accountcode))
+		ast_copy_string(buf, chan->accountcode, sizeof(buf));
 
 	ast_string_field_set(chan, accountcode, account);
 	for ( ; cdr ; cdr = cdr->next) {
@@ -899,6 +903,9 @@
 			ast_copy_string(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode));
 		}
 	}
+
+	/* Signal change of account code to manager */
+	manager_event(EVENT_FLAG_CALL, "NewAccountCode", "Channel: %s\r\nUniqueid: %s\r\nAccountCode: %s\r\nOldAccountCode: %s\r\n", chan->name, chan->uniqueid, chan->accountcode, buf);
 	return 0;
 }
 
@@ -1408,6 +1415,7 @@
 
 	ast_mutex_unlock(&cdr_batch_lock);
 	ast_config_destroy(config);
+	manager_event(EVENT_FLAG_SYSTEM, "Reload", "Module: CDR\r\nMessage: CDR subsystem reload requested\r\n");
 
 	return res;
 }




More information about the asterisk-commits mailing list