[asterisk-commits] oej: branch oej/pine-cdr-pgsql-status-1.4 r288485 - in /team/oej/pine-cdr-pgs...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 22 13:47:22 CDT 2010


Author: oej
Date: Wed Sep 22 13:47:14 2010
New Revision: 288485

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=288485
Log:
Reset, resolve move on. 

Modified:
    team/oej/pine-cdr-pgsql-status-1.4/   (props changed)
    team/oej/pine-cdr-pgsql-status-1.4/UPGRADE.txt
    team/oej/pine-cdr-pgsql-status-1.4/cdr/cdr_pgsql.c
    team/oej/pine-cdr-pgsql-status-1.4/channels/chan_sip.c
    team/oej/pine-cdr-pgsql-status-1.4/configs/cdr_pgsql.conf.sample
    team/oej/pine-cdr-pgsql-status-1.4/main/asterisk.c

Propchange: team/oej/pine-cdr-pgsql-status-1.4/
------------------------------------------------------------------------------
    automerge = http://www.codename-pineapple.org/

Propchange: team/oej/pine-cdr-pgsql-status-1.4/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Sep 22 13:47:14 2010
@@ -1,1 +1,1 @@
-/branches/1.4:1-288239
+/branches/1.4:1-288484

Modified: team/oej/pine-cdr-pgsql-status-1.4/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-cdr-pgsql-status-1.4/UPGRADE.txt?view=diff&rev=288485&r1=288484&r2=288485
==============================================================================
--- team/oej/pine-cdr-pgsql-status-1.4/UPGRADE.txt (original)
+++ team/oej/pine-cdr-pgsql-status-1.4/UPGRADE.txt Wed Sep 22 13:47:14 2010
@@ -493,6 +493,11 @@
   on the channel from the dialplan and have that change also show up in the 
   CDR, then you *must* set CALLERID(ANI) as well as CALLERID(num).
 
+* cdr_pgsql now assumes the encoding of strings it is handed are in LATIN9,
+  which should cover most uses of the extended ASCII set.  If your strings
+  use a different encoding in Asterisk, the "encoding" parameter may be set
+  to specify the correct character set.
+
 API:
 
 * There are some API functions that were not previously prefixed with the 'ast_'

Modified: team/oej/pine-cdr-pgsql-status-1.4/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-cdr-pgsql-status-1.4/cdr/cdr_pgsql.c?view=diff&rev=288485&r1=288484&r2=288485
==============================================================================
--- team/oej/pine-cdr-pgsql-status-1.4/cdr/cdr_pgsql.c (original)
+++ team/oej/pine-cdr-pgsql-status-1.4/cdr/cdr_pgsql.c Wed Sep 22 13:47:14 2010
@@ -62,7 +62,7 @@
 
 static char *name = "pgsql";
 static char *config = "cdr_pgsql.conf";
-static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL;
+static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL, *encoding = NULL;
 static int connected = 0;
 static time_t connect_time = 0;
 static int totalrecords = 0;
@@ -139,6 +139,9 @@
 			connected = 1;
 			connect_time = time(NULL);
                         records = 0;
+			if (PQsetClientEncoding(conn, encoding)) {
+				ast_log(LOG_WARNING, "Failed to set encoding to '%s'.  Encoding set to default '%s'\n", encoding, pg_encoding_to_char(PQclientEncoding(conn)));
+			}
 		} else {
 			pgerror = PQerrorMessage(conn);
 			ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s.  Calls will not be logged!\n", pghostname);
@@ -270,6 +273,9 @@
 		free(pgdbport);
 	if (table)
 		free(table);
+	if (encoding) {
+		free(encoding);
+	}
 	ast_cdr_unregister(name);
 	return 0;
 }
@@ -331,8 +337,16 @@
 	if (!(table = ast_strdup(tmp)))
 		return -1;
 
