Release: 1.1.3.2
[captive.git] / src / install / acquire / final.c
1 /* $Id$
2  * Final result message of drivers acquiring installation utility
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "final.h"      /* self */
23 #include <glib/gmessages.h>
24 #include <stdio.h>
25 #include <mntent.h>
26 #include <glib/gstring.h>
27 #include <string.h>
28
29 #include <captive/macros.h>
30
31
32 /* Config: */
33 #define FILENAME_ETC_FSTAB        "/etc/fstab"
34
35
36 gchar *final_text(gboolean all_modules_found)
37 {
38 const gchar *base;
39 FILE *mntentfiler;
40 struct mntent *mntent;
41 GString *gstring;
42 gboolean any_dirs_found;
43
44         if (!all_modules_found)
45                 base=_(
46                                 "Although essential modules (\"ntoskrnl.exe\" and \"ntfs.sys\") are available "
47                                 "you may still want to get their better version and/or more modules. ");
48         else 
49                 base=_("All needed modules were found in their best preferred versions.");
50         gstring=g_string_new(base);
51
52         any_dirs_found=FALSE;
53         /* FIXME: locking! */
54         if (!(mntentfiler=setmntent(FILENAME_ETC_FSTAB,"r")))
55                 g_error(_("Cannot open \"%s\" for reading: %m"),FILENAME_ETC_FSTAB);
56         while ((mntent=getmntent(mntentfiler))) {
57                 if (strcmp(mntent->mnt_type,"captive-ntfs"))
58                         continue;
59                 if (!any_dirs_found) {
60                         gstring=g_string_append(gstring,captive_printf_alloca(_("\n"
61                                         "Found NTFS disk partitions are prepared in %s. "
62                                         "You can mount them by commands mount(8) or usermount(1) such as:\n"
63                                         "\tmount /mnt/captive-LABEL_C\n"
64                                         "Available captive-ntfs partitions:"),FILENAME_ETC_FSTAB));
65                         any_dirs_found=TRUE;
66                         }
67                 gstring=g_string_append(gstring,"\n\t");
68                 gstring=g_string_append(gstring,mntent->mnt_dir);
69                 }
70         if (!any_dirs_found)
71                 gstring=g_string_append(gstring,_("\n"
72                                 "Despite drivers were found no NTFS disk partitions were found on your computer. "
73                                 "You still can mount read/write NTFS partitions by using filesystem type 'captive-ntfs' such as:\n"
74                                 "\tmkdir /mnt/captive-LABEL_C\n"
75                                 "\tmount -t captive-ntfs /dev/hda1 /mnt/captive-LABEL_C"));
76         if (1!=endmntent(mntentfiler))
77                 g_warning(_("Cannot close \"%s\" after reading: %m"),FILENAME_ETC_FSTAB);
78         
79         return g_string_free(gstring,
80                         FALSE); /* free_segment */
81 }