[asterisk-commits] russell: branch group/newcdr r201824 - /team/group/newcdr/main/cel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 18 17:40:51 CDT 2009


Author: russell
Date: Thu Jun 18 17:40:48 2009
New Revision: 201824

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201824
Log:
Restructure ast_cel_report_event() to reduce indentation, and remove an unneeded variable

Modified:
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/main/cel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=201824&r1=201823&r2=201824
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Thu Jun 18 17:40:48 2009
@@ -527,70 +527,66 @@
 
 void ast_cel_report_event(const struct ast_channel *chan, enum ast_cel_eventtype eventtype, char *userdefevname, const char *extra, const struct ast_channel *peer2)
 {
-	if (ast_cel_track_event(eventtype)) {
-		int trackit = 1;
-
-		ast_debug(3,"CEL event tracked: %s\n", ast_cel_eventtype2str(eventtype));
-
-		if (eventtype == CEL_APP_START || eventtype == CEL_APP_END) {
-
-			if (!ast_hashtab_lookup(appset, chan->appl)) {
-				trackit = 0;
-			}
+	struct timeval eventtime;
+	struct ast_event *ev;
+	char *udef = userdefevname;
+	const char *peername = "";
+	struct ast_channel *peer = ast_bridged_channel((struct ast_channel *) chan);
+
+	if (!ast_cel_track_event(eventtype)) {
+		ast_debug(1, "CEL event UNtracked: %s\n", ast_cel_eventtype2str(eventtype));
+	}
+
+	ast_debug(3, "CEL event tracked: %s\n", ast_cel_eventtype2str(eventtype));
+
+	if (eventtype == CEL_APP_START || eventtype == CEL_APP_END) {
+		if (!ast_hashtab_lookup(appset, chan->appl)) {
+			return;
 		}
-		if (trackit) {
-			struct timeval eventtime;
-			struct ast_event *ev;
-			char *udef = userdefevname;
-			const char *peername = "";
-			struct ast_channel *peer = ast_bridged_channel((struct ast_channel*)chan);
-
-			if (peer) {
-				peername = peer->name;
-			}
-			if (peer2) {
-				peername = peer2->name;
-			}
-			if (!udef) {
-				udef = "";
-			}
-			if (!extra) {
-				extra = "";
-			}
-			eventtime = ast_tvnow();
-			/* now, report this event */
-			ev = ast_event_new(AST_EVENT_CEL,
-							   AST_EVENT_IE_CEL_EVENT_TYPE, AST_EVENT_IE_PLTYPE_UINT, eventtype,
-							   AST_EVENT_IE_CEL_EVENT_TIME, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_sec,
-							   AST_EVENT_IE_CEL_EVENT_TIME_USEC, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_usec,
-							   AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_STR, udef,
-							   AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_name,""),
-							   AST_EVENT_IE_CEL_CIDNUM, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_num,""),
-							   AST_EVENT_IE_CEL_CIDANI, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_ani,""),
-							   AST_EVENT_IE_CEL_CIDRDNIS, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_rdnis,""),
-							   AST_EVENT_IE_CEL_CIDDNID, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_dnid,""),
-							   AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_PLTYPE_STR, chan->exten,
-							   AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_PLTYPE_STR, chan->context,
-							   AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, chan->name,
-							   AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->appl,""),
-							   AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->data,""),
-							   AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
-							   AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, chan->accountcode,
-							   AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_PLTYPE_STR, chan->peeraccount,
-							   AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, chan->uniqueid,
-							   AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_PLTYPE_STR, chan->linkedid,
-							   AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_PLTYPE_STR, chan->userfield,
-							   AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, extra,
-							   AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, peername,
-							   AST_EVENT_IE_END);
-			if (!ev) {
-				ast_log(LOG_NOTICE,"NULL event returned\n");
-				return;
-			}
-			ast_event_queue(ev); /* a lot of stuff happens here */
-		}
-	} else {
-		ast_log(LOG_DEBUG,"CEL event UNtracked: %s\n", ast_cel_eventtype2str(eventtype));
+	}
+
+	if (peer) {
+		peername = peer->name;
+	}
+	if (peer2) {
+		peername = peer2->name;
+	}
+	if (!udef) {
+		udef = "";
+	}
+	if (!extra) {
+		extra = "";
+	}
+
+	eventtime = ast_tvnow();
+
+	ev = ast_event_new(AST_EVENT_CEL,
+			AST_EVENT_IE_CEL_EVENT_TYPE, AST_EVENT_IE_PLTYPE_UINT, eventtype,
+			AST_EVENT_IE_CEL_EVENT_TIME, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_sec,
+			AST_EVENT_IE_CEL_EVENT_TIME_USEC, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_usec,
+			AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_STR, udef,
+			AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_name,""),
+			AST_EVENT_IE_CEL_CIDNUM, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_num,""),
+			AST_EVENT_IE_CEL_CIDANI, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_ani,""),
+			AST_EVENT_IE_CEL_CIDRDNIS, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_rdnis,""),
+			AST_EVENT_IE_CEL_CIDDNID, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->cid.cid_dnid,""),
+			AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_PLTYPE_STR, chan->exten,
+			AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_PLTYPE_STR, chan->context,
+			AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, chan->name,
+			AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->appl,""),
+			AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->data,""),
+			AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
+			AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, chan->accountcode,
+			AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_PLTYPE_STR, chan->peeraccount,
+			AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, chan->uniqueid,
+			AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_PLTYPE_STR, chan->linkedid,
+			AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_PLTYPE_STR, chan->userfield,
+			AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, extra,
+			AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, peername,
+			AST_EVENT_IE_END);
+
+	if (ev && ast_event_queue(ev)) {
+		ast_event_destroy(ev);
 	}
 }
 




More information about the asterisk-commits mailing list