[asterisk-commits] dlee: branch dlee/better-nicknames r401702 - in /team/dlee/better-nicknames: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 23 22:13:17 CDT 2013


Author: dlee
Date: Wed Oct 23 22:13:15 2013
New Revision: 401702

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=401702
Log:
Merged revisions 401447-401701 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    team/dlee/better-nicknames/   (props changed)
    team/dlee/better-nicknames/cdr/cdr_adaptive_odbc.c
    team/dlee/better-nicknames/channels/chan_iax2.c
    team/dlee/better-nicknames/channels/chan_mgcp.c
    team/dlee/better-nicknames/channels/chan_sip.c
    team/dlee/better-nicknames/channels/sip/reqresp_parser.c
    team/dlee/better-nicknames/configs/iax.conf.sample
    team/dlee/better-nicknames/funcs/func_math.c
    team/dlee/better-nicknames/main/bridge_channel.c
    team/dlee/better-nicknames/main/editline/readline.c
    team/dlee/better-nicknames/main/test.c
    team/dlee/better-nicknames/main/translate.c
    team/dlee/better-nicknames/res/res_rtp_asterisk.c
    team/dlee/better-nicknames/rest-api-templates/ari_model_validators.c.mustache
    team/dlee/better-nicknames/rest-api-templates/models.wiki.mustache
    team/dlee/better-nicknames/rest-api-templates/swagger_model.py
    team/dlee/better-nicknames/rest-api/api-docs/events.json
    team/dlee/better-nicknames/tests/test_dlinklists.c

Propchange: team/dlee/better-nicknames/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/dlee/better-nicknames/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Oct 23 22:13:15 2013
@@ -1,1 +1,1 @@
-/branches/12:1-401435
+/branches/12:1-401701

Modified: team/dlee/better-nicknames/cdr/cdr_adaptive_odbc.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/cdr/cdr_adaptive_odbc.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/cdr/cdr_adaptive_odbc.c (original)
+++ team/dlee/better-nicknames/cdr/cdr_adaptive_odbc.c Wed Oct 23 22:13:15 2013
@@ -720,6 +720,14 @@
 					continue;
 				}
 				first = 0;
+			} else if (entry->filtervalue
+				&& ((!entry->negatefiltervalue && entry->filtervalue[0] != '\0')
+					|| (entry->negatefiltervalue && entry->filtervalue[0] == '\0'))) {
+				ast_verb(4, "CDR column '%s' was not set and does not match filter of"
+					" %s'%s'.  Cancelling this CDR.\n",
+					entry->cdrname, entry->negatefiltervalue ? "!" : "",
+					entry->filtervalue);
+				goto early_release;
 			}
 		}
 

Modified: team/dlee/better-nicknames/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/channels/chan_iax2.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/channels/chan_iax2.c (original)
+++ team/dlee/better-nicknames/channels/chan_iax2.c Wed Oct 23 22:13:15 2013
@@ -13256,7 +13256,6 @@
 			else if (ast_parse_arg(v->value, PARSE_UINT32 | PARSE_IN_RANGE, &portno, 1024, 65535)) {
 				portno = IAX_DEFAULT_PORTNO;
 			}
-			ast_sockaddr_set_port(&bindaddr, portno);
 		} else if (!strcasecmp(v->name, "pingtime")){
 			ping_time = atoi(v->value);
 		}
