Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / install / acquire / ui-line.c
index c349d11..fdd3f9a 100644 (file)
@@ -25,6 +25,7 @@
 #include "main.h"
 #include <unistd.h>
 #include <time.h>
+#include "final.h"
 
 #ifdef HAVE_LIBREADLINE
 #include <readline/readline.h>
@@ -70,10 +71,13 @@ static gboolean aborted=FALSE;
 static time_t search_start_time;
 static gboolean abort_msg_printed=FALSE;
 
-static gboolean ui_line_search_is_aborted(void)
+static gboolean ui_line_progress(GnomeVFSURI *uri)
 {
 fd_set readfds;
 struct timeval timeval;
+static int stdin_isatty=-1;
+
+       /* 'uri' may be NULL */
 
        if (aborted)
                return TRUE;
@@ -87,7 +91,9 @@ struct timeval timeval;
                abort_msg_printed=TRUE;
                }
 
-       if (isatty(0)) {
+       if (stdin_isatty==-1)
+               stdin_isatty=isatty(0);
+       if (stdin_isatty>0) {
                FD_ZERO(&readfds);
                FD_SET(0,&readfds);
                timeval.tv_sec=0;
@@ -103,7 +109,7 @@ struct timeval timeval;
        return FALSE;
 }
 
-static void ui_line_search_is_aborted_reset(void)
+static void ui_line_progress_reset(void)
 {
        aborted=FALSE;
        search_start_time=0;
@@ -120,7 +126,7 @@ char line[1024],*s;
 
        g_return_val_if_fail(prompt!=NULL,NULL);
 
-       ui_line_search_is_aborted_reset();
+       ui_line_progress_reset();
 
 #ifdef HAVE_LIBREADLINE
        line=readline(prompt);
@@ -144,6 +150,7 @@ char line[1024],*s;
 
 /* FIXME: HACK: Encode module essentiality to '.captivemodid.xml'. */
 struct print_modules_available_foreach_param {
+       gboolean do_print;
        gboolean ntoskrnl_exe_found;
        gboolean ntfs_sys_found;
        };
@@ -155,14 +162,15 @@ static void print_modules_available_foreach
        g_return_if_fail(type!=NULL);
        g_return_if_fail(module_available!=NULL);
        g_return_if_fail(module_available->module!=NULL);
-       g_return_if_fail(!strcmp(type,module_available->module->type));
+       g_return_if_fail(!strcmp((const char *)type,(const char *)module_available->module->type));
        g_return_if_fail(param!=NULL);
 
-       print_ui_line_module_available(module_available);
+       if (param->do_print)
+               print_ui_line_module_available(module_available);
 
-       /**/ if (!strcmp(type,"ntoskrnl.exe"))
+       /**/ if (!strcmp((const char *)type,"ntoskrnl.exe"))
                param->ntoskrnl_exe_found=TRUE;
-       else if (!strcmp(type,"ntfs.sys"))
+       else if (!strcmp((const char *)type,"ntfs.sys"))
                param->ntfs_sys_found=TRUE;
 }
 
@@ -171,8 +179,10 @@ static gboolean print_modules_available(void)
 {
 struct print_modules_available_foreach_param param;
 gboolean r;
+static gboolean first_time=TRUE;
 
        putchar('\n');
+       param.do_print=!first_time;
        param.ntoskrnl_exe_found=FALSE;
        param.ntfs_sys_found=FALSE;
        if (module_available_hash)
@@ -186,9 +196,11 @@ gboolean r;
        if (r)
                puts(_(
                                "Essential modules (\"ntoskrnl.exe\" and \"ntfs.sys\") are available.\n"
-                               "You still may want to get their better version and/or more modules."));
+                               "You may still want to get their better version and/or more modules."));
        putchar('\n');
 
+       first_time=FALSE;
+
        return r;
 }
 
@@ -215,8 +227,11 @@ gboolean essentials_available;
                        free(line);
                        return FALSE;
                        }
-               if (!strncasecmp(line,_("done"),strlen(line)))
+               if (!strncasecmp(line,_("done"),strlen(line))) {
+                       putchar('\n');
+                       puts(final_text(all_modules_found));
                        exit(EXIT_SUCCESS);
+                       }
                free(line);
                }
        /* NOTREACHED */
@@ -233,7 +248,11 @@ static void ui_line_interactive(void)
        while (!all_modules_found) {
 char *line;
 
-               if (ui_line_interactive_ask(_("Fully scan all directories of your local disks?")))
+               if (ui_line_interactive_ask(_(
+                               "Detection of language localized MS-Windows drivers is missing."
+                               " You may need to copy localized ntfs.sys and ntoskrnl.exe to /var/lib/captive/ by cp(1) command;"
+                               " contact me for their proper identification, please.\n"
+                               "Fully scan all directories of your local disks?")))
                        scan_disks();
 
                if (!all_modules_found)
@@ -244,12 +263,10 @@ char *line;
                                if (line && *line) {
 GnomeVFSURI *uri;
 
-                                       uri=gnome_vfs_uri_new((strncmp(line,"http://",strlen("http://")) ? line
-                                                       : captive_printf_alloca("httpcaptive://%s",line+strlen("http://"))));
-                                       if (!uri)
+                                       if (!(uri=gnome_vfs_uri_new(line)))
                                                printf(_("Error paring URI: %s"),line);
                                        else {
-                                               mod_uri_load(uri);
+                                               mod_uri_load_base_reporting(uri);
                                                gnome_vfs_uri_unref(uri);
                                                }
                                        free(line);
@@ -261,22 +278,24 @@ GnomeVFSURI *uri;
                                } while (!all_modules_found && line);
 
                if (ui_line_interactive_ask(_(
-                               "You can download the best available version of needed drivers from Microsoft.\n"
-                               "They can be found in Microsoft Windows XP Service Pack 1 Checked Build.\n"
-                               "URL: http://www.microsoft.com/WindowsXP/pro/downloads/servicepacks/sp1/checkedbuild.asp\n"
+                               "You can download the best available version of needed drivers from Microsoft. They can be found in Microsoft Windows XP Service Pack 2 Checked Build.\n"
+                               "URL: http://msdn.microsoft.com/security/productinfo/xpsp2\n"
                                "Legal: In some countries you need to have valid Microsoft Windows XP license to use it.\n"
-                               "We will need to download approx 29MB od data right now (takes 2 hours on 33.6 modem).")))
+                               "It is needed to download approx 61MB of data right now out of the 307MB file size. You can also download the file separately and load it in the previous screen if some problems occur.\n")))
                        microsoft_com();
                if (!all_modules_found)
-                       puts(_("\nWe tried all available drivers acquiration method - the options will start again."));
+                       puts(_("\nWe tried all available drivers acquiration methods - the options will start again."));
                }
+       putchar('\n');
+       puts(final_text(all_modules_found));
 }
 
 gboolean ui_line_init(void)
 {
        acquire_module_available_notify=ui_line_module_available_notify;
        acquire_module_all_modules_found_notify=ui_line_all_modules_found_notify;
-       ui_search_is_aborted=ui_line_search_is_aborted;
+       ui_progress=ui_line_progress;
        ui_interactive=ui_line_interactive;
+       /* 'captivemodid_module_best_priority_notify' left NULL. */
        return TRUE;
 }