[asterisk-commits] murf: branch group/newcdr r166771 - in /team/group/newcdr: apps/ cdr/ cel/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 24 16:32:06 CST 2008


Author: murf
Date: Wed Dec 24 16:32:05 2008
New Revision: 166771

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166771
Log:
As per the first part of Russell's review, except I need to bring to bring in the cdr_adaptive stuff

Removed:
    team/group/newcdr/cel/cel_csv.c
Modified:
    team/group/newcdr/apps/app_celgenuserevent.c
    team/group/newcdr/apps/app_queue.c
    team/group/newcdr/cdr/cdr_radius.c
    team/group/newcdr/cdr/cdr_sqlite.c
    team/group/newcdr/cel/cel_custom.c
    team/group/newcdr/cel/cel_manager.c
    team/group/newcdr/cel/cel_pgsql.c

Modified: team/group/newcdr/apps/app_celgenuserevent.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_celgenuserevent.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/apps/app_celgenuserevent.c (original)
+++ team/group/newcdr/apps/app_celgenuserevent.c Wed Dec 24 16:32:05 2008
@@ -1,8 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Anthony Minessale anthmct at yahoo.com
- * Development of this app Sponsered/Funded  by TAAN Softworks Corp
+ * Copyright (C) 2008, Digium, Inc
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -17,12 +16,10 @@
 
 /*! \file
  *
- * \brief Fork CDR application
+ * \brief Generate User-Defined CEL event
  *
- * \author Anthony Minessale anthmct at yahoo.com
+ * \author Steve Murphy
  *
- * \note Development of this app Sponsored/Funded by TAAN Softworks Corp
- * 
  * \ingroup applications
  */
 
@@ -34,14 +31,24 @@
 #include "asterisk/app.h"
 #include "asterisk/channel.h"
 
+/*** DOCUMENTATION
+	<application name="CELGenUserEvent" language="en_US">
+		<synopsis>
+			Generates a CEL User Defined Event.
+		</synopsis>
+		<syntax>
+			<parameter name="event-name" required="true">
+				<argument name="event-name" required="true">
+				</argument>
+			</parameter>
+		</syntax>
+		<description>
+			<para>A CEL event will be immediately  generated by this channel, with the supplied name for a type.</para>
+		</description>
+	</application>
+ ***/
+
 static char *app = "CELGenUserEvent";
-static char *synopsis = 
-"Generates a CEL User Defined Event";
-static char *descrip = 
-	"  CELGenUserEvent(event-name):  \n"
-	"A CEL event will be immediately  generated by this channel,\n"
-	"with the supplied name for a type\n";
-
 
 static int celgenuserevent_exec(struct ast_channel *chan, void *data)
 {
@@ -59,9 +66,6 @@
 
 	parse = ast_strdupa(data);
 	AST_STANDARD_APP_ARGS(args, parse);
-	if (args.argc == 1) {
-		args.extra = NULL;
-	}
 
 	u = ast_module_user_add(chan);
 	ast_cel_report_event(chan, CEL_USER_DEFINED, args.event, args.extra, NULL);
@@ -77,12 +81,20 @@
 
 	ast_module_user_hangup_all();
 
-	return res;	
+	return res;
 }
 
 static int load_module(void)
 {
-	return ast_register_application(app, celgenuserevent_exec, synopsis, descrip);
+	int res = ast_register_application_xml(app, celgenuserevent_exec);
+	if (res) {
+		return AST_MODULE_LOAD_DECLINE;
+	} else {
+		return AST_MODULE_LOAD_SUCCESS;
+	}
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Generate a User-Defined CEL event");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event", 
+				.load = load_module,
+				.unload = unload_module,
+	);

Modified: team/group/newcdr/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_queue.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/apps/app_queue.c (original)
+++ team/group/newcdr/apps/app_queue.c Wed Dec 24 16:32:05 2008
@@ -6729,7 +6729,7 @@
 	}
 
 	/* in the following subscribe call, do I use DEVICE_STATE, or DEVICE_STATE_CHANGE? */
-	if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE_CHANGE, device_state_cb, "AppQueue Device state", NULL, AST_EVENT_IE_END))) {
+	if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, "AppQueue Device state", NULL, AST_EVENT_IE_END))) {
 		res = -1;
 	}
 

Modified: team/group/newcdr/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cdr/cdr_radius.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/cdr/cdr_radius.c (original)
+++ team/group/newcdr/cdr/cdr_radius.c Wed Dec 24 16:32:05 2008
@@ -191,11 +191,9 @@
 	if (!rc_avpair_add(rh, tosend, PW_USER_NAME, &cdr->channel, strlen(cdr->channel), 0))
 		return -1;
 
-#ifdef WHY_CANT_SESSION_ID_BE_FOUND
 	/* Unique ID */
 	if (!rc_avpair_add(rh, tosend, PW_ACCT_SESSION_ID, &cdr->uniqueid, strlen(cdr->uniqueid), 0))
 		return -1;
