Author: jsmeix Date: Fri Mar 12 17:45:24 2010 New Revision: 61319 URL: http://svn.opensuse.org/viewcvs/yast?rev=61319&view=rev Log: Major cleanup regarding printer AutoYaST support. Now a non-destructive implementation of the "Reset" function in printer_auto.ycp (no longer a reset to an empty map which would result empty /etc/cups/cupsd.conf and /etc/cups/client.conf system config files) instead a reset to the real system defaults of those files. New PrinterAutoSequence and runAutoDialog implement the Overview and Printing via Network dialogs for usage within the AutoYaST module so that those dialogs are limited to do only the AutoYaST settings for printing with CUPS via network but no setup regarding local print queues because there is no AutoYaST support for local print queues, see https://bugzilla.novell.com/show_bug.cgi?id=582680#c33 Modified: trunk/printer/package/yast2-printer.changes trunk/printer/src/Printer.ycp trunk/printer/src/dialogs.ycp trunk/printer/src/helps.ycp trunk/printer/src/overview.ycp trunk/printer/src/printer.ycp trunk/printer/src/printer_auto.ycp trunk/printer/src/printingvianetwork.ycp trunk/printer/src/wizards.ycp Modified: trunk/printer/package/yast2-printer.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/package/yast2-printer.changes (original) +++ trunk/printer/package/yast2-printer.changes Fri Mar 12 17:45:24 2010 @@ -3,7 +3,7 @@ - printer_auto.ycp and printer_proposal.ycp cleanup, see https://bugzilla.novell.com/show_bug.cgi?id=582680#c33 - Curently this is untested work in progress! + Currently this is untested work in progress! When finished this will become version 2.19.6 ------------------------------------------------------------------- Modified: trunk/printer/src/Printer.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printer.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/Printer.ycp (original) +++ trunk/printer/src/Printer.ycp Fri Mar 12 17:45:24 2010 @@ -51,16 +51,28 @@ global boolean modified = false; /** - * Set by AutoYaST by calling in printer_auto.ycp the "SetModified" function. + * Set to 'true' by AutoYaST by calling in printer_auto.ycp the "SetModified" function. + * Read by AutoYaST by calling in printer_auto.ycp the "GetModified" function. * Preset to false which is the right default for AutoYast. */ global boolean printer_auto_modified = false; /** * Filled in by AutoYaST by calling in printer_auto.ycp the "Import" function. + * Reset to the empty map by AutoYaST by calling in printer_auto.ycp the "Reset" function. * Preset to the empty map which is the right default for AutoYast. */ -global map autoyast_printer_settings_import = $[]; +global map autoyast_printer_settings = $[]; + +/** + * Set to 'true' by AutoYaST by calling in printer_auto.ycp the "Change" function. + * Lets the Overview dialog disable the checkbox to show local queues + * which disables as a consequence in particular the [Delete] button. + * Lets the Printing via Network dialog disable the button to + * run the Connection Wizard (to set up a local queue for a network printer). + * Preset to false which is the right default for all dialogs. + */ +global boolean printer_auto_dialogs = false; /** */ @@ -279,10 +291,10 @@ /** * Queue filter string: - * Can be either "all" or "local" or "remote" depending on - * which kind of queues from the queues list (of queue maps) - * the user wants to see in the overview dialog. - * Preset to "all" which indicates that all queues are shown. + * Both boolean variables queue_filter_show_local and queue_filter_show_remote + * can be either 'true' or 'false' depending on which kind of queues + * from the queues list (of queue maps) the user wants to see in the overview dialog. + * Both are preset to 'true' which indicates that all queues are shown. */ global boolean queue_filter_show_local = true; global boolean queue_filter_show_remote = true; Modified: trunk/printer/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/dialogs.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/dialogs.ycp (original) +++ trunk/printer/src/dialogs.ycp Fri Mar 12 17:45:24 2010 @@ -141,5 +141,63 @@ return ret; } +map< string, map< string, any > > AutoDialog_widgets_handling = + $[ "OVERVIEW" : + $[ "widget" : `custom, + "custom_widget" : widgetOverview, + "init" : initOverview, + "handle" : handleOverview, + "help" : HELPS["AutoYaSToverview"]:"" + ], + "NETWORKPRINTING" : + $[ "widget" : `custom, + "custom_widget" : widgetNetworkPrinting, + "init" : initNetworkPrinting, + "handle" : handleNetworkPrinting, + "help" : HELPS["printing_via_network_dialog"]:"" + ] + ]; + +map< string, map< string, any > > AutoDialog_tabs_description = + $[ "overview" : + $[ "header" : _("AutoYaST Printer Configurations"), + "tree_item_label" : _("Printer Configurations"), + "caption" : _("AutoYaST Printer Configurations"), + "contents" : `VBox( "OVERVIEW" ), + "widget_names" : ["OVERVIEW"] + ], + "network" : + $[ "header" : _("AutoYaST Print via Network Settings"), + "tree_item_label" : _("Print via Network"), + "caption" : _("AutoYaST Print via Network Settings"), + "contents" : `VBox( "NETWORKPRINTING" ), + "widget_names" : ["NETWORKPRINTING"] + ] + ]; + +symbol runAutoDialog() +{ string caption = _("AutoYaST Settings for Printing with CUPS via Network"); + symbol ret = DialogTree::ShowAndRun + ( $[ "ids_order" : [ "overview", "network" ], + "initial_screen" : "overview", + "screens" : AutoDialog_tabs_description, + "widget_descr" : AutoDialog_widgets_handling, + // All the dialogs in "ids_order" are single (step) configuration dialogs + // and according to the new YaST style guide at + // http://en.opensuse.org/YaST/Style_Guide#Single_Configuration.2FOverview.2FEd... + // there is no longer a "abort" functionality which exits the whole module. + // Instead this button is now named "Cancel" and its functionality is + // to go back to the Overview dialog (i.e. what the "back" button would do) + // because it reads "Cancel - Closes the window and returns to the overview." + // Therefore the button with the "abort" functionality is not shown at all + // and the button with the "back" functionality is named "Cancel". + "abort_button" : nil, + "back_button" : Label::CancelButton(), + "next_button" : Label::OKButton() + ] + ); + return ret; +} + /* EOF */ } Modified: trunk/printer/src/helps.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/helps.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/helps.ycp (original) +++ trunk/printer/src/helps.ycp Fri Mar 12 17:45:24 2010 @@ -106,6 +106,14 @@ of available remote queues. </p>"), +"AutoYaSToverview" : +// AutoYaST Overview dialog help 1/1: +_("<p> +<b><big>AutoYaST Print Queue Overview</big></b><br> +AutoYaST supports only settings for printing with CUPS via network.<br> +There is no AutoYaST support to set up local print queues. +</p>"), + "basic_add_dialog" : // BasicAddDialog help 1/5: _("<p> Modified: trunk/printer/src/overview.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/overview.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/overview.ycp (original) +++ trunk/printer/src/overview.ycp Fri Mar 12 17:45:24 2010 @@ -222,6 +222,16 @@ } } } + if( Printer::printer_auto_dialogs ) + { // When the Overview dialog is called by AutoYaST + // (by calling in printer_auto.ycp the "Change" function) + // it does not make sense to let the user show local queues: + UI::ChangeWidget( `local_content_checkbox, `Enabled, false ); + // Disable also the [Add] Button. + // It stays disabled as long as the dialog runs because + // it is nowhere again re-enabled below. + UI::ChangeWidget( `add, `Enabled, false ); + } UI::ChangeWidget( `local_content_checkbox, `Value, local_content_selected ); UI::ChangeWidget( `remote_content_checkbox, `Value, remote_content_selected ); UI::ChangeWidget( `overview_table, `Items, @@ -477,7 +487,10 @@ // Body of a Popup::AnyMessage when no queue was selected from the list: _("Select an entry.") ); - return nil; + // When testpage printing failed there might be whatever reason + // so that a refresh of the overview content is needed to be on the safe side. + // Re-run the OverviewDialog (with re-created queue status) via the sequencer: + return `refresh; } if( "yes" == Printer::queues[selected_queue_index,"rejecting"]:"no" ) { Popup::AnyMessage( // Header of a Popup::AnyMessage when the queue rejects print jobs: @@ -485,7 +498,10 @@ // Body of a Popup::AnyMessage when the queue rejects print jobs: _("The testpage cannot be printed because print jobs are rejected.") ); - return nil; + // When testpage printing failed there might be whatever reason + // so that a refresh of the overview content is needed to be on the safe side. + // Re-run the OverviewDialog (with re-created queue status) via the sequencer: + return `refresh; } if( "yes" == Printer::queues[selected_queue_index,"disabled"]:"no" ) { Popup::AnyMessage( // Header of a Popup::AnyMessage when printing is disabled for the queue: @@ -493,7 +509,10 @@ // Body of a Popup::AnyMessage when printing is disabled for the queue: _("The testpage cannot be printed because printout is disabled.") ); - return nil; + // When testpage printing failed there might be whatever reason + // so that a refresh of the overview content is needed to be on the safe side. + // Re-run the OverviewDialog (with re-created queue status) via the sequencer: + return `refresh; } if( "local" == Printer::queues[selected_queue_index,"config"]:"remote" ) { // When it is a local queue, remember it as the currently selected queue @@ -586,7 +605,6 @@ ), Printerlib::result["stderr"]:"" ); - // When submitting the testpage to the queue failed (also for non-local queues) // there might be whatever reason (e.g. a remote queue might have been deleted in the meantime) // so that a refresh of the overview content is needed to be on the safe side. Modified: trunk/printer/src/printer.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printer.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/printer.ycp (original) +++ trunk/printer/src/printer.ycp Fri Mar 12 17:45:24 2010 @@ -79,7 +79,7 @@ /* main ui function */ any ret = nil; -if(propose) ret = PrinterAutoSequence(); +if(propose) ret = PrinterProposalSequence(); else ret = CommandLine::Run(cmdline_description); y2debug("ret=%1", ret); Modified: trunk/printer/src/printer_auto.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printer_auto.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/printer_auto.ycp (original) +++ trunk/printer/src/printer_auto.ycp Fri Mar 12 17:45:24 2010 @@ -82,11 +82,39 @@ /* Create a summary string */ if (func == "Summary") -{ ret = _("AutoYaST printer client settings."); +{ ret = _("AutoYaST settings for printing with CUPS via network. There is no AutoYaST support for local print queues."); } -/* Reset configuration to an empty map */ +/* + * Reset the AutoYaST related printer settings to system defaults + * which means /etc/cups/cupsd.conf is overwritten by /etc/cups/cupsd.conf.default + * (/etc/cups/cupsd.conf.default is provided by our cups RPM for such cases) + * and all entries in /etc/cups/client.conf are commented out. + * Then read the content form those system config files + * (exactly the same way as it is done in the Export function) + * and store it in the Printer::autoyast_printer_settings map + * (exactly the same is done in the Import function) + * so that a subsequent call of the Export function by AutoYaST + * would export the system default values to AutoYaST + * and a subsequent call of the Write function by AutoYaST would + * write the same system default values again to /etc/cups/client.conf + * and to /etc/cups/cupsd.conf (regardless that their content + * is already reset to system defaults). + * Accordingly return the Printer::autoyast_printer_settings map + * to AutoYaST so that also the printer related settings inside AutoYaSTare + * are reset to system defaults so that a subsequent call of the Import + * function by AutoYaST would provide the correct system default values. + */ else if (func == "Reset") -{ ret = $[]; +{ // It is o.k. to ignore when the next two commands fail + // because then /etc/cups/cupsd.conf and/or /etc/cups/client.conf + // were (hopefully) not changed at all which is the right fallback + // so that there is no change of system config files in case of errors. + Printerlib::ExecuteBashCommand( "cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf" ); + Printerlib::ExecuteBashCommand( "sed -i -e '/^[^#]/s/^/#/' /etc/cups/client.conf" ); + Printer::autoyast_printer_settings = $[ "server_settings" : (map)SCR::Read(.cups.server), + "cups_remote_server" : (map)SCR::Read(.cups.client) + ]; + ret = Printer::autoyast_printer_settings; } /* Called appropriately by the AutoYaST framework */ else if (func == "SetModified") @@ -105,8 +133,17 @@ boolean progress_orig = Progress::set( false ); Printer::Read(); Progress::set( progress_orig ); - // PrinterAutoSequence in wizards.ycp runs only the MainSequence - // which are all the usual dialogs (starting with the "Overview") + // Let the Overview dialog disable the checkbox to show local queues + // which disables as a consequence in particular the [Delete] button. + // Lets the Printing via Network dialog disable the button to + // run the Connection Wizard (to set up a local queue for a network printer). + Printer::printer_auto_dialogs = true; + // Let the Overview dialog only show remote queues: + Printer::queue_filter_show_remote = true; + Printer::queue_filter_show_local = false; + // PrinterAutoSequence in wizards.ycp runs only the AutoSequence + // which is only the "Printing via Network" and the "Overview" dialog + // (starting with the "Printing via Network" dialog) // but without running before ReadDialog (which calls only Printer::Read) // and running afterwards WriteDialog (which calls only Printer::Write) // which is the reason that Printer::Read is called explicitely above. @@ -117,7 +154,7 @@ * and store it to be used later when the Write function is called. */ else if (func == "Import") -{ Printer::autoyast_printer_settings_import = param; +{ Printer::autoyast_printer_settings = param; ret = true; } /* @@ -162,7 +199,8 @@ /* * Write the AutoYaST related printer settings to the system * according to the Printer::autoyast_printer_settings_import map - * which was stored by a previous call of the Import function by AutoYaST. + * which was stored by a previous call of the Import function by AutoYaST + * or reset to an empty map by a previous call of the Reset function. * The map contains the cupsd.conf entries in a "server_settings" sub-map * and the client.conf entries in a "cups_remote_server" sub-map. * The cupsd.conf and client.conf entries are written by calling @@ -171,9 +209,9 @@ * where empty sub-maps would result empty system config files. */ else if (func == "Write") -{ y2milestone("Writing to system '%1'", Printer::autoyast_printer_settings_import); - Printerlib::WriteClientSettings( Printer::autoyast_printer_settings_import["cups_remote_server"]:$[] ); - Printerlib::WriteCupsSettings( Printer::autoyast_printer_settings_import["server_settings"]:$[] ); +{ y2milestone("Writing to system '%1'", Printer::autoyast_printer_settings); + Printerlib::WriteClientSettings( Printer::autoyast_printer_settings["cups_remote_server"]:$[] ); + Printerlib::WriteCupsSettings( Printer::autoyast_printer_settings["server_settings"]:$[] ); return true; } /* Unknown function */ Modified: trunk/printer/src/printingvianetwork.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printingvianetwork.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/printingvianetwork.ycp (original) +++ trunk/printer/src/printingvianetwork.ycp Fri Mar 12 17:45:24 2010 @@ -802,7 +802,8 @@ initial_client_conf_input_value = ""; UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); // Only the "Connection Wizard" button is enabled by default - // and disabled in case of "client_only", see "Client only settings" below: + // and disabled in case of "client_only" (see "Client only settings" below) + // and also disabled in case of Printer::printer_auto_dialogs. UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); // Make the actual Browsing settings: // If "none" is present as a BrowseAllow value it is actually no Browsing config. @@ -937,6 +938,13 @@ // Fill in the client-only values of the current settings in the system // regardless if it is actually a client-only config or not (see above): UI::ChangeWidget( `id(`client_conf_input), `Value, Printerlib::client_conf_server_name ); + if( Printer::printer_auto_dialogs ) + { // When the Overview dialog is called by AutoYaST + // (by calling in printer_auto.ycp the "Change" function) + // it does not make sense to let the user set up a local queue + // for a network printer via the "Connection Wizard": + UI::ChangeWidget( `id(`connection_wizard), `Enabled, false ); + } initial_client_conf_input_value = Printerlib::client_conf_server_name; y2milestone( "leaving initNetworkPrinting with\ninitial_browsing = '%1'\ninitial_browse_allow = '%2'\ninitial_browse_allow_input_value = '%3'\ninitial_browse_poll = '%4'\ninitial_browse_poll_input_value = '%5'\ninitial_client_only = '%6'\ninitial_client_conf_input_value = '%7'", initial_browsing, initial_browse_allow, initial_browse_allow_input_value, initial_browse_poll, initial_browse_poll_input_value, initial_client_only, initial_client_conf_input_value ); } @@ -1000,10 +1008,12 @@ } UI::ChangeWidget( `id(`client_conf_input), `Enabled, false ); UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); - if( ! Printerlib::client_only ) + if( ! Printerlib::client_only && ! Printer::printer_auto_dialogs ) { // The "Connection Wizard" button is enabled by default // and disabled if currently a "client_only" config is active. - // In this case it is never again enabled as long as the dialog runs, see above: + // In this case it is never again enabled as long as the dialog runs, see above. + // It is also disabled in case of Printer::printer_auto_dialogs + // and then it must stay disabled as long as the dialog runs. UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); } } Modified: trunk/printer/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/wizards.ycp?rev=61319&r1=61318&r2=61319&view=diff ============================================================================== --- trunk/printer/src/wizards.ycp (original) +++ trunk/printer/src/wizards.ycp Fri Mar 12 17:45:24 2010 @@ -113,7 +113,7 @@ "printing_via_network_connection_wizard" : $[ `abort : `abort, `back : "overview", `next : "add" - ], + ] ]; return Sequencer::Run( aliases, sequence ); } @@ -146,7 +146,36 @@ } /** - * Whole configuration of printer but without reading and writing. + * Workflow of the printer configuration for AutoYaST + * @return sequence result + */ +any AutoSequence() +{ map aliases = $[ "overview" : ``( runAutoDialog() ) + ]; + map sequence = $[ "ws_start" : "overview", + "overview": $[ `abort : `abort, + `back : "overview", + `next : `next, + `add : "overview", + `modify : "overview", + `delete : "overview", + `refresh : "overview", + `printing_via_network_back : "overview", + `printing_via_network_next : "overview", + `printing_via_network_connection_wizard : "overview", + `sharing_back : "overview", + `sharing_next : "overview", + `policies_back : "overview", + `policies_next : "overview", + `autoconfig_back : "overview", + `autoconfig_next : "overview" + ] + ]; + return Sequencer::Run( aliases, sequence ); +} + +/** + * Only "Printing via Network" configuration of printer. * For use with autoinstallation. * @return sequence result */ @@ -162,6 +191,28 @@ Label::BackButton(), Label::NextButton() ); + any ret = AutoSequence(); + UI::CloseDialog(); + return ret; +} + +/** + * Whole configuration of printer but without reading and writing. + * For use with proposal at the end of the system installation. + * @return sequence result + */ +any PrinterProposalSequence() +{ /* Initialization dialog caption */ + string caption = _("Printer Configuration"); + /* Initialization dialog contents */ + term contents = `Label( _("Initializing...") ); + Wizard::CreateDialog(); + Wizard::SetContentsButtons( caption, + contents, + "", + Label::BackButton(), + Label::NextButton() + ); any ret = MainSequence(); UI::CloseDialog(); return ret; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org