Author: jsmeix Date: Thu Sep 4 18:26:20 2008 New Revision: 50701 URL: http://svn.opensuse.org/viewcvs/yast?rev=50701&view=rev Log: - The 'Printing via Network' dialog should now work. - Added user confirmation before a cupsd start/restart/stop. - Implemented [Refresh] button for the 'Overview' dialog. - 2.7.10 Modified: trunk/printer/VERSION trunk/printer/package/yast2-printer.changes trunk/printer/src/Printerlib.ycp trunk/printer/src/overview.ycp trunk/printer/src/printingvianetwork.ycp trunk/printer/src/wizards.ycp trunk/printer/tools/cups_client_only Modified: trunk/printer/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/VERSION (original) +++ trunk/printer/VERSION Thu Sep 4 18:26:20 2008 @@ -1 +1 @@ -2.17.9 +2.17.10 Modified: trunk/printer/package/yast2-printer.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/package/yast2-printer.changes (original) +++ trunk/printer/package/yast2-printer.changes Thu Sep 4 18:26:20 2008 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Thu Sep 4 18:20:06 CEST 2008 - jsmeix@suse.de + +- The 'Printing via Network' dialog should now work. +- Added user confirmation before a cupsd start/restart/stop. +- Implemented [Refresh] button for the 'Overview' dialog. +- 2.7.10 + +------------------------------------------------------------------- Wed Sep 3 17:05:45 CEST 2008 - jsmeix@suse.de - Implemented cupsd status/start/restart/stop functionality. @@ -7,7 +15,7 @@ ------------------------------------------------------------------- Tue Sep 2 16:31:57 CEST 2008 - jsmeix@suse.de -- The 'Printing via Network'dialog writes the Browsing values +- The 'Printing via Network' dialog writes the Browsing values to the system (but client-only is not yet implemented). - 2.17.8 Modified: trunk/printer/src/Printerlib.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/src/Printerlib.ycp (original) +++ trunk/printer/src/Printerlib.ycp Thu Sep 4 18:26:20 2008 @@ -5,7 +5,6 @@ textdomain "printer"; import "Popup"; -import "Report"; import "Service"; // Fortunately the tools are for all architectures always @@ -63,71 +62,131 @@ { // Do not start an already running (i.e. accessible) cupsd: return true; } - if( ! Service::Start( "cups" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to start the CUPS daemon.") - ); - return false; + // Enforce user confirmation before a new service is started + // to be on the safe side that the user knows about it: + if( ! Popup::YesNoHeadline( // PopupYesNoHeadline headline: + _("Start local running CUPS daemon"), + // PopupYesNoHeadline body: + _("A local running CUPS daemon is needed.") + ) + ) + { return false; } - else - { Popup::TimedMessage( _("Started the CUPS daemon.\nWaiting one minute so that it is ready to operate..."), - 60 + if( ! Service::Start( "cups" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to start the CUPS daemon"), + Service::Error() ); + return false; } + // Wait one minute for a new started cupsd is necessary because + // when a client-only config is switched to a "get Browsing info" config + // the BrowseInterval in cupsd.conf on remote CUPS servers is by default 30 seconds + // so that the local cupsd should listen at least 31 seconds to get Browsing info + // before e.g. the Overview dialog can be shown with the right current queues. + // Additionally during first start after system installation the cupsd parses + // all the (usually thousands) of installed PPDs to generate + // the list of available drivers (what "lpinfo -l -m" shows). + Popup::TimedMessage( _("Started the CUPS daemon.\nWaiting one minute so that it is ready to operate..."), + 60 + ); local_cupsd_accessible = ExecuteBashCommand( local_cupsd_accessible_commandline ); if( ! local_cupsd_accessible ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("No local running CUPS daemon is accessible.") - ); + { Popup::Error( // Popup::Error message: + _("No local running CUPS daemon is accessible.") + ); return false; } + if( ! Service::Enable( "cups" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to enable starting of the CUPS daemon during system boot"), + Service::Error() + ); + // This is not a fatal error, therefore return "successfully" nevertheless. + } return true; } // Restart cupsd: if( "restart" == new_status ) - { if( ! Service::Restart( "cups" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to restart the CUPS daemon.") - ); - return false; - } - else - { Popup::TimedMessage( _("Restarted the CUPS daemon.\nWaiting one minute so that it is ready to operate..."), - 60 + { // Enforce user confirmation before the cupsd is restarted + // to be on the safe side regarding complaints in an enterprise environment + // because a restart disrupts all currently actively printing jobs: + if( ! Popup::YesNoHeadline( // PopupYesNoHeadline headline: + _("Restart local running CUPS daemon"), + // PopupYesNoHeadline body: + _("A restart disrupts all currently actively printing jobs.") + ) + ) + { return false; + } + if( ! Service::Restart( "cups" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to restart the CUPS daemon"), + Service::Error() ); + return false; } + // Wait 40 seconds for a restarted cupsd is necessary because + // when a "no Browsing info" config is switched to a "get Browsing info" config + // the BrowseInterval in cupsd.conf on remote CUPS servers is by default 30 seconds + // so that the local cupsd should listen at least 31 seconds to get Browsing info + // before e.g. the Overview dialog can be shown with the right current queues. + Popup::TimedMessage( _("Restarted the CUPS daemon.\nWaiting 40 seconds so that it is ready to operate..."), + 40 + ); local_cupsd_accessible = ExecuteBashCommand( local_cupsd_accessible_commandline ); if( ! local_cupsd_accessible ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("No local running CUPS daemon is accessible.") - ); + { Popup::Error( // Popup::Error message: + _("No local running CUPS daemon is accessible.") + ); return false; } + // To be on the safe side, ask the user to enable the cupsd + // to be started during boot if it is not yet enabled: + if( ! Service::Enabled( "cups" ) ) + { if( Popup::YesNoHeadline( // PopupYesNoHeadline headline: + _("Enable starting of the CUPS daemon during system boot"), + // PopupYesNoHeadline body: + _("Currently the CUPS daemon is not started during system boot.") + ) + ) + { if( ! Service::Enable( "cups" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to enable starting of the CUPS daemon during system boot"), + Service::Error() + ); + // This is not a fatal error, therefore return "successfully" nevertheless. + } + } + } return true; } // Stop cupsd: if( "stop" == new_status ) - { // To be on the safe side try to stop the cupsd regardless if it is accessible or not - // and ignore possible errors from Service::Stop when it is already stopped + { // Enforce user confirmation before the cupsd is stopped + // to be on the safe side regarding complaints in an enterprise environment + // because a stop disrupts all currently actively printing jobs: + if( ! Popup::YesNoHeadline( // PopupYesNoHeadline headline: + _("Stop local running CUPS daemon"), + // PopupYesNoHeadline body: + _("A stop disrupts all currently actively printing jobs.") + ) + ) + { return false; + } + // To be on the safe side try to stop and disable the cupsd + // regardless if it is accessible or not and/or disabled or not + // and ignore possible errors from Service::Stop and Service::Disable // (the local_cupsd_accessible test below should be sufficient): Service::Stop( "cups" ); + Service::Disable( "cups" ); // Wait one second to make sure that cupsd has really finished (it may do some cleanup): sleep( 1000 ); local_cupsd_accessible = ExecuteBashCommand( local_cupsd_accessible_commandline ); if( local_cupsd_accessible ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("A local running CUPS daemon is still accessible.") - ); + { Popup::Error( // Popup::Error message: + _("A local running CUPS daemon is still accessible.") + ); return false; } return true; @@ -175,22 +234,22 @@ // or when the "Browsing" entry is deactivated by a leading '#' character. // Therefore browsing_on is only false if "Browsing Off" or "Browsing No" // is explicitely set in /etc/cups/cupsd.conf. -global boolean browsing_on = true; +global boolean cupsd_conf_browsing_on = true; global boolean DetermineBrowsing() { // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf: if( ExecuteBashCommand( yast_bin_dir + "modify_cupsd_conf Browsing" ) ) { string browsing = tolower( result["stdout"]:"On" ); if( "off" == browsing || "no" == browsing ) - { browsing_on = false; + { cupsd_conf_browsing_on = false; } else - { browsing_on = true; + { cupsd_conf_browsing_on = true; } } else { // Use fallback value when the command above failed: - browsing_on = true; + cupsd_conf_browsing_on = true; return false; } return true; Modified: trunk/printer/src/overview.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/overview.ycp?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/src/overview.ycp (original) +++ trunk/printer/src/overview.ycp Thu Sep 4 18:26:20 2008 @@ -75,6 +75,7 @@ `PushButton (`id (`edit), _("Configure")), `PushButton (`id (`delete), Label::DeleteButton ()), `HStretch (), + `PushButton (`id (`refresh), _("Refresh list")), `PushButton (`id (`test), _("Print test page")) ) ); @@ -94,11 +95,7 @@ } // Determine whether or not a local cupsd is accessible: if( local_cupsd_required && ! Printerlib::GetAndSetCupsdStatus( "" ) ) - { Popup::ErrorDetails( // Popup::ErrorDetails header: - _("Start local running CUPS daemon"), - // Popup::ErrorDetails body: - _("A local running CUPS daemon is needed for your setup.") - ); + { // Printerlib::GetAndSetCupsdStatus already shows a confirmation popup: Printerlib::GetAndSetCupsdStatus( "start" ); } UI::ChangeWidget(`local_content_checkbox, `Value, local_content_selected); @@ -124,6 +121,23 @@ integer selected_queue_index = (integer)UI::QueryWidget( `id(`overview_table), `CurrentItem ); + if( `refresh == event["ID"]:nil && "Activated" == event["EventReason"]:"" ) + { // The refresh functionality is useful after switching the Browsing mode. + // For example when a client-only config is switched to a "get Browsing info" config + // the BrowseInterval in cupsd.conf on remote CUPS servers is by default 30 seconds + // so that it takes by default up to 31 seconds before the Overview dialog can show + // all remote queues or any time longer depending on the BrowseInterval setting + // on the remote CUPS servers which necessitates an explicite [Refresh] button. + // Or the other way round when a "Get browsing info" config with a local cupsd + // was switched to a "No browsing info" config with a local running cupsd. + // The default BrowseTimeout value for the local cupsd is 5 minutes. + // Therefore it takes by default 5 minutes until printer information + // that was previously received by Browsing is removed (via timeout) + // from the local cupsd's list so that such kind of outdated remote queues + // are no longer shown in the Overview dialog. + UI::ChangeWidget(`overview_table, `Items, Printer::QueueItems( Printer::queue_filter_show_local, Printer::queue_filter_show_remote )); + } + if (event["EventReason"]:"" == "Activated" && event["ID"]:nil == `delete){ string queue_name = Printer::queues[selected_queue_index,"name"]:""; if( "" == queue_name ) @@ -247,15 +261,9 @@ } } if( ! Printerlib::GetAndSetCupsdStatus( "" ) ) - { // No local running cupsd is accessible: - if( ! Popup::YesNoHeadline( // PopupYesNoHeadline headline: - _("Start local running CUPS daemon"), - // PopupYesNoHeadline body: - _("A local running CUPS daemon is needed to add a print queue.") - ) - ) - return nil; - // Do a restart to be safe: + { // No local running cupsd is accessible. + // Do a restart to be safe. + // Printerlib::GetAndSetCupsdStatus already shows a confirmation popup: if( ! Printerlib::GetAndSetCupsdStatus( "restart" ) ) { return nil; } Modified: trunk/printer/src/printingvianetwork.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printingvianetwork.ycp?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/src/printingvianetwork.ycp (original) +++ trunk/printer/src/printingvianetwork.ycp Thu Sep 4 18:26:20 2008 @@ -36,7 +36,6 @@ import "Printer"; import "Printerlib"; import "Popup"; -import "Report"; import "Service"; include "printer/helps.ycp"; @@ -50,14 +49,14 @@ `VBox ( `Left ( `RadioButton - ( `id(`cupsd_conf_browsing_off_radio_button), + ( `id(`browsing_off_radio_button), `opt(`notify), _("&Do not Receive Printer Information from Remote CUPS servers") ) ), `Left ( `RadioButton - ( `id(`cupsd_conf_browsing_on_radio_button), + ( `id(`browsing_on_radio_button), `opt(`notify), _("Receive Printer &Information from Remote CUPS servers") ) @@ -67,13 +66,13 @@ `VBox ( `Left ( `Label - ( `id(`cupsd_conf_browse_allow_label), + ( `id(`browse_allow_label), _("Accept Information from the Following Servers") ) ), `Left ( `ComboBox - ( `id(`cupsd_conf_browse_allow_combo_box), + ( `id(`browse_allow_combo_box), `opt(`notify), _("Usual &General Setting"), [ `item( `id(`browse_allow_all), "all hosts" ), @@ -84,13 +83,13 @@ ), `Left ( `TextEntry - ( `id(`cupsd_conf_browse_allow_input), + ( `id(`browse_allow_input), _("Optional Specific IP Addresses or &Network/Netmask") ) ), `Left ( `Label - ( `id(`cupsd_conf_browse_allow_input_label), + ( `id(`browse_allow_input_label), _("(each nnn.nnn.nnn.nnn or nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm separated by one space)") ) ) @@ -138,41 +137,27 @@ `VStretch() ); -/* - ), - `VStretch(), - `Right - ( `PushButton - ( `id(`apply), - _("Apply") - ) - ) - ); -*/ - boolean something_has_changed = false; -boolean initial_cupsd_conf_browsing_off_radio_button = false; -boolean initial_cupsd_conf_browsing_on_radio_button = false; -any initial_cupsd_conf_browse_allow_combo_box_value = nil; -string initial_cupsd_conf_browse_allow_input_value = ""; -boolean initial_client_only_radio_button = false; -string initial_client_conf_server_name_input_value = ""; +any initial_radio_button = nil; +any initial_browse_allow = nil; +string initial_browse_allow_input_value = ""; +string initial_server_name_input_value = ""; boolean ApplyNetworkPrintingSettings() { something_has_changed = false; // Get the actual settings and values from the dialog: any current_radio_button = UI::QueryWidget( `id(`browsing_or_client_only_check_boxes), `CurrentButton ); - any current_browse_allow = UI::QueryWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value ); - string current_browse_allow_input_value = (string)UI::QueryWidget( `id(`cupsd_conf_browse_allow_input), `Value ); + any current_browse_allow = UI::QueryWidget( `id(`browse_allow_combo_box), `Value ); + string current_browse_allow_input_value = (string)UI::QueryWidget( `id(`browse_allow_input), `Value ); string current_server_name_input_value = (string)UI::QueryWidget( `id(`client_conf_server_name_input), `Value ); y2milestone( "ApplyNetworkPrintingSettings with\ncurrent_radio_button = '%1'\ncurrent_browse_allow = '%2'\ncurrent_browse_allow_input_value = '%3'\ncurrent_server_name_input_value = '%4'", current_radio_button, current_browse_allow, current_browse_allow_input_value, current_server_name_input_value ); // Do not accept Browsing information: - if( `cupsd_conf_browsing_off_radio_button == current_radio_button ) - { if( initial_cupsd_conf_browsing_off_radio_button ) + if( `browsing_off_radio_button == current_radio_button ) + { if( `browsing_off_radio_button == initial_radio_button ) { // Nothing has changed: return true; } - if( initial_cupsd_conf_browsing_on_radio_button ) + if( `browsing_on_radio_button == initial_radio_button ) { // It was initially a "Get browsing info" config, // but now the user has activated the "No browsing info" radio button: something_has_changed = true; @@ -181,11 +166,10 @@ // which might be needed by the "Share Printers" dialog. // Instead set only "BrowseAllow none" in cupsd.conf: if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf BrowseAllow none" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to set 'BrowseAllow none' in /etc/cups/cupsd.conf") - ); + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to set 'BrowseAllow none' in /etc/cups/cupsd.conf"), + Printerlib::result["stderr"]:"" + ); return false; } // If a local cupsd is accessible, restart it, otherwise start it: @@ -193,6 +177,20 @@ { if( ! Printerlib::GetAndSetCupsdStatus( "restart" ) ) { return false; } + // A "Get browsing info" config with a local cupsd was switched + // to a "No browsing info" config with a local running cupsd. + // The Printerlib::GetAndSetCupsdStatus("restart") function + // already waits 40 seconds but the default BrowseTimeout value + // for the local cupsd is 5 minutes. + // Therefore it takes by default 5 minutes until printer information + // that was previously received by Browsing is removed (via timeout) + // from the local cupsd's list. + // I assume most users do not like to wait 5 minutes which is no problem + // because they can just click the [OK] button to continue but then + // they are at least informend why there may be still remote queues: + Popup::TimedMessage( _("When switching from 'receive information' to 'do not receive information'\nit takes usually 5 minutes until already received information faded away..."), + 300 + ); } else { if( ! Printerlib::GetAndSetCupsdStatus( "start" ) ) @@ -201,14 +199,14 @@ } return true; } - if( initial_client_only_radio_button ) + if( `client_only_radio_button == initial_radio_button ) { // Note that initial_client_only_radio_button is only true for a real client-only config // but not when the server name value for client-only is "localhost" or "127.0.0.1", // see Printerlib::DetermineClientOnly() and the initNetworkPrinting function below. // If it is actually a client-only config, // the user may have only activated the "No browsing info" radio button // but left the server name value for client-only unchanged: - if( current_server_name_input_value != initial_client_conf_server_name_input_value ) + if( current_server_name_input_value != initial_server_name_input_value ) { something_has_changed = true; // The user has changed the server name value for client-only // and afterwards he activated the "No browsing info" radio button. @@ -219,12 +217,11 @@ && "none" != server_name ) { if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only " + server_name ) ) - { Report::Error( // Message of a Report::Error - // where %1 will be replaced by the server name. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - sformat( _("Failed to set 'ServerName %1' in /etc/cups/client.conf"), server_name ) - ); + { Popup::ErrorDetails( // Popup::ErrorDetails header + // where %1 will be replaced by the server name. + sformat( _("Failed to set 'ServerName %1' in /etc/cups/client.conf"), server_name ), + Printerlib::result["stderr"]:"" + ); return false; } } @@ -233,16 +230,16 @@ // and afterwards the "No browsing info" radio button was activated. // This should disable the client-only setup but not start the local cupsd: if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only none" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to remove the 'ServerName' entry in /etc/cups/client.conf") - ); + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to remove the 'ServerName' entry in /etc/cups/client.conf"), + Printerlib::result["stderr"]:"" + ); return false; } } } } + // Exit successfully by default and as fallback: // The above change to the client-only setup was successful or // the user has not changed the server name value for client-only // and afterwards he activated the "No browsing info" radio button. @@ -250,24 +247,44 @@ return true; } // Accept Browsing information: - if( `cupsd_conf_browsing_on_radio_button == current_radio_button ) - { if( initial_cupsd_conf_browsing_off_radio_button ) + if( `browsing_on_radio_button == current_radio_button ) + { if( `browsing_off_radio_button == initial_radio_button ) { // It was initially a "No browsing info" config, // but now the user has activated the "Get browsing info" radio button: something_has_changed = true; } - if( initial_cupsd_conf_browsing_on_radio_button ) + if( `browsing_on_radio_button == initial_radio_button ) { // It was initially a "Get browsing info" config, // but now the user may have changed from which hosts browsing info is accepted: - if( current_browse_allow != initial_cupsd_conf_browse_allow_combo_box_value - || current_browse_allow_input_value != initial_cupsd_conf_browse_allow_input_value + if( current_browse_allow != initial_browse_allow + || current_browse_allow_input_value != initial_browse_allow_input_value ) { something_has_changed = true; } } - if( initial_client_only_radio_button ) + if( `client_only_radio_button == initial_radio_button ) { // It was initially a client-only config, - // but now the user has activated the "Get browsing info" radio button: + // but now the user has activated the "Get browsing info" radio button. + // "Get browsing info" means "no longer client-only" regardless + // if the browse_allow_value string is effectively empty or it contains "none" + // so that the client-only config is to be disabled in any case: + if( ! Popup::YesNoHeadline( // PopupYesNoHeadline headline + // where %1 will be replaced by the server name: + sformat( _("Disable remote CUPS server '%1'"), Printerlib::client_conf_server_name ), + // PopupYesNoHeadline body: + _("A remote CUPS server setting conflicts with receiving printer information.") + ) + ) + { return false; + } + // Remove the 'ServerName' entry in /etc/cups/client.conf: + if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only none" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to remove the 'ServerName' entry in /etc/cups/client.conf"), + Printerlib::result["stderr"]:"" + ); + return false; + } something_has_changed = true; } if( ! something_has_changed ) @@ -287,16 +304,16 @@ if( `browse_allow_local == current_browse_allow ) { browse_allow_value = browse_allow_value + " @LOCAL"; } - if( "" == filterchars( browse_allow_value, " " ) + if( "" == filterchars( browse_allow_value, Printer::alnum_chars ) || issubstring( browse_allow_value, "none" ) ) - { // The browse_allow_value string is empty or it contains "none". + { // The browse_allow_value string is effectively empty or it contains "none". // (The issubstring match is o.k. because only IP-addresses are supported // so that even for a hostname "none.nowhere" the IP-address would not match.) // This case happens when browse_allow_specific is selected in the combo box - // but no address or only "none" was entered for cupsd_conf_browse_allow_input. + // but no address or only "none" was entered for browse_allow_input. // This case has the same meaning as a "No browsing info" config. - if( initial_cupsd_conf_browsing_off_radio_button ) + if( `browsing_off_radio_button == initial_radio_button ) { // It was initially a "No browsing info" config, // and now the user has activated the "Get browsing info" radio button // but with effectively an empty or "none" browse_allow_value string @@ -311,15 +328,14 @@ // because this is the most secure setting. browse_allow_value = "none"; } - if( "none" != browse_allow_value ) + if( browse_allow_value != "none" ) { // Only a not-"none" browse_allow_value requires "Browsing On" in cupsd.conf. // Otherwise leave the "Browsing" entry in cupsd.conf unchanged. if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf Browsing On" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to set 'Browsing On' in /etc/cups/cupsd.conf") - ); + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to set 'Browsing On' in /etc/cups/cupsd.conf"), + Printerlib::result["stderr"]:"" + ); return false; } } @@ -329,14 +345,13 @@ + "'" ) ) - { Report::Error( // Message of a Report::Error - // where %1 will be replaced by the values for BrowseAllow. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - sformat( _("Failed to set BrowseAllow value(s) '%1' in /etc/cups/cupsd.conf"), - browse_allow_value - ) - ); + { Popup::ErrorDetails( // Popup::ErrorDetails header + // where %1 will be replaced by the values for BrowseAllow. + sformat( _("Failed to set BrowseAllow value(s) '%1' in /etc/cups/cupsd.conf"), + browse_allow_value + ), + Printerlib::result["stderr"]:"" + ); return false; } // If a local cupsd is accessible, restart it, otherwise start it if needed: @@ -360,8 +375,81 @@ } // Client-only: if( `client_only_radio_button == current_radio_button ) - { // Exit successfully by default and as fallback: - return true; + { string server_name = deletechars( tolower( current_server_name_input_value ), " " ); + if( `browsing_off_radio_button == initial_radio_button + || `browsing_on_radio_button == initial_radio_button + ) + { // It was initially a "No browsing info" config or a "Get browsing info" config, + // but now the user has activated the "client-only" radio button. + // If the server name is not "localhost" and not "127.0.0.1", + // a real client-only config is to be set up and then + // a possibly running local cupsd will be stopped. + something_has_changed = true; + if( server_name != "localhost" + && substring( server_name, 0, 5 ) != "127.0" + ) + { if( Printerlib::GetAndSetCupsdStatus( "" ) ) + { if( ! Printerlib::GetAndSetCupsdStatus( "stop" ) ) + { return false; + } + } + } + } + if( `client_only_radio_button == initial_radio_button ) + { // It was initially a client-only config. + // Note that initial_client_only_radio_button is only true for a real client-only config + // but not when the server name value for client-only is "localhost" or "127.0.0.1", + // see Printerlib::DetermineClientOnly() and the initNetworkPrinting function below. + // If it was initially a real client-only config, + // the user may have now entered "localhost" or "127.0.0.1" + // which makes it effectively a config with a local running cupsd. + if( current_server_name_input_value != initial_server_name_input_value ) + { something_has_changed = true; + } + } + if( ! something_has_changed ) + { // Nothing has changed: + return true; + } + if( "" != server_name + && "none" != server_name + ) + { // Test for "localhost/"127.0.0.1" first and make a local cupsd accessible + // because the "cups_client_only" tool which sets the ServerName in client.conf + // tests in any case if the cupsd on ServerName is accessible: + if( "localhost" == server_name + || "127.0" == substring( server_name, 0, 5 ) + ) + { // The user has entered "localhost" or "127.0.0.1" as server name + // which makes it effectively a config with a local running cupsd. + // If a local cupsd is already accessible, do nothing, otherwise start it: + if( ! Printerlib::GetAndSetCupsdStatus( "" ) ) + { if( ! Printerlib::GetAndSetCupsdStatus( "start" ) ) + { return false; + } + } + } + if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only " + server_name ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header + // where %1 will be replaced by the server name. + sformat( _("Failed to set 'ServerName %1' in /etc/cups/client.conf"), server_name ), + Printerlib::result["stderr"]:"" + ); + return false; + } + } + else + { // The client-only server name was changed to the empty string or to 'none'. + // This should disable the client-only setup but not start the local cupsd + // because the selected config is still a "client-only" config: + if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only none" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header: + _("Failed to remove the 'ServerName' entry in /etc/cups/client.conf"), + Printerlib::result["stderr"]:"" + ); + return false; + } + } } // Exit successfully by default and as fallback: return true; @@ -380,30 +468,30 @@ Printerlib::DetermineClientOnly(); // Have all widgets disabled initially // but nevertheless fill in the values of the current settings in the system: - UI::ChangeWidget( `id(`cupsd_conf_browsing_off_radio_button), `Value, false ); - UI::ChangeWidget( `id(`cupsd_conf_browsing_on_radio_button), `Value, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, false ); + UI::ChangeWidget( `id(`browsing_off_radio_button), `Value, false ); + UI::ChangeWidget( `id(`browsing_on_radio_button), `Value, false ); + UI::ChangeWidget( `id(`browse_allow_label), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_combo_box), `Enabled, false ); // When by accident "all" and "@LOCAL" were set as BrowseAllow values, - // the "@LOCAL" entry is preselected in cupsd_conf_browse_allow_combo_box + // the "@LOCAL" entry is preselected in browse_allow_combo_box // because this is the more secure setting: - initial_cupsd_conf_browse_allow_combo_box_value = `browse_allow_specific; - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_specific) ); + initial_browse_allow = `browse_allow_specific; + UI::ChangeWidget( `id(`browse_allow_combo_box), `Value, `id(`browse_allow_specific) ); if( contains( Printerlib::cupsd_conf_browse_allow, "all" ) ) - { initial_cupsd_conf_browse_allow_combo_box_value = `browse_allow_all; - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_all) ); + { initial_browse_allow = `browse_allow_all; + UI::ChangeWidget( `id(`browse_allow_combo_box), `Value, `id(`browse_allow_all) ); } if( contains( Printerlib::cupsd_conf_browse_allow, "@LOCAL" ) ) - { initial_cupsd_conf_browse_allow_combo_box_value = `browse_allow_local; - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_local) ); + { initial_browse_allow = `browse_allow_local; + UI::ChangeWidget( `id(`browse_allow_combo_box), `Value, `id(`browse_allow_local) ); } - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false ); - // The preset entry in cupsd_conf_browse_allow_input field + UI::ChangeWidget( `id(`browse_allow_input), `Enabled, false ); + // The preset entry in browse_allow_input field // should not contain "all" or "@LOCAL" because those are - // already selectable via cupsd_conf_browse_allow_combo_box + // already selectable via browse_allow_combo_box // and it should also not contain "none" because this setting - // is implicitely done via cupsd_conf_browsing_off_radio_button: - string cupsd_conf_browse_allow_input_value = mergestring( filter( string value, + // is implicitely done via browsing_off_radio_button: + string browse_allow_input_value = mergestring( filter( string value, Printerlib::cupsd_conf_browse_allow, { value = tolower( value ); return( "all" != value @@ -414,12 +502,12 @@ ), " " ); - initial_cupsd_conf_browse_allow_input_value = cupsd_conf_browse_allow_input_value; - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Value, cupsd_conf_browse_allow_input_value ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, false ); + initial_browse_allow_input_value = browse_allow_input_value; + UI::ChangeWidget( `id(`browse_allow_input), `Value, browse_allow_input_value ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, false ); UI::ChangeWidget( `id(`client_only_radio_button), `Value, false ); UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); - initial_client_conf_server_name_input_value = Printerlib::client_conf_server_name; + initial_server_name_input_value = Printerlib::client_conf_server_name; UI::ChangeWidget( `id(`client_conf_server_name_input), `Value, Printerlib::client_conf_server_name ); UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); UI::ChangeWidget( `id(`connection_wizard), `Enabled, false ); @@ -428,7 +516,7 @@ // but there is also an active ServerName (!="localhost") in /etc/cups/client.conf // have only the client-only widgets avtivated because client-only has topmost priority: if( Printerlib::client_only ) - { initial_client_only_radio_button = true; + { initial_radio_button = `client_only_radio_button; UI::ChangeWidget( `id(`client_only_radio_button), `Value, true ); UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, true ); UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, true ); @@ -438,79 +526,107 @@ UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); // If "none" is present as a BrowseAllow value, no 'Browsing On' widget is enabled // but the 'Browsing Off' widget is enabled instead: - if( Printerlib::browsing_on + if( Printerlib::cupsd_conf_browsing_on && ! contains( Printerlib::cupsd_conf_browse_allow, "none" ) ) - { initial_cupsd_conf_browsing_on_radio_button = true; - UI::ChangeWidget( `id(`cupsd_conf_browsing_on_radio_button), `Value, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, true ); + { initial_radio_button = `browsing_on_radio_button; + UI::ChangeWidget( `id(`browsing_on_radio_button), `Value, true ); + UI::ChangeWidget( `id(`browse_allow_label), `Enabled, true ); + UI::ChangeWidget( `id(`browse_allow_combo_box), `Enabled, true ); // If browsing info is accepted from all hosts, // it is useless to additionally accept it from specific IPs or networks: if( ! contains( Printerlib::cupsd_conf_browse_allow, "all" ) ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, true ); + { UI::ChangeWidget( `id(`browse_allow_input), `Enabled, true ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, true ); } } else - { initial_cupsd_conf_browsing_off_radio_button = true; - UI::ChangeWidget( `id(`cupsd_conf_browsing_off_radio_button), `Value, true ); + { initial_radio_button = `browsing_off_radio_button; + UI::ChangeWidget( `id(`browsing_off_radio_button), `Value, true ); } } - y2milestone( "leaving initNetworkPrinting" ); + y2milestone( "leaving initNetworkPrinting with\ninitial_radio_button = '%1'\ninitial_browse_allow = '%2'\ninitial_browse_allow_input_value = '%3'\ninitial_server_name_input_value = '%4'", initial_radio_button, initial_browse_allow, initial_browse_allow_input_value, initial_server_name_input_value ); } symbol handleNetworkPrinting( string key, map event ) { y2milestone( "entering handleNetworkPrinting with key '%1'\nand event '%2'", key, event ); if( "ValueChanged" == event["EventReason"]:"" ) - { if( `cupsd_conf_browsing_off_radio_button == event["ID"]:nil ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, false ); + { if( `browsing_off_radio_button == event["ID"]:nil ) + { UI::ChangeWidget( `id(`browse_allow_label), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_combo_box), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_input), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, false ); UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); } - if( `cupsd_conf_browsing_on_radio_button == event["ID"]:nil ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, true ); + if( `browsing_on_radio_button == event["ID"]:nil ) + { UI::ChangeWidget( `id(`browse_allow_label), `Enabled, true ); + UI::ChangeWidget( `id(`browse_allow_combo_box), `Enabled, true ); + UI::ChangeWidget( `id(`browse_allow_input), `Enabled, true ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, true ); UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); } - if( `cupsd_conf_browse_allow_combo_box == event["ID"]:nil ) - { if( `browse_allow_all == UI::QueryWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value ) ) + if( `browse_allow_combo_box == event["ID"]:nil ) + { if( `browse_allow_all == UI::QueryWidget( `id(`browse_allow_combo_box), `Value ) ) { // If browsing info is accepted from all hosts, // it is useless to additionally accept it from specific IPs or networks: - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_input), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, false ); } else - { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, true ); + { UI::ChangeWidget( `id(`browse_allow_input), `Enabled, true ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, true ); } } if( `client_only_radio_button == event["ID"]:nil ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false ); - UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input_label), `Enabled, false ); + { UI::ChangeWidget( `id(`browse_allow_label), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_combo_box), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_input), `Enabled, false ); + UI::ChangeWidget( `id(`browse_allow_input_label), `Enabled, false ); UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, true ); UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, true ); UI::ChangeWidget( `id(`connection_wizard), `Enabled, false ); } } if( "Activated" == event["EventReason"]:"" ) - { if( `apply == event["ID"]:nil ) - { if( ! ApplyNetworkPrintingSettings() ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to apply the settings to the system.") - ); + { if( `test_client_conf_server == event["ID"]:nil ) + { string current_server_name_input_value = (string)UI::QueryWidget( `id(`client_conf_server_name_input), `Value ); + string server_name = deletechars( tolower( current_server_name_input_value ), " " ); + // The tests here are the same (except verbosity) as in the cups_client_only tool. + // Make ping less verbose to avoid too much technical data in its output: + if( ! Printerlib::ExecuteBashCommand( "ping -q -w 1 -c 1 " + server_name ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header + // where %1 will be replaced by the server name. + sformat( _("The server '%1' does not respond to a 'ping' in the network"), server_name ), + Printerlib::result["stderr"]:"" + "\n" + + Printerlib::result["stdout"]:"" + ); + } + else + { string first_test_result = Printerlib::result["stderr"]:"" + "\n" + Printerlib::result["stdout"]:""; + // Make netcat verbose, otherwise there would be no output at all + // but some output is needed for the Popup::MessageDetails below: + if( ! Printerlib::ExecuteBashCommand( "netcat -v -w 1 -z " + server_name + " 631" ) ) + { Popup::ErrorDetails( // Popup::ErrorDetails header + // where %1 will be replaced by the server name. + sformat( _("The server '%1' is not accessible via port 631 (IPP/CUPS)"), server_name ), + Printerlib::result["stderr"]:"" + "\n" + + Printerlib::result["stdout"]:"" + ); + } + else + { // When both tests passed, show positive feedback: + Popup::MessageDetails( // Popup::MessageDetails header + // where %1 will be replaced by the server name. + sformat( _("The server '%1' is accessible"), server_name ), + first_test_result + "\n===========================================================\n\n" + + Printerlib::result["stderr"]:"" + "\n" + + Printerlib::result["stdout"]:"" + ); + } } } if( `connection_wizard == event["ID"]:nil ) @@ -525,11 +641,9 @@ void storeNetworkPrinting( string key, map event ) { y2milestone( "entering storeNetworkPrinting with key '%1'\nand event '%2'", key, event ); if( ! ApplyNetworkPrintingSettings() ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to apply the settings to the system.") - ); + { Popup::Error( // Popup::Error message: + _("Failed to apply the settings to the system.") + ); } if( ! something_has_changed ) { y2milestone( "Nothing changed in 'Printing via Network' dialog." ); @@ -545,436 +659,6 @@ return nil; } - - - -/** - * Printing via network dialog - * @return dialog result - */ -any PrintingViaNetworkDialog() -{ string caption = _("Print Via Network"); - string commandline = ""; - // By default there is "Browsing On" in /etc/cups/cupsd.conf - // which is even the fallback if there is no "Browsing" entry at all - // or when the "Browsing" entry is deactivated by a leading '#' character. - // Therefore browsing_on is only false if "Browsing Off" or "Browsing No" - // is explicitely set in /etc/cups/cupsd.conf. - boolean browsing_on = true; - commandline = "egrep -i '^Browsing[[:space:]]+Off|^Browsing[[:space:]]+No' /etc/cups/cupsd.conf"; - if( Printerlib::ExecuteBashCommand( commandline ) ) - { browsing_on = false; - } - // By default there is no "BrowseDeny" entry in /etc/cups/cupsd.conf - // but there can be such entries of the form "BrowseDeny .*" or "BrowseDeny from .*": - string cupsd_conf_browse_deny = ""; - commandline = "egrep -i '^BrowseDeny[[:space:]]+|^BrowseDeny[[:space:]]+from[[:space:]]+' /etc/cups/cupsd.conf | sed -e 's/[Ff][Rr][Oo][Mm]//' | tr -s '[:space:]' | cut -d ' ' -f 2 | tr '[:space:]' ' '"; - if( Printerlib::ExecuteBashCommand( commandline ) ) - { cupsd_conf_browse_deny = Printerlib::result["stdout"]:""; - } - // By default there is no /etc/cups/client.conf file at all - // and usually there is no ServerName entry in a /etc/cups/client.conf file. - // Therefore client_only is only true if there is a /etc/cups/client.conf file - // with an active ServerName entry: - boolean client_only = false; - string client_conf_server_name = ""; - commandline = "egrep -i '^ServerName[[:space:]]+[[:alnum:]]' /etc/cups/client.conf"; - if( Printerlib::ExecuteBashCommand( commandline ) ) - { client_only = true; - // YCP string quoting: A double backslash '\\' results a single backslash '\' in the string. - // At least the trailing newline character must be removed. - commandline = "sed -n -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee][[:space:]][[:space:]]*\\(.*\\)$/\\1/p' /etc/cups/client.conf | tr -d '[:space:]'"; - if( Printerlib::ExecuteBashCommand( commandline ) ) - { client_conf_server_name = Printerlib::result["stdout"]:""; - } - } - term contents = widgetNetworkPrinting; -/* - term contents = `VBox( `VStretch(), - `Frame( _("Use the Common Unix Printing System (CUPS) to print via network"), - `RadioButtonGroup( `id(`browsing_or_client_only_check_boxs), - `VBox( `Left( `RadioButton( `id(`cupsd_conf_browsing_on_radio_button), - `opt(`notify), - _("&Receive printer information which is published by remote CUPS servers"), - ! client_only && browsing_on - ) - ), - `HBox( `HSpacing( 3 ), - `TextEntry( `id(`cupsd_conf_browse_deny_input), - _("&Suppress the information which is published by the following CUPS servers (separated by spaces)"), - cupsd_conf_browse_deny - ) - ), - `Left( `RadioButton( `id(`cupsd_conf_browsing_off_radio_button), - `opt(`notify), - _("&Do not listen to any information which is published by remote CUPS servers"), - ! client_only && ! browsing_on - ) - ), - `VSpacing( 1 ), - `Left( `RadioButton( `id(`client_only_check_box), - `opt(`notify), - _("Do all your printing directly via one single remote &CUPS server"), - client_only - ) - ), - `HBox( `HSpacing( 3 ), - `HWeight( 2, - `TextEntry( `id(`client_conf_server_name_input), - _("&Hostname / IP address"), - client_conf_server_name - ) - ), - `HWeight( 1, - `PushButton( `id(`test_client_conf_server), - _("&Test server access") - ) - ), - `HStretch() - ) - ) - ) - ), - `VStretch(), - `Frame( _("Use a network printer directly or print via another kind of print server"), - `Left( `HBox( `Label( _("Use the") + " " ), - `PushButton( `id(`connection_wizard), - _("&Connection Wizard") - ), - `Label( " " + _("to specify how the network printer is accessible") ) - ) - ) - ), - `VStretch() - ); -*/ - Wizard::SetContentsButtons( caption, - contents, - HELPS["printing_via_network_dialog"]:"", - Label::BackButton(), - // Set a different label for the "next" button - // (i.e. the lower right button which results `next as UI::UserInput): - Label::OKButton() - ); - // Enable or disable certain widgets according to what is actually set: - if( browsing_on ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_deny_input), `Enabled, true ); - UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); - UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); - UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); - } - else - { UI::ChangeWidget( `id(`cupsd_conf_browse_deny_input), `Enabled, false ); - UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); - UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); - UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); - } - if( client_only ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_deny_input), `Enabled, false ); - UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, true ); - UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, true ); - UI::ChangeWidget( `id(`connection_wizard), `Enabled, false ); - } - any ret = nil; - while(true) - { ret = UI::UserInput(); - if( `abort == ret || `cancel == ret || `back == ret ) break; - if( `cupsd_conf_browsing_on_radio_button == ret ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_deny_input), `Enabled, true ); - UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); - UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); - UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); - } - if( `cupsd_conf_browsing_off_radio_button == ret ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_deny_input), `Enabled, false ); - UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false ); - UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false ); - UI::ChangeWidget( `id(`connection_wizard), `Enabled, true ); - } - if( `client_only_check_box == ret ) - { UI::ChangeWidget( `id(`cupsd_conf_browse_deny_input), `Enabled, false ); - UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, true ); - UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, true ); - UI::ChangeWidget( `id(`connection_wizard), `Enabled, false ); - } - if( `next == ret ) - { boolean cupsd_restart_required = false; - boolean cupsd_start_required = false; - boolean cupsd_stop_required = false; - any current_radio_button = UI::QueryWidget( `id(`browsing_or_client_only_check_boxs), `CurrentButton ); - if( `cupsd_conf_browsing_on_radio_button == current_radio_button ) - { if( client_only ) - { cupsd_start_required = true; - commandline = "sed -i.yast2.save -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee]/#ServerName/' /etc/cups/client.conf"; - if( ! Printerlib::ExecuteBashCommand( commandline ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to disable the 'ServerName' entry in /etc/cups/client.conf") - ); - continue; - } - } - if( ! browsing_on ) - { cupsd_restart_required = true; - } - // Set "Browsing On" explicitely in cupsd.conf in any case because - // the "BrowseDeny" lines are appended below the "Browsing On" line - // to get a nice to read cupsd.conf file: - Printerlib::ExecuteBashCommand( "sed -i.yast2.save -e 's/^.*[Bb][Rr][Oo][Ww][Ss][Ii][Nn][Gg].*/Browsing On/' /etc/cups/cupsd.conf" ); - if( ! Printerlib::ExecuteBashCommand( "grep '^Browsing On$' /etc/cups/cupsd.conf" ) ) - { string first_browse_line = ""; - Printerlib::ExecuteBashCommand( "sed -n -e '/[Bb][Rr][Oo][Ww][Ss]/=' /etc/cups/cupsd.conf | head -n 1" ); - first_browse_line = filterchars( Printerlib::result["stdout"]:"", Printer::number_chars ); - if( "" == first_browse_line ) first_browse_line = "$"; - Printerlib::ExecuteBashCommand( "sed -i.yast2.save -e '" + first_browse_line + "aBrowsing On' /etc/cups/cupsd.conf" ); - if( ! Printerlib::ExecuteBashCommand( "grep '^Browsing On$' /etc/cups/cupsd.conf" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to set 'Browsing On' in /etc/cups/cupsd.conf") - ); - continue; - } - } - string browse_deny_input = (string)UI::QueryWidget( `id(`cupsd_conf_browse_deny_input), `Value ); - if( cupsd_conf_browse_deny != browse_deny_input ) - { cupsd_restart_required = true; - commandline = "sed -i.yast2.save -e '/^[Bb][Rr][Oo][Ww][Ss][Ee][Dd][Ee][Nn][Yy].*/d' /etc/cups/cupsd.conf && for h in " + browse_deny_input + " ; do sed -i -e \"/Browsing On/aBrowseDeny $h\" /etc/cups/cupsd.conf ; done"; - if( ! Printerlib::ExecuteBashCommand( commandline ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to write 'BrowseDeny' entries to /etc/cups/cupsd.conf") - ); - continue; - } - } - } - if( `cupsd_conf_browsing_off_radio_button == current_radio_button ) - { if( client_only ) - { cupsd_start_required = true; - commandline = "sed -i.yast2.save -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee]/#ServerName/' /etc/cups/client.conf"; - if( ! Printerlib::ExecuteBashCommand( commandline ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to disable the 'ServerName' entry in /etc/cups/client.conf") - ); - continue; - } - } - if( browsing_on ) - { cupsd_restart_required = true; - commandline = "sed -i.yast2.save -e 's/^.*[Bb][Rr][Oo][Ww][Ss][Ii][Nn][Gg].*/Browsing Off/' /etc/cups/cupsd.conf"; - if( ! Printerlib::ExecuteBashCommand( commandline ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to set 'Browsing Off' in /etc/cups/cupsd.conf") - ); - continue; - } - } - } - if( `client_only_check_box == current_radio_button ) - { string server_name_input = (string)UI::QueryWidget( `id(`client_conf_server_name_input), `Value ); - if( "" == server_name_input ) - { Popup::AnyMessage( // Header of a Popup::AnyMessage when no server name was entered: - _("No Server Name"), - // Body of a Popup::AnyMessage when no server name was entered: - _("Enter a server name.") - ); - continue; - } - if( client_conf_server_name != server_name_input ) - { if( "localhost" == server_name_input ) - { cupsd_start_required = true; - } - else - { cupsd_stop_required = true; - } - if( ! client_only ) - { commandline = "echo 'ServerName " + server_name_input + "' >/etc/cups/client.conf"; - } - else - { commandline = "sed -i.yast2.save -e 's/^.*[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee].*/ServerName " - + server_name_input - + "/' /etc/cups/client.conf"; - } - if( ! Printerlib::ExecuteBashCommand( commandline ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to set the 'ServerName' entry in /etc/cups/client.conf") - ); - continue; - } - } - } - if( cupsd_stop_required ) - { if( ! Popup::YesNoHeadline( _("Stop local running CUPS daemon"), - _("No local CUPS daemon is needed when you do all your printing via a remote CUPS server.") - ) - ) - { continue; - } - if( ! Service::Stop("cups") ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to stop the CUPS daemon.") - ); - continue; - } - } - if( cupsd_restart_required ) - { if( ! Popup::YesNoHeadline( _("Restart local running CUPS daemon"), - _("A restart is needed because the configuration of the CUPS daemon changed.") - ) - ) - { continue; - } - if( ! Service::Restart("cups") ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to restart the CUPS daemon.") - ); - continue; - } - else - { Popup::TimedMessage( _("Waiting for the CUPS daemon to become ready to operate..."), - 60 - ); - } - } - else - { if( cupsd_start_required ) - { if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) - { if( ! Popup::YesNoHeadline( _("Start local running CUPS daemon"), - _("A local running CUPS daemon is needed for your setup.") - ) - ) - { continue; - } - if( ! Service::Start("cups") ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to start the CUPS daemon.") - ); - continue; - } - Popup::TimedMessage( _("Waiting for the CUPS daemon to become ready to operate..."), - 60 - ); - } - } - } - if( cupsd_restart_required || cupsd_start_required ) - { if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("No local running CUPS daemon is accessible.") - ); - continue; - } - } - // After changes regarding printing via network, enforce to show also remote queues. - // For example when CUPS Browsing was disabled before and becomes now enabled, - // there are probably new remote queues which should be shown to the user - // in particular when his queue_filter_string was "local" before. - // On the other hand if queue_filter_string was "remote" before - // but now client-only is no longer used (or it is a "localhost" client-only setup) - // there are probably new local queues which should be shown to the user. - // Therefore set the queue_filter_string to "all" in any case to be on the safe side: - Printer::queue_filter_show_local = true; - Printer::queue_filter_show_remote = true; - // Exit this dialog in any case: - break; - } - if( `test_client_conf_server == ret ) - { string server_name_input = (string)UI::QueryWidget( `id(`client_conf_server_name_input), `Value ); - if( "" == server_name_input ) - { Popup::AnyMessage( // Header of a Popup::AnyMessage when no server name was entered: - _("No Server Name"), - // Body of a Popup::AnyMessage when no server name was entered: - _("Enter a server name.") - ); - continue; - } - if( "localhost" == server_name_input ) - { if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) - { if( ! Popup::YesNoHeadline( _("Start local running CUPS daemon"), - _("A local running CUPS daemon is needed for your setup.") - ) - ) - { continue; - } - if( ! Service::Start("cups") ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("Failed to start the CUPS daemon.") - ); - continue; - } - else - { Popup::TimedMessage( _("Waiting for the CUPS daemon to become ready to operate..."), - 60 - ); - } - } - if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) - { Report::Error( // Message of a Report::Error. - // Only a simple message because this error does not happen on a normal system - // (i.e. a system which is not totally broken or totally messed up). - _("No local running CUPS daemon is accessible.") - ); - continue; - } - } - if( ! Printerlib::ExecuteBashCommand( "netcat -w 1 -z " + server_name_input + " 631" ) ) - { Popup::Error( // Message of a Popup::Error when a remote CUPS server is not accessible: - _("This server is not accessible.") - ); - continue; - } - if( ! Printerlib::ExecuteBashCommand( "echo -en 'GET / HTTP/1.1\n\n' | netcat -w 10 " - + server_name_input - + " 631 | grep '^Server: CUPS'" ) - ) - { Popup::Warning( // Message of a Popup::Warning when a remote CUPS server name seems to be wrong: - _("This host does not respond like a CUPS server should do.") - ); - continue; - } - Popup::AnyMessage( // Header of a Popup::AnyMessage when a remote CUPS server looks o.k.: - _("CUPS Server OK"), - // Body of a Popup::AnyMessage when a remote CUPS server looks o.k.: - _("The CUPS server responds as expected.") - ); - continue; - } - if( `connection_wizard == ret ) - { // After the ConnectionWizardDialog and BasicAddDialog a new local queue exists. - // Therefore enforce to show also local queues in the OverviewDialog - // in particular when the queue_filter_string was "remote" before: -/* - if( "remote" == Printer::queue_filter_string ) - { Printer::queue_filter_string = "all"; - } -*/ - // Exit this dialog and go to the ConnectionWizardDialog and BasicAddDialog via the sequencer in wizards.ycp: - break; - } - y2milestone( "Ignoring unexpected returncode in PrintingViaNetworkDialog: %1", ret ); - continue; - } - return ret; -} - /* EOF */ } + Modified: trunk/printer/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/wizards.ycp?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/src/wizards.ycp (original) +++ trunk/printer/src/wizards.ycp Thu Sep 4 18:26:20 2008 @@ -53,7 +53,6 @@ "modify" : ``( BasicModifyDialog() ), "modify_connection_wizard" : ``( ConnectionWizardDialog() ), "modify_driver_options" : ``( DriverOptionsDialog() ), - "printing_via_network" : ``( PrintingViaNetworkDialog() ), "printing_via_network_connection_wizard" : ``( ConnectionWizardDialog() ) ]; map sequence = $[ "ws_start" : "overview", @@ -62,7 +61,6 @@ `add : "add", `modify : "modify", `delete : "overview", - `printing_via_network : "printing_via_network", `connection_wizard : "printing_via_network_connection_wizard" ], "add" : $[ `abort : `abort, @@ -83,10 +81,6 @@ "modify_driver_options" : $[ `abort : `abort, `next : "modify" ], - "printing_via_network" : $[ `abort : `abort, - `next : "overview", - `connection_wizard : "printing_via_network_connection_wizard" - ], "printing_via_network_connection_wizard" : $[ `abort : `abort, `next : "add" ], Modified: trunk/printer/tools/cups_client_only URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/cups_client_only?rev=50701&r1=50700&r2=50701&view=diff ============================================================================== --- trunk/printer/tools/cups_client_only (original) +++ trunk/printer/tools/cups_client_only Thu Sep 4 18:26:20 2008 @@ -70,7 +70,7 @@ then echo "Cannot execute ping" 1>&2 else # Test if the server responds to ping: if ! $PING -w 1 -c 1 $SERVERNAME &>/dev/null - then echo "The host '$SERVERNAME' does not respond to 'ping'." 1>&2 + then echo "The server '$SERVERNAME' does not respond to a 'ping' in the network." 1>&2 exit 2 fi fi @@ -82,7 +82,7 @@ # It is possible to run the cupsd on another port and specify this # via 'ServerName host:port' but currently this special case is ignored. if ! $NETCAT -w 1 -z $SERVERNAME 631 &>/dev/null - then echo "No cupsd accessible on host '$SERVERNAME' via port 631 (IPP)." 1>&2 + then echo "The server '$SERVERNAME' is not accessible via port 631 (IPP/CUPS)." 1>&2 exit 3 fi fi -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org