@@ -13318,18 +13317,28 @@
 			if (reload) {
 				ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
 			} else {
-				/* remember port if it has already been set */
-				int setport = ast_sockaddr_port(&bindaddr);
-
-				if (ast_parse_arg(v->value, PARSE_ADDR | PARSE_PORT_IGNORE, NULL)) {
-					ast_log(LOG_WARNING, "Invalid address '%s' specified, default '%s' will be used\n", v->value,
-						ast_sockaddr_stringify(&bindaddr));
+
+				if (!ast_parse_arg(v->value, PARSE_ADDR, NULL)) {
+
+					ast_sockaddr_parse(&bindaddr, v->value, 0);
+
+					if (!ast_sockaddr_port(&bindaddr)) {
+						ast_sockaddr_set_port(&bindaddr, portno);
+					}
+
+					if (!(ns = ast_netsock_bindaddr(netsock, io, &bindaddr, qos.tos, qos.cos, socket_read, NULL))) {
+						ast_log(LOG_WARNING, "Unable to apply binding to '%s' at line %d\n", v->value, v->lineno);
+					} else {
+						ast_verb(2, "Binding IAX2 to address %s\n", ast_sockaddr_stringify(&bindaddr));
+
+						if (defaultsockfd < 0) {
+							defaultsockfd = ast_netsock_sockfd(ns);
+						}
+						ast_netsock_unref(ns);
+					}
+
 				} else {
-					ast_sockaddr_parse(&bindaddr, v->value, PARSE_PORT_IGNORE);
-				}
-
-				if (setport) {
-					ast_sockaddr_set_port(&bindaddr, setport);
+					ast_log(LOG_WARNING, "Invalid address '%s' specified, at line %d\n", v->value, v->lineno);
 				}
 			}
 		} else if (!strcasecmp(v->name, "authdebug")) {
@@ -13528,15 +13537,14 @@
 		network_change_stasis_unsubscribe();
 	}
 
-	if (!ast_sockaddr_port(&bindaddr)) {
-		ast_sockaddr_set_port(&bindaddr, IAX_DEFAULT_PORTNO);
-	}
-
 	if (defaultsockfd < 0) {
+
+		ast_sockaddr_set_port(&bindaddr, portno);
+
 		if (!(ns = ast_netsock_bindaddr(netsock, io, &bindaddr, qos.tos, qos.cos, socket_read, NULL))) {
 			ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
 		} else {
-			ast_verb(2, "Binding IAX2 to address %s\n", ast_sockaddr_stringify(&bindaddr));
+			ast_verb(2, "Binding IAX2 to default address %s\n", ast_sockaddr_stringify(&bindaddr));
 			defaultsockfd = ast_netsock_sockfd(ns);
 			ast_netsock_unref(ns);
 		}

Modified: team/dlee/better-nicknames/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/channels/chan_mgcp.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/channels/chan_mgcp.c (original)
+++ team/dlee/better-nicknames/channels/chan_mgcp.c Wed Oct 23 22:13:15 2013
@@ -1971,7 +1971,7 @@
 	char *c;
 	char *a;
 	char host[258];
-	int len;
+	int len = 0;
 	int portno;
 	struct ast_format_cap *peercap;
 	int peerNonCodecCapability;
@@ -2001,8 +2001,8 @@
 		ast_log(LOG_WARNING, "Unable to lookup host in c= line, '%s'\n", c);
 		return -1;
 	}
