home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / clients / inst_ask_config.ycp < prev    next >
Encoding:
Text File  |  2000-03-30  |  8.4 KB  |  265 lines

  1. /**
  2.  *
  3.  * $Id: inst_ask_config.ycp,v 1.21 2000/03/10 12:59:20 kkaempf Exp $
  4.  *
  5.  * Module:        inst_ask_config.ycp
  6.  *
  7.  * Author:        Stefan Hundhammer <sh@suse.de>
  8.  *
  9.  * Purpose:        Let the user branch into various configuration dialogs:
  10.  *
  11.  * user_settings:    To be defined
  12.  */
  13. {
  14.  
  15.   if (false) {
  16. // this is a multiprocessor system
  17. // the installed kernel modules are smp
  18. // but the running kernel is still uniprocessor (from installing)
  19. // configuration now does not work, because the smp modules can't
  20. // be loaded while the uniprocessor kernel is running.
  21. // tell the user to reboot (with the smp kernel) and do
  22. // the configuration later (after reboot).
  23.     UI(`DisplayMessage(_("\
  24. This is a multiprocessor system.\n
  25. \n
  26. You must finish the installation now,\n
  27. reboot and use YaST2 later\n")));
  28.   }
  29.  
  30.   list aprobe = [];
  31.   map device = $[];
  32.   string sub_vendor = "";
  33.   string sub_device = "";
  34.  
  35.   // default text below "Detected:" for printer
  36.   string printer_name        = UI(_("no printer detected"));
  37.   aprobe = SCR(`Read(.probe.byclass.printer));
  38.   if (size (aprobe) > 0) {
  39.     device = select (aprobe, 0);
  40.     sub_vendor = lookup (device, "sub_vendor", "");
  41.     sub_device = lookup (device, "sub_device", "");
  42.     if ((sub_vendor != "") && (sub_device != ""))
  43.     printer_name = sub_vendor + " " + sub_device;
  44.     else
  45.     printer_name = lookup (device, "vendor", "") + " " + lookup (device, "device", "");
  46.     y2log (.milestone, "ask_config", 1, "printer: "+ printer_name);
  47.   }
  48.  
  49.   // default text below "Detected:" for sound cards
  50.   string sound_card_name    = UI(_("no sound card detected"));
  51.   aprobe = SCR(`Read(.probe.byclass.multimedia.audio));
  52.   if (size (aprobe) > 0) {
  53.     device = select (aprobe, 0);
  54.     sub_vendor = lookup (device, "sub_vendor", "");
  55.     sub_device = lookup (device, "sub_device", "");
  56.     if ((sub_vendor != "") && (sub_device != ""))
  57.     sound_card_name = sub_vendor + "\n" + sub_device;
  58.     else
  59.     sound_card_name = lookup (device, "vendor", "") + "\n" + lookup (device, "device", "");
  60.     y2log (.milestone, "ask_config", 1, "sound: "+ sound_card_name);
  61.   }
  62.  
  63.   // default text below "Detected:" for dialup internet
  64.   string modem_name        = UI(_("no modem or isdn card detected"));
  65.   aprobe = SCR(`Read(.probe.byclass.modem));
  66.   if (size (aprobe) == 0) {
  67.     aprobe = SCR(`Read(.probe.byclass.isdn));
  68.   }
  69.   if (size (aprobe) > 0) {
  70.     device = select (aprobe, 0);
  71.     sub_vendor = lookup (device, "sub_vendor", "");
  72.     sub_device = lookup (device, "sub_device", "");
  73.     if ((sub_vendor != "") && (sub_device != ""))
  74.     modem_name = sub_vendor + "\n" + sub_device;
  75.     else
  76.     modem_name = lookup (device, "vendor", "") + "\n" + lookup (device, "device", "");
  77.     y2log (.milestone, "ask_config", 1, "modem: "+ modem_name);
  78.   }
  79.  
  80.   // default text below "Detected:" for network
  81.   string network_card_name    = UI(_("no ethernet card detected"));
  82.   aprobe = SCR(`Read(.probe.byclass.network));
  83.   if (size (aprobe) > 0) {
  84.     device = select (aprobe, 0);
  85.     sub_vendor = lookup (device, "sub_vendor", "");
  86.     sub_device = lookup (device, "sub_device", "");
  87.     if ((sub_vendor != "") && (sub_device != ""))
  88.     network_card_name = sub_vendor + "\n" + sub_device;
  89.     else
  90.     network_card_name = lookup (device, "vendor", "") + "\n" + lookup (device, "device", "");
  91.     y2log (.milestone, "ask_config", 1, "network: "+ network_card_name);
  92.   }
  93.  
  94.  
  95.   // Build window contents
  96.  
  97.   term contents = `HBox(
  98.             `HWeight( 3, `HStretch() ),
  99.             `HWeight( 100,
  100.                   `HVCenter(
  101.                         `VBox(
  102.                           `VWeight( 3, `VStretch() ),
  103.  
  104.                           `VWeight( 15,
  105.                                 `Frame ( _( "Printer" ),
  106.                                      `HBox(
  107.                                        `HWeight( 55,
  108.                                              // Constant text: Headline for detected hardware
  109.                                              // The name of the hardware is displayed in the line below
  110.                                              // `Left( `Label( _( "Detected:" ) ) ),
  111.                                              `Left( `Label( printer_name ) )
  112.                                              ),
  113.  
  114.                                        `HWeight( 45,
  115.                                              // PushButton: Branch to printer configuration dialog
  116.                                              `PushButton ( `id( `printer ), `opt( `hstretch ), _( "Configure &Printer..." ) )
  117.                                              )
  118.                                        )
  119.                                      )
  120.                                 ),
  121.  
  122.                           `VWeight( 5, `VStretch() ),
  123.                           `VWeight( 15,
  124.                                 `Frame ( _( "Sound" ),
  125.                                      `HBox(
  126.                                        `HWeight( 55,
  127.                                              // Constant text: Headline for detected hardware
  128.                                              // The name of the hardware is displayed in the line below
  129.                                              // `Left( `Label( _( "Detected:" ) ) ),
  130.                                              `Left( `Label( sound_card_name ) )
  131.                                              ),
  132.  
  133.                                        `HWeight( 45,
  134.                                              // PushButton: Branch to sound configuration dialog
  135.                                              `PushButton ( `id( `sound ), `opt( `hstretch ), _( "Configure &Sound..." ) )
  136.                                              )
  137.                                        )
  138.                                      )
  139.                                 ),
  140.  
  141.                           `VWeight( 5, `VStretch() ),
  142.                           `VWeight( 15,
  143.                                 `Frame ( _( "Internet" ),
  144.                                      `HBox(
  145.                                        `HWeight( 55,
  146.                                              // Constant text: Headline for detected hardware
  147.                                              // The name of the hardware is displayed in the line below
  148.                                              // `Left( `Label( _( "Detected:" ) ) ),
  149.                                              `Left( `Label( modem_name ) )
  150.                                              ),
  151.  
  152.                                        `HWeight( 45,
  153.                                              // PushButton: Branch to internet configuration dialog
  154.                                              `PushButton ( `id( `internet ), `opt( `hstretch ), _( "Configure &Internet..." ) )
  155.                                              )
  156.                                        )
  157.                                      )
  158.                                 ),
  159.  
  160.                           `VWeight( 5, `VStretch() ),
  161.                           `VWeight( 15,
  162.                                 `Frame ( _( "Network" ),
  163.                                      `HBox(
  164.                                        `HWeight( 55,
  165.                                              // Constant text: Headline for detected hardware
  166.                                              // The name of the hardware is displayed in the line below
  167.                                              // `Left( `Label( _( "Detected:" ) ) ),
  168.                                              `Left( `Label( network_card_name ) )
  169.                                              ),
  170.  
  171.                                        `HWeight( 45,
  172.                                              // PushButton: Branch to network configuration dialog
  173.                                              `PushButton ( `id( `network ), `opt( `hstretch ), _( "Configure &Network..." ) )
  174.                                              )
  175.                                        )
  176.                                      )
  177.                                 ),
  178.  
  179.                           `VWeight( 10, `VStretch() )
  180.                           )
  181.                         )
  182.                   ),
  183.             `HWeight( 3, `HStretch() )
  184.             );
  185.  
  186.   // Help text for inst_ask_config_x11.ycp:
  187.   // The user is prompted to branch into various configuration dialogs.
  188.   //
  189.   // Help text (HTML-like) START
  190.   string help_text = UI( _( "<p>
  191. Configure any of the system components shown.
  192. </p>" ) );
  193.  
  194.   // Help text (HTML-like) continued
  195.   help_text = help_text + UI( _( "<p>
  196. If you wish, you can <b><i>skip those configurations now and instead finish the installaton</i></b>.
  197. You can perform those configurations later at any time.
  198. </p>" ) );
  199.  
  200.  
  201.   // Help text (HTML-like) continued
  202.   help_text = help_text + UI( _( "<p>
  203. Any of the configuration dialogs will take you back to this screen here after they are finished.
  204. </p>" ) );
  205.  
  206.   // Help text (HTML-like) END
  207.   help_text = help_text + UI( _( "<p>
  208. Please notice that not all kinds of hardware can be detected automatically.
  209. If your hardware is not shown here, you may still be able to configure it manually.
  210. Just press the appropriate configuration button in this dialog.
  211. </p>" ) );
  212.  
  213.  
  214.   UI(`SetWizardContents(
  215.             // Headline for gerneral configuration screen:
  216.             // The user can perform various configurations from here,
  217.             // e.g. printer, sound, internet, network.
  218.             _("System Component Configuration"),
  219.             contents,
  220.             help_text,
  221.             Args(0),    // have_back_button
  222.             Args(1)        // have_next_button
  223.             )
  224.      );
  225.  
  226.   UI(`ReplaceWizardNextButton(
  227.                   // new caption for "Next" button ("&Installation abschliessen" in german !)
  228.                   `PushButton(`id(`next), _("&Finish installation") )
  229.                   ));
  230.  
  231.   // Event loop
  232.  
  233.   any ret = nil;
  234.  
  235.   repeat
  236.       {
  237.       ret = UI(`UserInput());
  238.       if      ( ret == `printer     )    CallModule( "printconf", [] );
  239.       else if ( ret == `sound     )    CallModule( "sound",     [] );
  240.       else if ( ret == `internet     )    CallModule( "dialup",     [] );
  241.       else if ( ret == `network     ) {
  242.         CallModule( "lan",     [] );
  243.         // we're at the end of installation here, dhclient will
  244.         // be restarted during bootup after we exit isnt_ask_config
  245.         Shell("/sbin/init.d/dhclient stop 2>/dev/null"); // just in case
  246.       }
  247.       else if ( ret == `back     )
  248.           UI(`RestoreWizardNextButton());
  249.  
  250.       } until (ret == `next || ret == `back);
  251.  
  252.   UI(`SetModulename("inst_ask_config"));
  253.  
  254.   if (ret == `next)
  255.   {
  256.       // Popup window that is displayed after successful installation
  257.       UI(`DisplayMessage(sformat(UI(_("\
  258. Your system is now installed.\n\
  259. Now you can log in as `%1'.")),
  260.                  lookup (user_settings, "loginname"))));
  261.   }
  262.  
  263.   return ret;
  264. }
  265.