[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] cdebconf: Fix build of ncurses,bogl,slang frontends



Hi all,

They need to be adapted to the changed API for q_get_* etc. 

The attached patch should be obviously correct and safe to apply,
but I'm sending it here for review just in case.

	Max

Index: debian/changelog
===================================================================
--- debian/changelog	(Revision 53045)
+++ debian/changelog	(Arbeitskopie)
@@ -1,8 +1,13 @@
 cdebconf (0.131) UNRELEASED; urgency=low
 
+  [ Frans Pop ]
   * gtk frontend: remove special handling for countrychooser/country-name as
     that template no longer exists. Requires: localechooser (>= 2.02).
 
+  [ Max Vozeler ]
+  * src/modules/frontend/{ncurses,slang,bogl}: Adapt to API changes made in 
+    cdebconf 0.129 - q_get_*() and question_get_value().
+
  -- Frans Pop <fjp@debian.org>  Sun, 20 Apr 2008 18:21:40 +0200
 
 cdebconf (0.130) unstable; urgency=low
Index: src/modules/frontend/ncurses/ncurses.c
===================================================================
--- src/modules/frontend/ncurses/ncurses.c	(Revision 53045)
+++ src/modules/frontend/ncurses/ncurses.c	(Arbeitskopie)
@@ -225,8 +225,8 @@
 {
 	WINDOW *qrywin = UIDATA(ui)->qrywin;
 	WINDOW *descwin = UIDATA(ui)->descwin;
-	char *descr = q_get_description(q);
-	char *ext_descr = q_get_extended_description(q);
+	char *descr = q_get_description(ui, q);
+	char *ext_descr = q_get_extended_description(ui, q);
 
 	drawframe(ui, WIN_QUERY, ui->title);
 	wrapprint(qrywin, descr, 0, COLS-2);
@@ -369,13 +369,13 @@
 	WINDOW *win = UIDATA(ui)->qrywin;
 
 	/* Parse out all the choices */
-	count = strchoicesplit(q_get_choices_vals(q), choices, DIM(choices));
+	count = strchoicesplit(q_get_choices_vals(ui, q), choices, DIM(choices));
 	if (count <= 0) return DC_NOTOK;
 	if (count == 1)
 		defval = choices[0];
 
-	strchoicesplit(q_get_choices(q), choices_translated, DIM(choices_translated));
-	dcount = strchoicesplit(question_get_field(q, "C", "value"), defaults, DIM(defaults));
+	strchoicesplit(q_get_choices(ui, q), choices_translated, DIM(choices_translated));
+	dcount = strchoicesplit(question_get_field(ui, q, "C", "value"), defaults, DIM(defaults));
 
 	/* See what the currently selected value should be -- either a
 	 * previously selected value, or the default for the question
Index: src/modules/frontend/slang/slang.c
===================================================================
--- src/modules/frontend/slang/slang.c	(Revision 53045)
+++ src/modules/frontend/slang/slang.c	(Arbeitskopie)
@@ -202,8 +202,8 @@
 static void slang_drawdesc(struct frontend *ui, struct question *q)
 {
 	struct uidata *uid = UIDATA(ui);
-	char *descr = q_get_description(q);
-	char *ext_descr = q_get_extended_description(q);
+	char *descr = q_get_description(ui, q);
+	char *ext_descr = q_get_extended_description(ui, q);
 
 	/* Clear the windows */
 	slang_drawwin(&uid->qrywin);
@@ -290,14 +290,14 @@
 static char *get_text(struct frontend *obj, const char *template, char *fallback)
 {
         struct question *q = obj->qdb->methods.get(obj->qdb, template);
-        return q ? q_get_description(q) : fallback;
+        return q ? q_get_description(obj, q) : fallback;
 }
 
 static char *button_text(struct frontend *obj, const char *template, char *fallback)
 {
 	char text[50];
         struct question *q = obj->qdb->methods.get(obj->qdb, template);
-	sprintf(text, "< %s >", q ? q_get_description(q) : fallback);
+	sprintf(text, "< %s >", q ? q_get_description(obj, q) : fallback);
 	return strdup(text);
 }
 
@@ -368,7 +368,7 @@
 	if (!yes_text)	yes_text = get_text(ui, "debconf/button-yes", "Yes");
 	if (!no_text)  	no_text = get_text(ui, "debconf/button-no", "No");
 
-	value = question_get_field(q, "C", "value");
+	value = question_get_field(ui, q, "C", "value");
 
 	ans = (strcmp(value, "true") == 0);
 	pos = (ans ? 2 : 3);
@@ -428,24 +428,24 @@
 	char *selected;
 	char answer[1024] = {0};
 	int *tindex = NULL;
-	const char *indices = q_get_indices(q);
+	const char *indices = q_get_indices(ui, q);
 	int i, j, count, dcount, ret = 0, val = 0, pos = 2, xpos, ypos;
 	int top, bottom, longest, ch;
 	struct uidata *uid = UIDATA(ui);
 	struct slwindow *win = &uid->qrywin;
 
 	/* Parse out all the choices */
-	count = strgetargc(q_get_choices_vals(q));
+	count = strgetargc(q_get_choices_vals(ui, q));
 	if (count <= 0)
 		return DC_NOTOK;
 	choices = malloc(sizeof(char *) * count);
 	choices_translated = malloc(sizeof(char *) * count);
 	tindex = malloc(sizeof(int) * count);
-	if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q), indices, choices, choices_translated, tindex, count) != count)
+	if (strchoicesplitsort(q_get_choices_vals(ui, q), q_get_choices(ui, q), indices, choices, choices_translated, tindex, count) != count)
 		return DC_NOTOK;
 
 	defaults = malloc(sizeof(char *) * count);