-	if (sscanf(m, "audio %30d RTP/AVP %n", &portno, &len) != 1) {
-		ast_log(LOG_WARNING, "Unable to determine port number for RTP in '%s'\n", m);
+	if (sscanf(m, "audio %30d RTP/AVP %n", &portno, &len) != 1 || !len) {
+		ast_log(LOG_WARNING, "Malformed media stream descriptor: %s\n", m);
 		return -1;
 	}
 	sin.sin_family = AF_INET;

Modified: team/dlee/better-nicknames/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/channels/chan_sip.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/channels/chan_sip.c (original)
+++ team/dlee/better-nicknames/channels/chan_sip.c Wed Oct 23 22:13:15 2013
@@ -13358,10 +13358,11 @@
 		/* Unless otherwise configured, the prefcaps is added before the peer's
 		 * configured codecs.
 		 */
-		if (!ast_test_flag(&p->flags[2], SIP_PAGE3_IGNORE_PREFCAPS) && ast_format_cap_has_joint(tmpcap, p->prefcaps)) {
+		if (!ast_test_flag(&p->flags[2], SIP_PAGE3_IGNORE_PREFCAPS)) {
 			ast_format_cap_iter_start(p->prefcaps);
 			while (!(ast_format_cap_iter_next(p->prefcaps, &tmp_fmt))) {
-				if (AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_AUDIO) {
+				if (AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_AUDIO ||
+					!ast_format_cap_iscompatible(tmpcap, &tmp_fmt)) {
 					continue;
 				}
 				add_codec_to_sdp(p, &tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size, &max_audio_packet_size);

Modified: team/dlee/better-nicknames/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/channels/sip/reqresp_parser.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/channels/sip/reqresp_parser.c (original)
+++ team/dlee/better-nicknames/channels/sip/reqresp_parser.c Wed Oct 23 22:13:15 2013
@@ -1561,6 +1561,10 @@
 				}
 
 				contactptr = AST_LIST_NEXT(contactptr,list);
+			}
+
+			while ((contactptr = AST_LIST_REMOVE_HEAD(contactlistptr,list))) {
+				ast_free(contactptr);
 			}
 		}
 	}

Modified: team/dlee/better-nicknames/configs/iax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/configs/iax.conf.sample?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/configs/iax.conf.sample (original)
+++ team/dlee/better-nicknames/configs/iax.conf.sample Wed Oct 23 22:13:15 2013
@@ -22,11 +22,13 @@
 ;bindport=4569           ; The default port to listen on
                          ; NOTE: bindport must be specified BEFORE bindaddr or
                          ; may be specified on a specific bindaddr if followed by
-                         ; colon and port (e.g. bindaddr=192.168.0.1:4569)
+                         ; colon and port (e.g. bindaddr=192.168.0.1:4569) or for
+                         ; IPv6 the address needs to be in brackets then colon
+                         ; and port (e.g. bindaddr=[2001:db8::1]:4569).
 
 ;bindaddr=192.168.0.1    ; You can specify 'bindaddr' more than once to bind to
                          ; multiple addresses, but the first will be the
-                         ; default.
+                         ; default. IPv6 addresses are accepted.
 
 ;
 ; Set 'iaxcompat' to yes if you plan to use layered switches or some other

Modified: team/dlee/better-nicknames/funcs/func_math.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/funcs/func_math.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/funcs/func_math.c (original)
+++ team/dlee/better-nicknames/funcs/func_math.c Wed Oct 23 22:13:15 2013
@@ -503,6 +503,9 @@
 		res = AST_TEST_FAIL;
 	}
 
+	ast_free(expr);
+	ast_free(result);
+
 	return res;
 }
 #endif

Modified: team/dlee/better-nicknames/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/main/bridge_channel.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/main/bridge_channel.c (original)
+++ team/dlee/better-nicknames/main/bridge_channel.c Wed Oct 23 22:13:15 2013
@@ -1092,6 +1092,7 @@
 #ifdef TEST_FRAMEWORK
 	char *feature = "unknown";
 	struct ast_featuremap_config *featuremap = ast_get_chan_featuremap_config(chan);
+	struct ast_features_xfer_config *xfer = ast_get_chan_features_xfer_config(chan);
 
 	if (featuremap) {
 		if (!strcmp(dtmf, featuremap->blindxfer)) {
@@ -1106,6 +1107,8 @@
 			feature = "automixmon";
 		} else if (!strcmp(dtmf, featuremap->parkcall)) {
 			feature = "parkcall";
+		} else if (!strcmp(dtmf, xfer->atxferthreeway)) {
+			feature = "atxferthreeway";
 		}
 	}
 

Modified: team/dlee/better-nicknames/main/editline/readline.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/main/editline/readline.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/main/editline/readline.c (original)
+++ team/dlee/better-nicknames/main/editline/readline.c Wed Oct 23 22:13:15 2013
@@ -1236,8 +1236,11 @@
 	filename_len = strlen(filename);
 
 	dir = opendir(dirname ? dirname : ".");
-	if (!dir)
+	if (!dir) {
+		free(filename);
+		free(dirname);
 		return (NULL);	/* cannot open the directory */
+	}
 
 	/* find the match */
 	while ((entry = readdir(dir)) != NULL) {
@@ -1274,6 +1277,8 @@
 	} else
 		temp = NULL;
 	closedir(dir);
+	free(filename);
+	free(dirname);
 
 	return (temp);
 }

