[Asterisk-code-review] menuselect: Add ability to set deprecated and removed versions. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Wed Mar 10 08:12:27 CST 2021


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15623 )


Change subject: menuselect: Add ability to set deprecated and removed versions.
......................................................................

menuselect: Add ability to set deprecated and removed versions.

The "deprecated_in" and "removed_in" information can now be
set in MODULEINFO for a module and is then displayed in
menuselect so users can be aware of when a module is slated
to be deprecated and then removed.

ASTERISK-29337

Change-Id: I6952889cf08e0e9e99cf8b43f99b3cef4688087a
---
M menuselect/menuselect.c
M menuselect/menuselect.h
M menuselect/menuselect_curses.c
M menuselect/menuselect_newt.c
4 files changed, 50 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/23/15623/1

diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c
index 2eea3f0..2ef075f 100644
--- a/menuselect/menuselect.c
+++ b/menuselect/menuselect.c
@@ -210,6 +210,8 @@
 		xmlFree((void *) mem->defaultenabled);
 		xmlFree((void *) mem->support_level);
 		xmlFree((void *) mem->replacement);
+		xmlFree((void *) mem->deprecated_in);
+		xmlFree((void *) mem->removed_in);
 	}
 
 	free(mem);
@@ -341,6 +343,32 @@
 	return 0;
 }
 
+static int process_xml_deprecatedin_node(xmlNode *node, struct member *mem)
+{
+	const char *tmp = (const char *) xmlNodeGetContent(node);
+
+	if (tmp && !strlen_zero(tmp)) {
+		xmlFree((void *) mem->deprecated_in);
+		mem->deprecated_in = tmp;
+		print_debug("Set deprecated_in for %s to %s\n", mem->name, mem->deprecated_in);
+	}
+
+	return 0;
+}
+
+static int process_xml_removedin_node(xmlNode *node, struct member *mem)
+{
+	const char *tmp = (const char *) xmlNodeGetContent(node);
+
+	if (tmp && !strlen_zero(tmp)) {
+		xmlFree((void *) mem->removed_in);
+		mem->removed_in = tmp;
+		print_debug("Set removed_in for %s to %s\n", mem->name, mem->removed_in);
+	}
+
+	return 0;
+}
+
 static int process_xml_ref_node(xmlNode *node, struct member *mem, struct reference_list *refs)
 {
 	struct reference *ref;
@@ -416,6 +444,8 @@
 	{ "conflict",       process_xml_conflict_node       },
 	{ "use",            process_xml_use_node            },
 	{ "member_data",    process_xml_member_data_node    },
+	{ "deprecated_in",  process_xml_deprecatedin_node   },
+	{ "removed_in",     process_xml_removedin_node      },
 };
 
 static node_handler lookup_node_handler(xmlNode *node)
diff --git a/menuselect/menuselect.h b/menuselect/menuselect.h
index d41859e..9c71de2 100644
--- a/menuselect/menuselect.h
+++ b/menuselect/menuselect.h
@@ -70,6 +70,8 @@
 	const char *touch_on_change;
 	const char *support_level;
 	const char *replacement;
+	const char *deprecated_in;
+	const char *removed_in;
 	/*! member_data is just an opaque, member-specific string */
 	const char *member_data;
 	/*! This module is currently selected */
diff --git a/menuselect/menuselect_curses.c b/menuselect/menuselect_curses.c
index fe42119..7698061 100644
--- a/menuselect/menuselect_curses.c
+++ b/menuselect/menuselect_curses.c
@@ -279,13 +279,21 @@
 
 	if (!mem->is_separator) { /* Separators lack support levels */
 		{ /* support level */
+			char buf2[64];
 			wmove(menu, end - start_y + 7, start_x);
 			snprintf(buf, sizeof(buf), "Support Level: %s", mem->support_level);
 			if (mem->replacement && *mem->replacement) {
-				char buf2[64];
 				snprintf(buf2, sizeof(buf2), ", Replaced by: %s", mem->replacement);
 				strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
 			}
+			if (mem->deprecated_in && *mem->deprecated_in) {
+				snprintf(buf2, sizeof(buf2), ", Deprecated in: %s", mem->deprecated_in);
+				strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
+			}
+			if (mem->removed_in && *mem->removed_in) {
+				snprintf(buf2, sizeof(buf2), ", Removed in: %s", mem->removed_in);
+				strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
+			}
 			waddstr(menu, buf);
 		}
 	}
diff --git a/menuselect/menuselect_newt.c b/menuselect/menuselect_newt.c
index bc03f9b..b0f7574 100644
--- a/menuselect/menuselect_newt.c
+++ b/menuselect/menuselect_newt.c
@@ -110,6 +110,7 @@
 static void display_member_info(struct member *mem)
 {
 	char buffer[128] = { 0 };
+	char buf2[64];
 
 	struct reference *dep;
 	struct reference *con;
@@ -175,10 +176,17 @@
 	{ /* Support Level */
 		snprintf(buffer, sizeof(buffer), "%s", mem->support_level);
 		if (mem->replacement && *mem->replacement) {
-			char buf2[64];
 			snprintf(buf2, sizeof(buf2), ", Replaced by: %s", mem->replacement);
 			strncat(buffer, buf2, sizeof(buffer) - strlen(buffer) - 1);
 		}
+		if (mem->deprecated_in && *mem->deprecated_in) {
+			snprintf(buf2, sizeof(buf2), ", Deprecated in: %s", mem->deprecated_in);
+			strncat(buffer, buf2, sizeof(buffer) - strlen(buffer) - 1);
+		}
+		if (mem->removed_in && *mem->removed_in) {
+			snprintf(buf2, sizeof(buf2), ", Removed in: %s", mem->removed_in);
+			strncat(buffer, buf2, sizeof(buffer) - strlen(buffer) - 1);
+		}
 		if (mem->is_separator) {
 			newtTextboxSetText(supportLevelDataTextbox, "");
 		} else {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15623
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I6952889cf08e0e9e99cf8b43f99b3cef4688087a
Gerrit-Change-Number: 15623
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210310/45ff72ad/attachment.html>


More information about the asterisk-code-review mailing list