From: Michael Tremer Date: Sun, 12 Oct 2014 14:53:12 +0000 (+0200) Subject: installer: Make networking and download functions more user-friendly X-Git-Tag: v2.17-core87~103^2~51^2~1 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=35853bb47bc3a8dea8591979aa4d23a78c255f60 installer: Make networking and download functions more user-friendly Allows to retry after a failed attempt or abort --- diff --git a/src/installer/main.c b/src/installer/main.c index 411121c125..ba50cd9b6f 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -351,37 +351,57 @@ int main(int argc, char *argv[]) { /* If we could not find a source drive, we will try * downloading the install image */ if (!sourcedrive) { - require_networking = 1; - if (!unattended) { - rc = newtWinOkCancel(title, _("No source drive could be found.\n\n" - "You can try to download the required installation data. " - "Please make sure to connect your machine to a network and " - "the installer will try connect to acquire an IP address."), - 55, 10, _("Download installation image"), _("Cancel")); + // Show the right message to the user + char reason[STRING_SIZE]; + if (require_networking) { + snprintf(reason, sizeof(reason), + _("The installer will now try downloading the installation image.")); + } else { + snprintf(reason, sizeof(reason), + _("No source drive could be found.\n\n" + "You can try downloading the required installation image.")); + } + snprintf(message, sizeof(message), "%s %s", reason, + _("Please make sure to connect your machine to a network and " + "the installer will try connect to acquire an IP address.")); + + rc = newtWinOkCancel(title, message, 55, 12, + _("Download installation image"), _("Cancel")); if (rc != 0) goto EXIT; } + + require_networking = 1; } // Try starting the networking if we require it if (require_networking) { - statuswindow(60, 4, title, _("Trying to start networking (DHCP)...")); + while (1) { + statuswindow(60, 4, title, _("Trying to start networking (DHCP)...")); - rc = hw_start_networking(logfile); - newtPopWindow(); + rc = hw_start_networking(logfile); + newtPopWindow(); - if (rc) { - errorbox(_("Networking could not be started " - "but is required to go on with the installation.\n\n" - "Please connect your machine to a network with a " - "DHCP server and retry.")); - goto EXIT; + // Networking was successfully started + if (rc == 0) { + break; + + // An error happened, ask the user what to do + } else { + rc = newtWinOkCancel(title, _("Networking could not be started " + "but is required to go on with the installation.\n\n" + "Please connect your machine to a network with a " + "DHCP server and retry."), 50, 10, _("Retry"), _("Cancel")); + + if (rc) + goto EXIT; + } } // Download the image if required - if (!sourcedrive) { + while (!sourcedrive) { snprintf(commandstring, sizeof(commandstring), "/usr/bin/downloadsource.sh %s", SOURCE_TEMPFILE); runcommandwithstatus(commandstring, title, _("Downloading installation image..."), logfile); @@ -390,8 +410,11 @@ int main(int argc, char *argv[]) { sourcedrive = SOURCE_TEMPFILE; fclose(f); } else { - errorbox(_("The installation image could not be downloaded.")); - goto EXIT; + rc = newtWinOkCancel(title, _("The installation image could not be downloaded."), + 60, 8, _("Retry"), _("Cancel")); + + if (rc) + goto EXIT; } } }