Modified: team/dlee/better-nicknames/main/test.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/main/test.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/main/test.c (original)
+++ team/dlee/better-nicknames/main/test.c Wed Oct 23 22:13:15 2013
@@ -1053,6 +1053,7 @@
 
 static void test_cleanup(void)
 {
+	ast_cli_unregister_multiple(test_cli, ARRAY_LEN(test_cli));
 	ao2_cleanup(test_suite_topic);
 	test_suite_topic = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_test_suite_message_type);

Modified: team/dlee/better-nicknames/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/main/translate.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/main/translate.c (original)
+++ team/dlee/better-nicknames/main/translate.c Wed Oct 23 22:13:15 2013
@@ -540,6 +540,10 @@
 		/* Predict next outgoing timestamp from samples in this
 		   frame. */
 		path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(&out->subclass.format)));
+		if (f->samples != out->samples && ast_test_flag(out, AST_FRFLAG_HAS_TIMING_INFO)) {
+			ast_debug(4, "Sample size different %u vs %u\n", f->samples, out->samples);
+			ast_clear_flag(out, AST_FRFLAG_HAS_TIMING_INFO);
+		}
 	} else {
 		out->delivery = ast_tv(0, 0);
 		ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);

Modified: team/dlee/better-nicknames/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/res/res_rtp_asterisk.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/res/res_rtp_asterisk.c (original)
+++ team/dlee/better-nicknames/res/res_rtp_asterisk.c Wed Oct 23 22:13:15 2013
@@ -94,6 +94,7 @@
 #define RTCP_PT_PSFB    206
 
 #define RTP_MTU		1200
+#define DTMF_SAMPLE_RATE_MS    8 /*!< DTMF samples per millisecond */
 
 #define DEFAULT_DTMF_TIMEOUT (150 * (8000 / 1000))	/*!< samples */
 
@@ -1726,6 +1727,35 @@
 }
 #endif
 
+/*!
+ * \internal
+ * \brief Calculates the elapsed time from issue of the first tx packet in an
+ *        rtp session and a specified time
+ *
+ * \param rtp pointer to the rtp struct with the transmitted rtp packet
+ * \param delivery time of delivery - if NULL or zero value, will be ast_tvnow()
+ *
+ * \return time elapsed in milliseconds
+ */
+static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery)
+{
+	struct timeval t;
+	long ms;
+
+	if (ast_tvzero(rtp->txcore)) {
+		rtp->txcore = ast_tvnow();
+		rtp->txcore.tv_usec -= rtp->txcore.tv_usec % 20000;
+	}
+
+	t = (delivery && !ast_tvzero(*delivery)) ? *delivery : ast_tvnow();
+	if ((ms = ast_tvdiff_ms(t, rtp->txcore)) < 0) {
+		ms = 0;
+	}
+	rtp->txcore = t;
+
+	return (unsigned int) ms;
+}
+
 static int ast_rtp_new(struct ast_rtp_instance *instance,
 		       struct ast_sched_context *sched, struct ast_sockaddr *addr,
 		       void *data)
@@ -1957,6 +1987,7 @@
 
 	rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
 	rtp->send_duration = 160;
+	rtp->lastts += calc_txstamp(rtp, NULL) * DTMF_SAMPLE_RATE_MS;
 	rtp->lastdigitts = rtp->lastts + rtp->send_duration;
 
 	/* Create the actual packet that we will be sending */
@@ -2037,6 +2068,7 @@
 	/* And now we increment some values for the next time we swing by */
 	rtp->seqno++;
 	rtp->send_duration += 160;
+	rtp->lastts += calc_txstamp(rtp, NULL) * DTMF_SAMPLE_RATE_MS;
 
 	return 0;
 }
@@ -2114,7 +2146,7 @@
 	res = 0;
 
 	/* Oh and we can't forget to turn off the stuff that says we are sending DTMF */
-	rtp->lastts += rtp->send_duration;
+	rtp->lastts += calc_txstamp(rtp, NULL) * DTMF_SAMPLE_RATE_MS;
 cleanup:
 	rtp->sending_digit = 0;
 	rtp->send_digit = 0;
