[libpri-commits] rmudgett: branch group/issue14068 r802 - /team/group/issue14068/

SVN commits to the libpri project libpri-commits at lists.digium.com
Mon May 18 10:28:34 CDT 2009


Author: rmudgett
Date: Mon May 18 10:28:31 2009
New Revision: 802

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=802
Log:
Found a way to eliminate PRI_EVENT_FACNAME and maintain bacward compatibility.

*  Replaced PRI_EVENT_FACNAME with PRI_EVENT_FACILITY and adjusted the new
event to maintain backward compatibility.

*  Removed awkward struct pri_subcommands.size_subcmd and just simply
reserve room to maintain ABI compatibility.  (Reserving space does not
guarantee future ABI compatibility, but it is much easier to use.)

*  Added subcmds element to most call message events to allow for
supplementary servcies.

Modified:
    team/group/issue14068/libpri.h
    team/group/issue14068/pri.c
    team/group/issue14068/q931.c

Modified: team/group/issue14068/libpri.h
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/libpri.h?view=diff&rev=802&r1=801&r2=802
==============================================================================
--- team/group/issue14068/libpri.h (original)
+++ team/group/issue14068/libpri.h Mon May 18 10:28:31 2009
@@ -80,7 +80,8 @@
 #define PRI_EVENT_ANSWER		 8	/* Call has been answered (CONNECT) */
 #define PRI_EVENT_HANGUP_ACK	 9	/* Call hangup has been acknowledged */
 #define PRI_EVENT_RESTART_ACK	10	/* Restart complete on a given channel (RESTART_ACKNOWLEDGE) */
-#define PRI_EVENT_FACNAME		11	/* Caller*ID Name received on Facility */
+#define PRI_EVENT_FACNAME		11	/* Caller*ID Name received on Facility (DEPRECATED) */
+#define PRI_EVENT_FACILITY		11	/* Facility received (FACILITY) */
 #define PRI_EVENT_INFO_RECEIVED 12	/* Additional info (digits) received (INFORMATION) */
 #define PRI_EVENT_PROCEEDING	13	/* When we get CALL_PROCEEDING */
 #define PRI_EVENT_SETUP_ACK		14	/* When we get SETUP_ACKNOWLEDGE */
@@ -90,7 +91,6 @@
 #define PRI_EVENT_KEYPAD_DIGIT	18	/* When we receive during ACTIVE state (INFORMATION) */
 #define PRI_EVENT_SERVICE       19	/* SERVICE maintenance message */
 #define PRI_EVENT_SERVICE_ACK   20	/* SERVICE maintenance acknowledgement message */
-#define PRI_EVENT_FACILITY		21	/* Facility received (FACILITY) */
 
 /* Simple states */
 #define PRI_STATE_DOWN		0
@@ -415,6 +415,8 @@
 	/*! PRI_SUBCMD_xxx defined values */
 	int cmd;
 	union {
+		/*! Reserve room for possible expansion to maintain ABI compatibility. */
+		char reserve_space[2048];
 		struct pri_subcmd_connected_line connected_line;
 		struct pri_subcmd_redirecting redirecting;
 	};
@@ -425,11 +427,6 @@
 
 struct pri_subcommands {
 	int counter_subcmd;
-	/*!
-	 * \note This is set to sizeof(struct pri_subcommand) to
-	 * maintain ABI compatibility if more subcommand events are addd.
-	 */
-	unsigned size_subcmd;
 	struct pri_subcommand subcmd[PRI_MAX_SUBCOMMANDS];
 };
 
@@ -461,6 +458,7 @@
 	char callednum[256];
 	int calledpres;
 	int calledplan;
+	struct pri_subcommands subcmds;
 } pri_event_ringing;
 
 typedef struct pri_event_answer {
@@ -476,8 +474,10 @@
 	int connectedpres;
 	int connectedplan;
 	int source;
+	struct pri_subcommands subcmds;
 } pri_event_answer;
 
