Add license dialog to the installer.

This commit is contained in:
Arne Fitzenreiter
2010-10-20 20:01:24 +02:00
parent 59093c5ec4
commit e0bbaf8777
8 changed files with 112 additions and 7 deletions

View File

@@ -35,6 +35,9 @@ extern char *fr_tr[];
int main(int argc, char *argv[])
{
char discl_msg[40000] = "Disclaimer\n";
char *langnames[] = { "Deutsch", "English", "Français", "Español", NULL };
char *shortlangnames[] = { "de", "en", "fr", "es", NULL };
char **langtrs[] = { de_tr, en_tr, fr_tr, es_tr, NULL };
@@ -57,7 +60,7 @@ int main(int argc, char *argv[])
int allok_fastexit=0;
int raid_disk = 0;
struct keyvalue *ethernetkv = initkeyvalues();
FILE *handle, *cmdfile;
FILE *handle, *cmdfile, *copying;
char line[STRING_SIZE];
char string[STRING_SIZE];
long memory = 0, disk = 0, free;
@@ -108,6 +111,16 @@ int main(int argc, char *argv[])
}
}
// Read gpl ...
if (! (copying = fopen("/COPYING", "r")))
{
fprintf(flog, "Couldn't open gpl (/COPYING)\n");
sprintf(discl_msg, "Couldn't open gpl (/COPYING)\n");
} else {
fread(discl_msg, 1, 40000, copying);
fclose(copying);
}
// Load common modules
mysystem("/sbin/modprobe iso9660"); // CDROM
mysystem("/sbin/modprobe ext2"); // Boot patition
@@ -135,6 +148,13 @@ int main(int argc, char *argv[])
sprintf(message, ctr[TR_WELCOME], NAME);
newtWinMessage(title, ctr[TR_OK], message);
if (!unattended) {
if (disclaimerbox(discl_msg)==0) {
errorbox(ctr[TR_LICENSE_NOT_ACCEPTED]);
goto EXIT;
}
}
switch (mysystem("/bin/mountsource.sh")) {
case 0:
break;

View File

@@ -79,6 +79,8 @@ void reboot(void);
void stripnl(char *s);
int mysystem(char *command);
void errorbox(char *message);
int statuswindowscroll(int width, int height, char *title, char *text, ...);
int disclaimerbox(char *message);
void statuswindow(int width, int height, char *title, char *text, ...);
int runcommandwithprogress(int width, int height, char *title, char *command,
int lines, char *text, ...);

View File

@@ -45,6 +45,61 @@ void errorbox(char *message)
newtWinMessage(ctr[TR_ERROR], ctr[TR_OK], message);
}
int scrollmsgbox(int width, int height, char *title, char *text, ...)
{
int rc = 0;
newtComponent t, f, b, c;
char *buf = NULL;
char checkbox;
int size = 0;
int i = 0;
va_list args;
va_start(args, text);
do {
size += 40000;
if (buf) free(buf);
buf = malloc(size);
i = vsnprintf(buf, size, text, args);
} while (i == size);
va_end(args);
newtCenteredWindow(width, height, title);
b = newtCompactButton(width - 15 ,height - 2, ctr[TR_OK]);
c = newtCheckbox(3, height - 2, ctr[TR_LICENSE_ACCEPT], ' ', " *", &checkbox);
t = newtTextbox(1, 1, width - 2, height - 4, NEWT_TEXTBOX_WRAP+NEWT_TEXTBOX_SCROLL);
newtTextboxSetText(t, buf);
f = newtForm(NULL, NULL, 0);
free(buf);
newtFormAddComponent(f, c);
newtFormAddComponent(f, b);
newtFormAddComponent(f, t);
newtRunForm(f);
if (checkbox=='*') rc=1;
newtFormDestroy(f);
return rc;
}
int disclaimerbox(char *message)
{
int rc;
char title[STRING_SIZE];
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
rc = scrollmsgbox(75, 20, title, message);
newtPopWindow();
return rc;
}
void statuswindow(int width, int height, char *title, char *text, ...)
{
newtComponent t, f;