@@ -2162,25 +2194,6 @@
 	rtp->ssrc = ssrc;
 
 	return;
-}
-
-static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval *delivery)
-{
-	struct timeval t;
-	long ms;
-
-	if (ast_tvzero(rtp->txcore)) {
-		rtp->txcore = ast_tvnow();
-		rtp->txcore.tv_usec -= rtp->txcore.tv_usec % 20000;
-	}
-
-	t = (delivery && !ast_tvzero(*delivery)) ? *delivery : ast_tvnow();
-	if ((ms = ast_tvdiff_ms(t, rtp->txcore)) < 0) {
-		ms = 0;
-	}
-	rtp->txcore = t;
-
-	return (unsigned int) ms;
 }
 
 static void timeval2ntp(struct timeval tv, unsigned int *msw, unsigned int *lsw)
@@ -3699,10 +3712,12 @@
 		rtp->rxcount = 0;
 		rtp->cycles = 0;
 		rtp->lastrxseqno = 0;
-		rtp->rtcp->expected_prior = 0;
-		rtp->rtcp->received_prior = 0;
 		rtp->last_seqno = 0;
 		rtp->last_end_timestamp = 0;
+		if (rtp->rtcp) {
+			rtp->rtcp->expected_prior = 0;
+			rtp->rtcp->received_prior = 0;
+		}
 	}
 
 	rtp->rxssrc = ssrc;

Modified: team/dlee/better-nicknames/rest-api-templates/ari_model_validators.c.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/rest-api-templates/ari_model_validators.c.mustache?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/rest-api-templates/ari_model_validators.c.mustache (original)
+++ team/dlee/better-nicknames/rest-api-templates/ari_model_validators.c.mustache Wed Oct 23 22:13:15 2013
@@ -57,11 +57,11 @@
 	if (strcmp("{{id}}", discriminator) == 0) {
 		/* Self type; fall through */
 	} else