+	if (!(tmp = ast_variable_retrieve(cfg, "global", "encoding"))) {
+		tmp = "LATIN9";
+	}
+
+	if (!(encoding = ast_strdup(tmp))) {
+		return -1;
+	}
+
 	if (option_debug) {
-	    	if (ast_strlen_zero(pghostname))
+		if (ast_strlen_zero(pghostname))
 			ast_log(LOG_DEBUG, "cdr_pgsql: using default unix socket\n");
 		else
 			ast_log(LOG_DEBUG, "cdr_pgsql: got hostname of %s\n", pghostname);
@@ -342,14 +356,17 @@
 		ast_log(LOG_DEBUG, "cdr_pgsql: got password of %s\n", pgpassword);
 		ast_log(LOG_DEBUG, "cdr_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");
 		connected = 1;
+		if (PQsetClientEncoding(conn, encoding)) {
+			ast_log(LOG_WARNING, "Failed to set encoding to '%s'.  Encoding set to default '%s'\n", encoding, pg_encoding_to_char(PQclientEncoding(conn)));
+		}
 	} else {
-                pgerror = PQerrorMessage(conn);
+		pgerror = PQerrorMessage(conn);
 		ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s.  CALLS WILL NOT BE LOGGED!!\n", pghostname);
                 ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
 		connected = 0;

Modified: team/oej/pine-cdr-pgsql-status-1.4/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-cdr-pgsql-status-1.4/channels/chan_sip.c?view=diff&rev=288485&r1=288484&r2=288485
==============================================================================
--- team/oej/pine-cdr-pgsql-status-1.4/channels/chan_sip.c (original)
+++ team/oej/pine-cdr-pgsql-status-1.4/channels/chan_sip.c Wed Sep 22 13:47:14 2010
@@ -5463,9 +5463,11 @@
 	/* Host information */
 	struct ast_hostent audiohp;
 	struct ast_hostent videohp;
+	struct ast_hostent imagehp;
 	struct ast_hostent sessionhp;
 	struct hostent *hp = NULL;	/*!< RTP Audio host IP */
 	struct hostent *vhp = NULL;	/*!< RTP video host IP */
+	struct hostent *ihp = NULL;	/*!< UDPTL host IP */
 	int portno = -1;		/*!< RTP Audio port number */
 	int vportno = -1;		/*!< RTP Video port number */
 	int udptlportno = -1;		/*!< UDPTL Image port number */
@@ -5541,6 +5543,7 @@
 				processed = TRUE;
 				hp = &sessionhp.hp;
 				vhp = hp;
+				ihp = hp;
 			}
 			break;
 		case 'a':
@@ -5675,6 +5678,11 @@
 						processed = TRUE;
 						vhp = &videohp.hp;
 					}
+				} else if (image) {
+					if (process_sdp_c(value, &imagehp)) {
+						processed = TRUE;
+						ihp = &imagehp.hp;
+					}
 				}
 				break;
 			case 'a':
@@ -5709,7 +5717,7 @@
 	}
 
 	/* Sanity checks */
-	if (!hp && !vhp) {
+	if (!hp && !vhp && !ihp) {
 		ast_log(LOG_WARNING, "Insufficient information in SDP (c=)...\n");
 		return -1;
 	}
@@ -5844,7 +5852,7 @@
 						ast_log(LOG_DEBUG, "Peer T.38 UDPTL is set behind NAT and with destination, destination address now %s\n", ast_inet_ntoa(isin.sin_addr));
 				}
 			} else
-				memcpy(&isin.sin_addr, hp->h_addr, sizeof(isin.sin_addr));
+				memcpy(&isin.sin_addr, ihp->h_addr, sizeof(isin.sin_addr));
 			ast_udptl_set_peer(p->udptl, &isin);
 			if (debug)
 				ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(isin.sin_addr), ntohs(isin.sin_port));
@@ -13104,11 +13112,12 @@
 {
 	if (ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
 		/* if we can't BYE, then this is really a pending CANCEL */
-		if (p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA)
+		if (p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA) {
+			p->invitestate = INV_CANCELLED;
 			transmit_request(p, SIP_CANCEL, p->lastinvite, XMIT_RELIABLE, FALSE);
 			/* Actually don't destroy us yet, wait for the 487 on our original 
 			   INVITE, but do set an autodestruct just in case we never get it. */
-		else {
+		} else {
 			/* We have a pending outbound invite, don't send someting
 				new in-transaction */
 			if (p->pendinginvite)
@@ -16844,7 +16853,7 @@
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
 			if (req->method != SIP_ACK)
-				transmit_response(p, "503 Server error", req);	/* We must respond according to RFC 3261 sec 12.2 */
+				transmit_response(p, "500 Server error", req);	/* We must respond according to RFC 3261 sec 12.2 */
 			return -1;
 		}
 	} else if (p->icseq &&

Modified: team/oej/pine-cdr-pgsql-status-1.4/configs/cdr_pgsql.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-cdr-pgsql-status-1.4/configs/cdr_pgsql.conf.sample?view=diff&rev=288485&r1=288484&r2=288485
==============================================================================
--- team/oej/pine-cdr-pgsql-status-1.4/configs/cdr_pgsql.conf.sample (original)
+++ team/oej/pine-cdr-pgsql-status-1.4/configs/cdr_pgsql.conf.sample Wed Sep 22 13:47:14 2010
@@ -7,3 +7,4 @@
 ;password=password
 ;user=postgres
 ;table=cdr		;SQL table where CDRs will be inserted
+;encoding=LATIN9	; Encoding of logged characters in Asterisk

Modified: team/oej/pine-cdr-pgsql-status-1.4/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-cdr-pgsql-status-1.4/main/asterisk.c?view=diff&rev=288485&r1=288484&r2=288485
==============================================================================
--- team/oej/pine-cdr-pgsql-status-1.4/main/asterisk.c (original)
+++ team/oej/pine-cdr-pgsql-status-1.4/main/asterisk.c Wed Sep 22 13:47:14 2010
@@ -2625,7 +2625,7 @@
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
 		/* Run as console (-c at startup, implies nofork) */
 		} else if (!strcasecmp(v->name, "console")) {
-			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CONSOLE);
+			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
 		/* Run with high priority if the O/S permits (-p at startup) */
 		} else if (!strcasecmp(v->name, "highpriority")) {
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);




More information about the asterisk-commits mailing list