? eula_prompt.patch Index: dialog_ui.c =================================================================== RCS file: /cvs/cvsroot/loki_setup/dialog_ui.c,v retrieving revision 1.3 diff -u -r1.3 dialog_ui.c --- dialog_ui.c 2002/04/03 08:10:24 1.3 +++ dialog_ui.c 2002/09/06 10:22:30 @@ -14,6 +14,7 @@ #include "install.h" #include "install_ui.h" +#include "install_log.h" #include "detect.h" #include "file.h" #include "copy.h" @@ -137,6 +138,11 @@ xmlNodePtr node = parent->childs; while ( node && nb_choicesname, "option") ) { /* Skip options that are already installed */ if ( info->product && ! GetProductReinstall(info) ) { @@ -155,7 +161,6 @@ choices[i++] = strdup(get_option_name(info, node, NULL, 0)); choices[i++] = (set && !strcmp(set,"true")) ? "on" : "off"; choices[i++] = get_option_help(info, node); - nb_choices++; } else if ( ! strcmp(node->name, "exclusive") ) { nodes[nb_choices] = node; @@ -175,6 +180,8 @@ node = node->next; } + /* loop until the selected options are all validated by possible EULA */ +options_loop: clear_screen(); snprintf(buf, sizeof(buf), _("Installation of %s"), info->desc); if ( dialog_checklist(buf, _("Please choose the options to install"), @@ -187,6 +194,40 @@ for ( i = 0; i < nb_choices; ++i ) { if ( !strcmp(nodes[i]->name, "option") ) { if ( result[i] ) { + /* does this option have a EULA item */ + xmlNodePtr child; + child = nodes[i]->childs; + while(child) + { + if (!strcmp(child->name, "eula")) + { + /* this option has some EULA nodes + * we need to prompt before this change can be validated / turned on + */ + const char* name = GetEULA_ForOption(info, nodes[i]); + if (name) + { + /* prompt for the EULA */ + dialog_textbox(_("License Agreement"), name, -1, -1); + clear_screen(); + if ( dialog_prompt(_("Do you agree with the license?"), RESPONSE_YES) == RESPONSE_NO ) { + /* refused the license, don't set the option and bounce back */ + choices[i*4+2] = "off"; + goto options_loop; + } + } + else + { + /* NOTE TTimo: i18n? */ + char buf[BUFSIZ]; + snprintf(buf, BUFSIZ, "option-specific EULA not found for '%s', can't set option on\n", choices[i*4+1]); + dialog_msgbox(_("Error"), buf, 6, strlen(buf), 1); + choices[i*4+2] = "off"; + goto options_loop; + } + } + child = child->next; + } /* Mark this option for installation */ mark_option(info, nodes[i], "true", 0); Index: gtk_ui.c =================================================================== RCS file: /cvs/cvsroot/loki_setup/gtk_ui.c,v retrieving revision 1.68 diff -u -r1.68 gtk_ui.c --- gtk_ui.c 2002/04/03 08:10:24 1.68 +++ gtk_ui.c 2002/09/06 10:22:34 @@ -147,11 +147,11 @@ static GladeXML *setup_glade; static GladeXML *setup_glade_readme; -static GladeXML *setup_glade_license; +static GladeXML *setup_glade_license = NULL; static int cur_state; static install_info *cur_info; static int diskspace; -static int license_okay; +static int license_okay = 0; static GSList *radio_list = NULL; /* Group for the radio buttons */ /******** Local prototypes **********/ @@ -391,7 +391,7 @@ void setup_button_license_agree_slot( GtkWidget* widget, gpointer func_data ) { GtkWidget *license; - + license = glade_xml_get_widget(setup_glade_license, "license_dialog"); gtk_widget_hide(license); license_okay = 1; @@ -631,6 +631,64 @@ window = glade_xml_get_widget(setup_glade, "setup_window"); if ( GTK_TOGGLE_BUTTON(widget)->active ) { + /* does this option require a seperate EULA? */ + xmlNodePtr child; + child = data->node->childs; + while(child) + { + if (!strcmp(child->name, "eula")) + { + /* this option has some EULA nodes + * we need to prompt before this change can be validated / turned on + */ + const char* name = GetEULA_ForOption(cur_info, data->node); + if (name) + { + GtkWidget *license; + GtkWidget *license_widget; + + if (!setup_glade_license) + setup_glade_license = glade_xml_new(SETUP_GLADE, "license_dialog"); + glade_xml_signal_autoconnect(setup_glade_license); + license = glade_xml_get_widget(setup_glade_license, "license_dialog"); + license_widget = glade_xml_get_widget(setup_glade_license, "license_area"); + if ( license && license_widget ) { + GdkFont *font; + int start; + + font = gdk_font_load(LICENSE_FONT); + gtk_widget_hide(license); + load_file(GTK_TEXT(license_widget), font, name); + gtk_widget_show(license); + gtk_window_set_modal(GTK_WINDOW(license), TRUE); + + start = cur_state; /* happy hacking */ + license_okay = 0; + iterate_for_state(); + cur_state = start; + gtk_widget_hide(license); + if (!license_okay) + { + /* the user doesn't accept the option EULA, leave this option disabled */ + license_okay = 1; /* put things back in order regarding the product EULA */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE); + return; + } + license_okay = 1; + break; + } + } + else + { + log_warning("option-specific EULA not found, can't set option on\n"); + // EULA not found or not accepted + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE); + return; + } + } + child = child->next; + } + /* Mark this option for installation */ mark_option(cur_info, data->node, "true", 0); @@ -992,8 +1050,13 @@ if ( ! match_distro(info, wanted) ) { return; } + + /* Process only option and text nodes */ + if (strcmp(node->name, "option") && strcmp(node->name, "text")) { + return; + } - /* See if the user wants this option */ + /* See if the user wants this option */ if ( node->type == XML_TEXT_NODE ) { name = g_strdup(node->content); g_strstrip(name); Index: install.c =================================================================== RCS file: /cvs/cvsroot/loki_setup/install.c,v retrieving revision 1.92 diff -u -r1.92 install.c --- install.c 2002/04/03 08:10:24 1.92 +++ install.c 2002/09/06 10:22:37 @@ -278,21 +278,20 @@ return path; } -const char *GetProductEULA(install_info *info) +const char *GetEULA_ForOption(install_info *info, xmlNodePtr pOption) { const char *text; - static char name[BUFSIZ], matched_name[BUFSIZ]; xmlNodePtr node; + static char name[BUFSIZ], matched_name[BUFSIZ]; int found = 0; - - text = xmlGetProp(info->config->root, "eula"); + + text = xmlGetProp(pOption, "eula"); if (text) { strncpy(matched_name, text, BUFSIZ); found = 1; log_warning("The 'eula' attribute is deprecated, please use the 'eula' element from now on."); } - /* Look for EULA elements */ - node = info->config->root->childs; + node = pOption->childs; while(node) { if(! strcmp(node->name, "eula") ) { const char *prop = xmlGetProp(node, "lang"); @@ -316,7 +315,12 @@ return name; } } - return NULL; + return NULL; +} + +const char *GetProductEULA(install_info *info) +{ + return GetEULA_ForOption(info, info->config->root); } const char *GetProductREADME(install_info *info) Index: install.h =================================================================== RCS file: /cvs/cvsroot/loki_setup/install.h,v retrieving revision 1.58 diff -u -r1.58 install.h --- install.h 2002/04/03 08:10:24 1.58 +++ install.h 2002/09/06 10:22:38 @@ -200,6 +200,10 @@ extern int GetProductHasPromptBinaries(install_info *info); extern const char *GetProductSplash(install_info *info); extern const char *GetProductCDROMFile(install_info *info); +/*! general function to retrieve the name of the EULA document + * is used by GetProductEULA, and for option-specific EULA +*/ +extern const char *GetEULA_ForOption(install_info *info, xmlNodePtr pOption); extern const char *GetProductEULA(install_info *info); extern const char *GetProductREADME(install_info *info); extern const char *GetWebsiteText(install_info *info);