-#endif
 
 	return 0;
 }

Modified: team/group/newcdr/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cdr/cdr_sqlite.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/cdr/cdr_sqlite.c (original)
+++ team/group/newcdr/cdr/cdr_sqlite.c Wed Dec 24 16:32:05 2008
@@ -180,12 +180,6 @@
 
 	/* is the database there? */
 	snprintf(fn, sizeof(fn), "%s/cdr.db", ast_config_AST_LOG_DIR);
-
-	if (access(fn, W_OK) != 0) {
-		ast_log(LOG_ERROR, "cdr_sqlite: Unable to create table 'cdr': %s\n", fn);
-		return AST_MODULE_LOAD_DECLINE;
-	}
-	
 	db = sqlite_open(fn, AST_FILE_MODE, &zErr);
 	if (!db) {
 		ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);

Modified: team/group/newcdr/cel/cel_custom.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_custom.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/cel/cel_custom.c (original)
+++ team/group/newcdr/cel/cel_custom.c Wed Dec 24 16:32:05 2008
@@ -64,7 +64,7 @@
 
 static char master[PATH_MAX];
 static char format[1024]="";
-static struct ast_event_sub *event_sub = 0;
+static struct ast_event_sub *event_sub = NULL;
 
 static int load_config(int reload) 
 {
@@ -80,9 +80,9 @@
 	strcpy(master, "");
 	ast_mutex_lock(&lock);
 
-	if(cfg) {
+	if (cfg) {
 		var = ast_variable_browse(cfg, "mappings");
-		while(var) {
+		while (var) {
 			if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) {
 				if (strlen(var->value) > (sizeof(format) - 1)) {
 					ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno);
@@ -160,31 +160,30 @@
 	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
 	}
-	event_sub = 0;
+	event_sub = NULL;
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int load_module(void)
 {
 
-	if (!load_config(0)) {
-
-		event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, "Custom CSV logging", NULL, AST_EVENT_IE_END);
-
-		if (mf) {
-			fclose(mf);
-			mf = NULL;
-		}
-		if (!event_sub) {
-			ast_log(LOG_ERROR, "Unable to register custom CEL handling\n");
-			return AST_MODULE_LOAD_DECLINE;
-		} else {
-			ast_log(LOG_NOTICE, "Subscribed to Custom-CSV CEL events\n");
-		}
-		return AST_MODULE_LOAD_SUCCESS;
-	} else {
+	if (load_config(0)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
+	
+	event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, "Custom CSV logging", NULL, AST_EVENT_IE_END);
+	
+	if (mf) {
+		fclose(mf);
+		mf = NULL;
+	}
+	if (!event_sub) {
+		ast_log(LOG_ERROR, "Unable to register custom CEL handling\n");
+		return AST_MODULE_LOAD_DECLINE;
+	} else {
+		ast_log(LOG_NOTICE, "Subscribed to Custom-CSV CEL events\n");
+	}
+	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int reload(void)

Modified: team/group/newcdr/cel/cel_manager.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_manager.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/cel/cel_manager.c (original)
+++ team/group/newcdr/cel/cel_manager.c Wed Dec 24 16:32:05 2008
@@ -53,7 +53,7 @@
 struct ast_str *customfields;
 
 static int enablecel = 0;
-static struct ast_event_sub *event_sub = 0;
+static struct ast_event_sub *event_sub = NULL;
 static void manager_log(const struct ast_event *event, void *userdata);
 
 static int load_config(int reload)
@@ -89,7 +89,7 @@
 		return 0;
 	}
 
-	while ( (cat = ast_category_browse(cfg, cat)) ) {
+	while ((cat = ast_category_browse(cfg, cat))) {
 		if (!strcasecmp(cat, "general")) {
 			v = ast_variable_browse(cfg, cat);
 			while (v) {
@@ -103,7 +103,7 @@
 			v = ast_variable_browse(cfg, cat);
 			while (v) {
 				if (customfields && !ast_strlen_zero(v->name) && !ast_strlen_zero(v->value)) {
-					if( (ast_str_strlen(customfields) + strlen(v->value) + strlen(v->name) + 14) < ast_str_size(customfields)) {
+					if ((ast_str_strlen(customfields) + strlen(v->value) + strlen(v->name) + 14) < ast_str_size(customfields)) {
 						ast_str_append(&customfields, -1, "%s: ${CDR(%s)}\r\n", v->value, v->name);
 						ast_log(LOG_NOTICE, "Added mapping %s: ${CDR(%s)}\n", v->value, v->name);
 					} else {
@@ -122,7 +122,7 @@
 		if (event_sub) {
 			ast_event_unsubscribe(event_sub);
 		}
-		event_sub = 0;
+		event_sub = NULL;
 	} else if (!enablecel && newenablecel) {
 		event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, "Manager Event Logging", NULL, AST_EVENT_IE_END);
 		if (!event_sub) {
@@ -154,9 +154,9 @@
 	}
 	ast_log(LOG_NOTICE,"Logging event to manager interface\n");
 
-	eventtype = (enum ast_cel_eventtype)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
-	eventtime.tv_sec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
-	eventtime.tv_usec = (time_t)ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
+	eventtype = (enum ast_cel_eventtype) ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE);
+	eventtime.tv_sec = (time_t) ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME);
+	eventtime.tv_usec = (time_t) ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
 	if (eventtype == CEL_USER_DEFINED) {
 		userdefname = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME);
 	}
@@ -215,7 +215,7 @@
 		ast_free(customfields);
 	}
 	customfields = NULL;
-	event_sub = 0;
+	event_sub = NULL;
 	return 0;
 }
 

Modified: team/group/newcdr/cel/cel_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/cel/cel_pgsql.c?view=diff&rev=166771&r1=166770&r2=166771
==============================================================================
--- team/group/newcdr/cel/cel_pgsql.c (original)
+++ team/group/newcdr/cel/cel_pgsql.c Wed Dec 24 16:32:05 2008
@@ -180,9 +180,7 @@
 			ast_mutex_unlock(&pgsql_lock);
 			return;
 		}
-		if (option_debug > 1) {
-			ast_log(LOG_DEBUG, "cel_pgsql: inserting a CEL record.\n");
-		}
+		ast_debug(2, "cel_pgsql: inserting a CEL record.\n");
 		snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (eventtime,cidname,cidnum,cidani,cidrdnis,ciddnid,exten,context,channel,"
 				 "app,appdata,amaflags,accountcode,uniqueid,userfield,peer,linkedid) VALUES"
 				 " ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d,'%s','%s','%s','%s','%s')",
@@ -190,9 +188,8 @@
 				 exten_esc, context_esc,channel_esc, app_esc, appdata_esc,
 				 amaflag, accountcode_esc, uniqueid_esc, userfield_esc, peer_esc,linkedid_esc);
 		
-		if (option_debug > 2) {
-			ast_log(LOG_DEBUG, "cel_pgsql: SQL command executed:  %s\n",sqlcmd);
-		}
+		ast_debug(3, "cel_pgsql: SQL command executed:  %s\n",sqlcmd);
+
 		/* Test to be sure we're still connected... */
 		/* If we're connected, and connection is working, good. */
 		/* Otherwise, attempt reconnect.  If it fails... sorry... */
@@ -244,22 +241,22 @@
 		PQfinish(conn);
 	}
 	if (pghostname) {
-		free(pghostname);
+		ast_free(pghostname);
 	}
 	if (pgdbname) {
-		free(pgdbname);
+		ast_free(pgdbname);
 	}
 	if (pgdbuser) {
-		free(pgdbuser);
+		ast_free(pgdbuser);
 	}
 	if (pgpassword) {
-		free(pgpassword);
+		ast_free(pgpassword);
 	}
 	if (pgdbport) {
-		free(pgdbport);
+		ast_free(pgdbport);
 	}
 	if (table) {
-		free(table);
+		ast_free(table);
 	}
 	if (event_sub) {
 		ast_event_unsubscribe(event_sub);
@@ -326,21 +323,21 @@
 	}
 	if (option_debug) {
 		if (ast_strlen_zero(pghostname)) {
-			ast_log(LOG_DEBUG, "cel_pgsql: using default unix socket\n");
+			ast_debug(3, "cel_pgsql: using default unix socket\n");
 		} else {
-			ast_log(LOG_DEBUG, "cel_pgsql: got hostname of %s\n", pghostname);
-		}
-		ast_log(LOG_DEBUG, "cel_pgsql: got port of %s\n", pgdbport);
-		ast_log(LOG_DEBUG, "cel_pgsql: got user of %s\n", pgdbuser);
-		ast_log(LOG_DEBUG, "cel_pgsql: got dbname of %s\n", pgdbname);
-		ast_log(LOG_DEBUG, "cel_pgsql: got password of %s\n", pgpassword);
-		ast_log(LOG_DEBUG, "cel_pgsql: got sql table name of %s\n", table);
+			ast_debug(3, "cel_pgsql: got hostname of %s\n", pghostname);
+		}
+		ast_debug(3, "cel_pgsql: got port of %s\n", pgdbport);
+		ast_debug(3, "cel_pgsql: got user of %s\n", pgdbuser);
+		ast_debug(3, "cel_pgsql: got dbname of %s\n", pgdbname);
+		ast_debug(3, "cel_pgsql: got password of %s\n", pgpassword);
+		ast_debug(3, "cel_pgsql: got sql table name of %s\n", table);
 	}
 	
 	conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
 	if (PQstatus(conn) != CONNECTION_BAD) {
 		if (option_debug) {
-			ast_log(LOG_DEBUG, "Successfully connected to PostgreSQL database.\n");
+			ast_debug(3, "Successfully connected to PostgreSQL database.\n");
 		}
 		connected = 1;
 	} else {




More information about the asterisk-commits mailing list