-{{#subtypes}}
+{{#all_subtypes}}
 	if (strcmp("{{id}}", discriminator) == 0) {
 		return ast_ari_validate_{{c_id}}(json);
 	} else
-{{/subtypes}}
+{{/all_subtypes}}
 	{
 		ast_log(LOG_ERROR, "ARI {{id}} has undocumented subtype %s\n",
 			discriminator);

Modified: team/dlee/better-nicknames/rest-api-templates/models.wiki.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/rest-api-templates/models.wiki.mustache?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/rest-api-templates/models.wiki.mustache (original)
+++ team/dlee/better-nicknames/rest-api-templates/models.wiki.mustache Wed Oct 23 22:13:15 2013
@@ -5,7 +5,7 @@
 {{#models}}
 h1. {{id}}
 {{#extends}}Base type: [{{extends}}|#{{extends}}]{{/extends}}
-{{#has_subtypes}}Subtypes:{{#subtypes}} [{{id}}|#{{id}}]{{/subtypes}}{{/has_subtypes}}
+{{#has_subtypes}}Subtypes:{{#all_subtypes}} [{{id}}|#{{id}}]{{/all_subtypes}}{{/has_subtypes}}
 {{#wiki_description}}
 
 {{{wiki_description}}}

Modified: team/dlee/better-nicknames/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/rest-api-templates/swagger_model.py?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/rest-api-templates/swagger_model.py (original)
+++ team/dlee/better-nicknames/rest-api-templates/swagger_model.py Wed Oct 23 22:13:15 2013
@@ -33,8 +33,8 @@
 import sys
 import traceback
 
-# I'm not quite sure what was in Swagger 1.2, but apparently I missed it
-SWAGGER_VERSIONS = ["1.1", "1.3"]
+# We don't fully support Swagger 1.2, but we need it for subtyping
+SWAGGER_VERSIONS = ["1.1", "1.2"]
 
 SWAGGER_PRIMITIVES = [
     'void',
@@ -479,13 +479,13 @@
 
     def __init__(self):
         self.id = None
-        self.extends = None
-        self.extends_type = None
+        self.subtypes = []
+        self.__subtype_types = []
         self.notes = None
         self.description = None
         self.__properties = None
         self.__discriminator = None
-        self.__subtypes = []
+        self.__extends_type = None
 
     def load(self, id, model_json, processor, context):
         context = context.next_stack(model_json, 'id')
@@ -494,9 +494,9 @@
         self.id = model_json.get('id')
         if id != self.id:
             raise SwaggerError("Model id doesn't match name", context)
-        self.extends = model_json.get('extends')
-        if self.extends and context.version_less_than("1.3"):
-            raise SwaggerError("Type extension support added in Swagger 1.3",
+        self.subtypes = model_json.get('subTypes') or []
+        if self.subtypes and context.version_less_than("1.2"):
+            raise SwaggerError("Type extension support added in Swagger 1.2",
                                context)
         self.description = model_json.get('description')
         props = model_json.get('properties').items() or []
@@ -507,8 +507,8 @@
         discriminator = model_json.get('discriminator')
 
         if discriminator:
-            if context.version_less_than("1.3"):
-                raise SwaggerError("Discriminator support added in Swagger 1.3",
+            if context.version_less_than("1.2"):
+                raise SwaggerError("Discriminator support added in Swagger 1.2",
                                    context)
 
             discr_props = [p for p in self.__properties if p.name == discriminator]
@@ -526,43 +526,42 @@
         processor.process_model(self, context)
         return self
 
-    def add_subtype(self, subtype):
-        """Add subtype to this model.
-
-        @param subtype: Model instance for the subtype.
-        """
-        self.__subtypes.append(subtype)
+    def extends(self):
+        return self.__extends_type and self.__extends_type.id
 
     def set_extends_type(self, extends_type):
-        self.extends_type = extends_type
+        self.__extends_type = extends_type
+
+    def set_subtype_types(self, subtype_types):
+        self.__subtype_types = subtype_types
 
     def discriminator(self):
         """Returns the discriminator, digging through base types if needed.
         """
         return self.__discriminator or \
-            self.extends_type and self.extends_type.discriminator()
+            self.__extends_type and self.__extends_type.discriminator()
 
     def properties(self):
         base_props = []
-        if self.extends_type:
-            base_props = self.extends_type.properties()
+        if self.__extends_type:
+            base_props = self.__extends_type.properties()
         return base_props + self.__properties
 
     def has_properties(self):
         return len(self.properties()) > 0
 
-    def subtypes(self):
-        """Returns the full list of all subtypes.
-        """
-        res = self.__subtypes + \
-            [subsubtypes for subtype in self.__subtypes
-             for subsubtypes in subtype.subtypes()]
+    def all_subtypes(self):
+        """Returns the full list of all subtypes, including sub-subtypes.
+        """
+        res = self.__subtype_types + \
+              [subsubtypes for subtype in self.__subtype_types
+               for subsubtypes in subtype.all_subtypes()]
         return sorted(res, key=lambda m: m.id)
 
     def has_subtypes(self):
         """Returns True if type has any subtypes.
         """
-        return len(self.subtypes()) > 0
+        return len(self.subtypes) > 0
 
 
 class ApiDeclaration(Stringify):
@@ -646,13 +645,16 @@
         # Now link all base/extended types
         model_dict = dict((m.id, m) for m in self.models)
         for m in self.models:
-            if m.extends:
-                extends_type = model_dict.get(m.extends)
-                if not extends_type:
-                    raise SwaggerError("%s extends non-existing model %s",
-                                       m.id, m.extends)
-                extends_type.add_subtype(m)
-                m.set_extends_type(extends_type)
+            def link_subtype(name):
+                res = model_dict.get(subtype)
+                if not res:
+                    raise SwaggerError("%s has non-existing subtype %s",
+                                       m.id, name)
+                res.set_extends_type(m)
+                return res;
+            if m.subtypes:
+                m.set_subtype_types([
+                    link_subtype(subtype) for subtype in m.subtypes])
         return self
 
 

Modified: team/dlee/better-nicknames/rest-api/api-docs/events.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/rest-api/api-docs/events.json?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/rest-api/api-docs/events.json (original)
+++ team/dlee/better-nicknames/rest-api/api-docs/events.json Wed Oct 23 22:13:15 2013
@@ -3,7 +3,7 @@
 	"_author": "David M. Lee, II <dlee at digium.com>",
 	"_svn_revision": "$Revision$",
 	"apiVersion": "0.0.1",
-	"swaggerVersion": "1.3",
+	"swaggerVersion": "1.2",
 	"basePath": "http://localhost:8088/stasis",
 	"resourcePath": "/api-docs/events.{format}",
 	"apis": [
@@ -43,11 +43,14 @@
 					"required": true,
 					"description": "Indicates the type of this message."
 				}
-			}
+			},
+			"subTypes": [
+				"MissingParams",
+				"Event"
+			]
 		},
 		"MissingParams": {
 			"id": "MissingParams",
-			"extends": "Message",
 			"description": "Error event sent when required params are missing.",
 			"properties": {
 				"params": {
@@ -59,7 +62,6 @@
 		},
 		"Event": {
 			"id": "Event",
-			"extends": "Message",
 			"description": "Base type for asynchronous events from Asterisk.",
 			"properties": {
 				"application": {
@@ -72,11 +74,32 @@
 					"description": "Time at which this event was created.",
 					"required": false
 				}
-			}
+			},
+			"subTypes": [
+				"PlaybackStarted",
+				"PlaybackFinished",
+				"ApplicationReplaced",
+				"BridgeCreated",
+				"BridgeDestroyed",
+				"BridgeMerged",
+				"ChannelCreated",
+				"ChannelDestroyed",
+				"ChannelEnteredBridge",
+				"ChannelLeftBridge",
+				"ChannelStateChange",
+				"ChannelDtmfReceived",
+				"ChannelDialplan",
+				"ChannelCallerId",
+				"ChannelUserevent",
+				"ChannelHangupRequest",
+				"ChannelVarset",
+				"EndpointStateChange",
+				"StasisEnd",
+				"StasisStart"
+			]
 		},
 		"PlaybackStarted": {
 			"id": "PlaybackStarted",
-			"extends": "Event",
 			"description": "Event showing the start of a media playback operation.",
 			"properties": {
 				"playback": {
@@ -88,7 +111,6 @@
 		},
 		"PlaybackFinished": {
 			"id": "PlaybackFinished",
-			"extends": "Event",
 			"description": "Event showing the completion of a media playback operation.",
 			"properties": {
 				"playback": {
@@ -100,13 +122,11 @@
 		},
 		"ApplicationReplaced": {
 			"id": "ApplicationReplaced",
-			"extends": "Event",
 			"description": "Notification that another WebSocket has taken over for an application.\n\nAn application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe to the same application, the newer WebSocket wins, and the older one receives this event.",
 			"properties": {}
 		},
 		"BridgeCreated": {
 			"id": "BridgeCreated",
-			"extends": "Event",
 			"description": "Notification that a bridge has been created.",
 			"properties": {
 				"bridge": {
@@ -117,7 +137,6 @@
 		},
 		"BridgeDestroyed": {
 			"id": "BridgeDestroyed",
-			"extends": "Event",
 			"description": "Notification that a bridge has been destroyed.",
 			"properties": {
 				"bridge": {
@@ -128,7 +147,6 @@
 		},
 		"BridgeMerged": {
 			"id": "BridgeMerged",
-			"extends": "Event",
 			"description": "Notification that one bridge has merged into another.",
 			"properties": {
 				"bridge": {
@@ -143,7 +161,6 @@
 		},
 		"ChannelCreated": {
 			"id": "ChannelCreated",
-			"extends": "Event",
 			"description": "Notification that a channel has been created.",
 			"properties": {
 				"channel": {
@@ -154,7 +171,6 @@
 		},
 		"ChannelDestroyed": {
 			"id": "ChannelDestroyed",
-			"extends": "Event",
 			"description": "Notification that a channel has been destroyed.",
 			"properties": {
 				"cause": {
@@ -175,7 +191,6 @@
 		},
 		"ChannelEnteredBridge": {
 			"id": "ChannelEnteredBridge",
-			"extends": "Event",
 			"description": "Notification that a channel has entered a bridge.",
 			"properties": {
 				"bridge": {
@@ -189,7 +204,6 @@
 		},
 		"ChannelLeftBridge": {
 			"id": "ChannelLeftBridge",
-			"extends": "Event",
 			"description": "Notification that a channel has left a bridge.",
 			"properties": {
 				"bridge": {
@@ -204,7 +218,6 @@
 		},
 		"ChannelStateChange": {
 			"id": "ChannelStateChange",
-			"extends": "Event",
 			"description": "Notification of a channel's state change.",
 			"properties": {
 				"channel": {
@@ -215,7 +228,6 @@
 		},
 		"ChannelDtmfReceived": {
 			"id": "ChannelDtmfReceived",
-			"extends": "Event",
 			"description": "DTMF received on a channel.\n\nThis event is sent when the DTMF ends. There is no notification about the start of DTMF",
 			"properties": {
 				"digit": {
@@ -237,7 +249,6 @@
 		},
 		"ChannelDialplan": {
 			"id": "ChannelDialplan",
-			"extends": "Event",
 			"description": "Channel changed location in the dialplan.",
 			"properties": {
 				"channel": {
@@ -259,7 +270,6 @@
 		},
 		"ChannelCallerId": {
 			"id": "ChannelCallerId",
-			"extends": "Event",
 			"description": "Channel changed Caller ID.",
 			"properties": {
 				"caller_presentation": {
@@ -281,7 +291,6 @@
 		},
 		"ChannelUserevent": {
 			"id": "ChannelUserevent",
-			"extends": "Event",
 			"description": "User-generated event with additional user-defined fields in the object.",
 			"properties": {
 				"eventname": {
@@ -303,7 +312,6 @@
 		},
 		"ChannelHangupRequest": {
 			"id": "ChannelHangupRequest",
-			"extends": "Event",
 			"description": "A hangup was requested on the channel.",
 			"properties": {
 				"cause": {
@@ -323,7 +331,6 @@
 		},
 		"ChannelVarset": {
 			"id": "ChannelVarset",
-			"extends": "Event",
 			"description": "Channel variable changed.",
 			"properties": {
 				"variable": {
@@ -345,7 +352,6 @@
 		},
 		"EndpointStateChange": {
 			"id": "EndpointStateChange",
-			"extends": "Event",
 			"description": "Endpoint state changed.",
 			"properties": {
 				"endpoint": {
@@ -356,7 +362,6 @@
 		},
 		"StasisEnd": {
 			"id": "StasisEnd",
-			"extends": "Event",
 			"description": "Notification that a channel has left a Stasis appliction.",
 			"properties": {
 				"channel": {
@@ -367,7 +372,6 @@
 		},
 		"StasisStart": {
 			"id": "StasisStart",
-			"extends": "Event",
 			"description": "Notification that a channel has entered a Stasis appliction.",
 			"properties": {
 				"args": {

Modified: team/dlee/better-nicknames/tests/test_dlinklists.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/better-nicknames/tests/test_dlinklists.c?view=diff&rev=401702&r1=401701&r2=401702
==============================================================================
--- team/dlee/better-nicknames/tests/test_dlinklists.c (original)
+++ team/dlee/better-nicknames/tests/test_dlinklists.c Wed Oct 23 22:13:15 2013
@@ -337,6 +337,7 @@
 
 		if (e == b) {
 			AST_DLLIST_REMOVE_CURRENT(list);  /* C A */
+			free(b);
 			print_list(tc, "C <=> A");
 		}
 		if (e == a) {
@@ -348,6 +349,7 @@
 	AST_DLLIST_TRAVERSE_SAFE_END;
 	print_list(tc, "C <=> A <=> D");
 
+	destroy_test_container(tc);
 }
 
 static int unload_module(void)




More information about the asterisk-commits mailing list