+/*! Deprecated replaced by struct pri_event_facility. */
 typedef struct pri_event_facname {
 	int e;
 	char callingname[256];
@@ -491,9 +491,13 @@
 
 struct pri_event_facility {
 	int e;
+	char callingname[256];		/*!< Deprecated, preserved for struct pri_event_facname compatibility */
+	char callingnum[256];		/*!< Deprecated, preserved for struct pri_event_facname compatibility */
 	int channel;
 	int cref;
 	q931_call *call;
+	int callingpres;			/*!< Presentation of Calling CallerID (Deprecated, preserved for struct pri_event_facname compatibility) */
+	int callingplan;			/*!< Dialing plan of Calling entity (Deprecated, preserved for struct pri_event_facname compatibility) */
 	struct pri_subcommands subcmds;
 };
 
@@ -531,6 +535,7 @@
 	int origredirectingreason;
 	int redirectingpres;
 	int redirectingcount;
+	struct pri_subcommands subcmds;
 } pri_event_ring;
 
 typedef struct pri_event_hangup {
@@ -541,6 +546,7 @@
 	q931_call *call;			/* Opaque call pointer */
 	long aoc_units;				/* Advise of Charge number of charged units */
 	char useruserinfo[260];		/* User->User info */
+	struct pri_subcommands subcmds;
 } pri_event_hangup;	
 
 typedef struct pri_event_restart_ack {
@@ -557,12 +563,14 @@
 	int progressmask;
 	int cause;
 	q931_call *call;
+	struct pri_subcommands subcmds;
 } pri_event_proceeding;
  
 typedef struct pri_event_setup_ack {
 	int e;
 	int channel;
 	q931_call *call;
+	struct pri_subcommands subcmds;
 } pri_event_setup_ack;
 
 typedef struct pri_event_notify {
@@ -576,6 +584,7 @@
 	int channel;
 	q931_call *call;
 	char digits[64];
+	struct pri_subcommands subcmds;
 } pri_event_keypad_digit;
 
 typedef struct pri_event_service {
@@ -595,7 +604,7 @@
 	pri_event_generic gen;		/* Generic view */
 	pri_event_restart restart;	/* Restart view */
 	pri_event_error	  err;		/* Error view */
-	pri_event_facname facname;	/* Caller*ID Name on Facility */
+	pri_event_facname facname;	/* Caller*ID Name on Facility (Deprecated, use pri_event.facility) */
 	pri_event_ring	  ring;		/* Ring */
 	pri_event_hangup  hangup;	/* Hang up */
 	pri_event_ringing ringing;	/* Ringing */

Modified: team/group/issue14068/pri.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri.c?view=diff&rev=802&r1=801&r2=802
==============================================================================
--- team/group/issue14068/pri.c (original)
+++ team/group/issue14068/pri.c Mon May 18 10:28:31 2009
@@ -355,8 +355,6 @@
 		return "Hangup ACK";
 	case PRI_EVENT_RESTART_ACK:
 		return "Restart ACK";
-	case PRI_EVENT_FACNAME:
-		return "FacName";
 	case PRI_EVENT_FACILITY:
 		return "Facility";
 	case PRI_EVENT_INFO_RECEIVED:

Modified: team/group/issue14068/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/q931.c?view=diff&rev=802&r1=801&r2=802
==============================================================================
--- team/group/issue14068/q931.c (original)
+++ team/group/issue14068/q931.c Mon May 18 10:28:31 2009
@@ -3374,7 +3374,6 @@
 static void clr_subcommands(struct pri_subcommands *sub)
 {
 	sub->counter_subcmd = 0;
-	sub->size_subcmd = sizeof(struct pri_subcommand);
 }
 
 static struct pri_subcommand *get_ptr_subcommand(struct pri_subcommands *sub)
@@ -3917,6 +3916,8 @@
 	case Q931_FACILITY:
 		{
 			int haveevent = 0;
+			struct pri_subcommand *subcmd;
+
 			clr_subcommands(&pri->ev.facility.subcmds);
 
 			if (c->newcall) {
@@ -3928,12 +3929,7 @@
 
 				if (c->ctcompletecallstatus == 0) {
 					/* answered(0) */
-					struct pri_subcommand *subcmd;
-
 					pri_message(pri, "Got CT-Complete, callStatus = answered(0)\n");
-					pri->ev.e = PRI_EVENT_FACILITY;
-					pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
-					pri->ev.facility.call = c;
 
 					subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
 					if (subcmd) {
@@ -3950,12 +3946,7 @@
 					}
 				} else if (c->ctcompletecallstatus == 1) {
 					/* alerting(1) */
-					struct pri_subcommand *subcmd;
-
 					pri_message(pri, "Got CT-Complete, callStatus = alerting(1)\n");
-					pri->ev.e = PRI_EVENT_FACILITY;
-					pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
-					pri->ev.facility.call = c;
 
 					subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
 					if (subcmd) {
@@ -3979,14 +3970,9 @@
 					pri_message(pri, "illegal value for callStatus=%d\n", c->ctcompletecallstatus);
 				}
 			} else if (c->ctactiveflag) {
-				struct pri_subcommand *subcmd;
-
 				c->ctactiveflag = 0;
 
 				pri_message(pri, "Got CT-Active\n");
-				pri->ev.e = PRI_EVENT_FACILITY;
-				pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
-				pri->ev.facility.call = c;
 
 				subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
 				if (subcmd) {
@@ -4001,16 +3987,10 @@
 					haveevent = 1;
 					pri_message(pri, "CT-Active, sending facility PRI_SUBCMD_CONNECTED_LINE (%s/%s)\n", cmdcl->party.id.name, cmdcl->party.id.number);
 				}
-			}
-			else if (c->divleginfo1activeflag) {
-				struct pri_subcommand *subcmd;
-
+			} else if (c->divleginfo1activeflag) {
 				c->divleginfo1activeflag = 0;
 
 				pri_message(pri, "Got DivertingLegInformation1\n");
-				pri->ev.e = PRI_EVENT_FACILITY;
-				pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
-				pri->ev.facility.call = c;
 
 				subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
 				if (subcmd) {
@@ -4032,8 +4012,20 @@
 				}
 			}
 
-			if (haveevent)
+			if (haveevent) {
+				pri->ev.e = PRI_EVENT_FACILITY;
+				pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
+				pri->ev.facility.cref = c->cr;
+				pri->ev.facility.call = c;
+
+				/* Need to do this for backward compatibility with struct pri_event_facname */
+				libpri_copy_string(pri->ev.facility.callingname, c->callername, sizeof(pri->ev.facility.callingname));
+				libpri_copy_string(pri->ev.facility.callingnum, c->callernum, sizeof(pri->ev.facility.callingnum));
+				pri->ev.facility.callingpres = c->callerpres;
+				pri->ev.facility.callingplan = c->callerplan;
+
 				return Q931_RES_HAVEEVENT;
+			}
 		}
 		break;
 	case Q931_PROGRESS:




More information about the libpri-commits mailing list