-	dcount = strchoicesplit(question_get_field(q, "C", "value"), defaults, count);
+	dcount = strchoicesplit(question_get_field(ui, q, "C", "value"), defaults, count);
 	INFO(INFO_VERBOSE, "Parsed out %d choices, %d defaults", count, dcount);
 	if (dcount <= 0) return DC_NOTOK;
 	if (count == 1 && !multi)
@@ -592,7 +592,7 @@
 	int xpos = 0, ypos = win->y + win->border + 4;
 	int cursor;
 
-	STRCPY(value, question_get_field(q, "C", "value"));
+	STRCPY(value, question_get_field(ui, q, "C", "value"));
 	cursor = strlen(value);
 
 	/* TODO: scrolling */
Index: src/modules/frontend/bogl/bogl.c
===================================================================
--- src/modules/frontend/bogl/bogl.c	(Revision 53045)
+++ src/modules/frontend/bogl/bogl.c	(Arbeitskopie)
@@ -38,7 +38,7 @@
 get_text(struct frontend *obj, const char *template, const char *fallback )
 {
 	        struct question *q = obj->qdb->methods.get(obj->qdb, template);
-		return q ? q_get_description(q) : fallback;
+		return q ? q_get_description(obj, q) : fallback;
 }
 
 static handler_t handler(const char *type)
@@ -62,12 +62,12 @@
 static void drawdesctop(struct frontend *ui, struct question *q)
 {
 	bowl_title(ui->title);
-	bowl_new_text(q_get_description(q));
+	bowl_new_text(q_get_description(ui, q));
 }
 
 static void drawdescbot(struct frontend *ui, struct question *q)
 {
-	bowl_new_text(q_get_extended_description(q));
+	bowl_new_text(q_get_extended_description(ui, q));
 }
 
 
@@ -76,7 +76,7 @@
 int bogl_handler_boolean(struct frontend *ui, struct question *q)
 {
 	/* Should just make bowl_new_checkbox be properly const-qualified. */
-	char *desc = strdup(q_get_description(q));
+	char *desc = strdup(q_get_description(ui, q));
 	int ret;
 	
 #if 0
@@ -128,7 +128,7 @@
 	const char *p;
 
 	count = 0;
-	p = q_get_choices_vals(q);
+	p = q_get_choices_vals(ui, q);
 	if (*p)
 	{
 		count++;
@@ -140,18 +140,18 @@
 	if (count <= 0) return DC_NOTOK;
 
 	choices = malloc(sizeof(char *) * count);
-	strchoicesplit(q_get_choices_vals(q), choices, count);
+	strchoicesplit(q_get_choices_vals(ui, q), choices, count);
 	choices_translated = malloc(sizeof(char *) * count);
-	strchoicesplit(q_get_choices(q), choices_translated, count);
+	strchoicesplit(q_get_choices(ui, q), choices_translated, count);
 	selected = malloc(sizeof(char) * count);
 	memset(selected, ' ', count);
 
 	dcount = 1;
-	for(p = question_get_field(q, "C", "value"); *p; p++)
+	for(p = question_get_field(ui, q, "C", "value"); *p; p++)
 		if(*p == ',')
 		  	dcount++;
 	defaults = malloc(sizeof(char *) * dcount);
-	dcount = strchoicesplit(question_get_field(q, "C", "value"), defaults, dcount);
+	dcount = strchoicesplit(question_get_field(ui, q, "C", "value"), defaults, dcount);
 	for(j = 0; j < dcount; j++)
 	{
 		for(i = 0; i < count; i++)
@@ -176,7 +176,7 @@
 	if(ret == DC_OK)
 	{
 		/* Be safe - allow for commas and spaces. */
-		char *answer = malloc(strlen(q_get_choices(q)) + 1 + count);
+		char *answer = malloc(strlen(q_get_choices(ui, q)) + 1 + count);
 		answer[0] = 0;
 		for(i = 0; i < count; i++)
 			if (selected[i] == '*')
@@ -202,7 +202,7 @@
 
 	bowl_flush();
 	drawdesctop(ui, q);
-	bowl_new_input(&s, question_get_field(q, "C", "value"));
+	bowl_new_input(&s, question_get_field(ui, q, "C", "value"));
 	drawnavbuttons(ui, q);
 	drawdescbot(ui, q);
 	bowl_layout();

Reply to: