Author: mzugec Date: Thu Jul 17 15:55:20 2008 New Revision: 49226 URL: http://svn.opensuse.org/viewcvs/yast?rev=49226&view=rev Log: moved some functionality into Printerlib.ycp moved "Printing via Network" into DialogTree Added: branches/tmp/mzugec/printer2/src/Printerlib.ycp Modified: branches/tmp/mzugec/printer2/src/Makefile.am branches/tmp/mzugec/printer2/src/Printer.ycp branches/tmp/mzugec/printer2/src/basicadd.ycp branches/tmp/mzugec/printer2/src/basicmodify.ycp branches/tmp/mzugec/printer2/src/dialogs.ycp branches/tmp/mzugec/printer2/src/overview.ycp branches/tmp/mzugec/printer2/src/printingvianetwork.ycp branches/tmp/mzugec/printer2/src/wizards.ycp Modified: branches/tmp/mzugec/printer2/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/Makefile.am?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/Makefile.am (original) +++ branches/tmp/mzugec/printer2/src/Makefile.am Thu Jul 17 15:55:20 2008 @@ -23,8 +23,9 @@ printer.desktop module_DATA = \ - Printer.ycp \ - Printer2.pm + Printerlib.ycp \ + Printer.ycp +# Printer2.pm # create a symlink for local build, #145327 printer: Modified: branches/tmp/mzugec/printer2/src/Printer.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/Printer.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/Printer.ycp (original) +++ branches/tmp/mzugec/printer2/src/Printer.ycp Thu Jul 17 15:55:20 2008 @@ -40,6 +40,7 @@ import "Summary"; import "Message"; import "Popup"; +import "Printerlib"; /** * Prototypes @@ -201,10 +202,6 @@ global boolean queue_filter_show_local = true; global boolean queue_filter_show_remote = true; - -global boolean client_only = false; -global string client_conf_server_name = ""; - /** * Driver options (options in the PPD for one specific existing queue): * Determined at runtime via Printer::DetermineDriverOptions( "queue_name") @@ -223,17 +220,6 @@ */ global list< map< string, any > > driver_options = []; -// The result map is used as a simple common local store for whatever additional results -// (in particular commandline exit code, stdout, stderr, and whatever messages) -// so that the local functions in this module can be of easy-to-use boolean type. -// The following keys are used: -// result["exit"]:<integer> for exit codes -// result["stdout"]:<string> for stdout and whatever non-error-messages -// result["stderr"]:<string> for stderr and whatever error-messages -global map result = $[ "exit":0, - "stdout":"", - "stderr":"" - ]; /* * Local variables: @@ -252,24 +238,6 @@ * Global functions which are called by the local functions below: */ -/** - * Wrapper for SCR::Execute to execute a bash command to increase verbosity via y2milestone. - * It reports the command via y2milestone in any case and it reports exit code, stdout - * and stderr via y2milestone in case of non-zero exit code. - * @param bash_commandline string of the bash command to be executed - * @return true on success - */ -global boolean ExecuteBashCommand( string bash_commandline ) -{ y2milestone( "Executing bash commandline: %1", bash_commandline ); - result = (map)SCR::Execute( .target.bash_output, bash_commandline ); - if( result["exit"]:9999 != 0 ) - { y2warning( "'%1' exit code is: %2", bash_commandline, result["exit"]:9999 ); - y2warning( "'%1' stdout is: %2", bash_commandline, result["stdout"]:"" ); - y2warning( "'%1' stderr is: %2", bash_commandline, result["stderr"]:"" ); - return false; - } - return true; -} /* * Local functions which are called by the global functions below: @@ -290,7 +258,7 @@ { // Show nice self-updating feedback: // Empty an existing database file so that the DownloadProgress starts at the beginning. // Don't care if this command is successful. All what matters is if CreateDatabase() works. - ExecuteBashCommand( "cat /dev/null >" + database_filename ); + Printerlib::ExecuteBashCommand( "cat /dev/null >" + database_filename ); UI::OpenDialog( `MinSize( 60, 3, `ReplacePoint( `id(`create_database_progress_replace_point), `DownloadProgress( // Header of a DownloadProgress indicator: @@ -312,7 +280,7 @@ _("Retrieving printer driver information...") ); } - if( ! ExecuteBashCommand( create_database_commandline ) ) + if( ! Printerlib::ExecuteBashCommand( create_database_commandline ) ) { if( progress_feedback ) { UI::CloseDialog(); } @@ -408,7 +376,7 @@ { // Show nice self-updating feedback: // Empty an existing progress file so that the DownloadProgress starts at the beginning. // Don't care if this command is successful. - ExecuteBashCommand( "cat /dev/null >" + autodetect_printers_progress_filename ); + Printerlib::ExecuteBashCommand( "cat /dev/null >" + autodetect_printers_progress_filename ); UI::OpenDialog( `MinSize( 60, 3, `ReplacePoint( `id(`autodetect_printers_progress_replace_point), `DownloadProgress( // Header of a DownloadProgress indicator: @@ -432,7 +400,7 @@ _("Detecting printers...") ); } - if( ! ExecuteBashCommand( autodetect_printers_commandline ) ) + if( ! Printerlib::ExecuteBashCommand( autodetect_printers_commandline ) ) { if( progress_feedback ) { UI::CloseDialog(); } @@ -522,7 +490,7 @@ global boolean AutodetectQueues() { // To be safe invalidate selected_queues_index in any case: selected_queues_index = -1; - if( ! ExecuteBashCommand( autodetect_queues_commandline ) ) + if( ! Printerlib::ExecuteBashCommand( autodetect_queues_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). @@ -579,7 +547,7 @@ { return false; } string commandline = determine_printer_driver_options_commandline + queue_name; - if( ! ExecuteBashCommand( commandline ) ) + if( ! Printerlib::ExecuteBashCommand( commandline ) ) { Report::Error( sformat( // Message of a Report::Error where %1 will be replaced by the queue 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). @@ -641,10 +609,8 @@ ); // Progress 1. stage (Autodetect already configured printers): if( Abort() ) return false; + Printerlib::Read(); Progress::NextStage(); - client_only = Printer::ExecuteBashCommand( "egrep -i '^ServerName[[:space:]]+[[:alnum:]]' /etc/cups/client.conf" ); - if( ExecuteBashCommand( "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:]'" ) ) - client_conf_server_name = result["stdout"]:""; // Progress last stage (progress finished): if( Abort() ) return false; Progress::Finish(); @@ -1549,7 +1515,7 @@ } // Note the bash quotings of the queue_name and description strings with ' characters: string commandline = "/usr/sbin/lpadmin -h localhost -p '" + queue_name + "' -v " + uri + " -m " + ppd + " -D '" + description + "' -E"; - if( ! ExecuteBashCommand( commandline ) ) + if( ! Printerlib::ExecuteBashCommand( commandline ) ) { return false; } return true; @@ -1573,7 +1539,7 @@ selected_queues_index = -1; // Note the bash quoting of the queue_name string with ' characters: string commandline = "/usr/sbin/lpadmin -h localhost -x '" + queue_name + "'"; - if( ! ExecuteBashCommand( commandline ) ) + if( ! Printerlib::ExecuteBashCommand( commandline ) ) { return false; } return true; Added: branches/tmp/mzugec/printer2/src/Printerlib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/Printerlib.ycp?rev=49226&view=auto ============================================================================== --- branches/tmp/mzugec/printer2/src/Printerlib.ycp (added) +++ branches/tmp/mzugec/printer2/src/Printerlib.ycp Thu Jul 17 15:55:20 2008 @@ -0,0 +1,62 @@ +{ +module "Printerlib"; +textdomain "printer"; + +global boolean client_only = false; +global string client_conf_server_name = ""; + +// 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. +global boolean browsing_on = true; + +// 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 .*": +global string cupsd_conf_browse_deny = ""; + +// The result map is used as a simple common local store for whatever additional results +// (in particular commandline exit code, stdout, stderr, and whatever messages) +// so that the local functions in this module can be of easy-to-use boolean type. +// The following keys are used: +// result["exit"]:<integer> for exit codes +// result["stdout"]:<string> for stdout and whatever non-error-messages +// result["stderr"]:<string> for stderr and whatever error-messages +global map result = $[ "exit":0, + "stdout":"", + "stderr":"" + ]; + +/** + * Wrapper for SCR::Execute to execute a bash command to increase verbosity via y2milestone. + * It reports the command via y2milestone in any case and it reports exit code, stdout + * and stderr via y2milestone in case of non-zero exit code. + * @param bash_commandline string of the bash command to be executed + * @return true on success + */ +global boolean ExecuteBashCommand( string bash_commandline ) +{ y2milestone( "Executing bash commandline: %1", bash_commandline ); + result = (map)SCR::Execute( .target.bash_output, bash_commandline ); + if( result["exit"]:9999 != 0 ) + { y2warning( "'%1' exit code is: %2", bash_commandline, result["exit"]:9999 ); + y2warning( "'%1' stdout is: %2", bash_commandline, result["stdout"]:"" ); + y2warning( "'%1' stderr is: %2", bash_commandline, result["stderr"]:"" ); + return false; + } + return true; +} + +global void Read(){ + client_only = ExecuteBashCommand( "egrep -i '^ServerName[[:space:]]+[[:alnum:]]' /etc/cups/client.conf" ); + if( ExecuteBashCommand( "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:]'" ) ) + client_conf_server_name = result["stdout"]:""; + + if( Printerlib::ExecuteBashCommand( "egrep -i '^Browsing[[:space:]]+Off|^Browsing[[:space:]]+No' /etc/cups/cupsd.conf" ) ) + browsing_on = false; + string 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"]:""; +} + + +} Modified: branches/tmp/mzugec/printer2/src/basicadd.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/basicadd.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/basicadd.ycp (original) +++ branches/tmp/mzugec/printer2/src/basicadd.ycp Thu Jul 17 15:55:20 2008 @@ -34,6 +34,7 @@ import "Label"; import "Wizard"; import "Printer"; +import "Printerlib"; import "Popup"; include "printer/helps.ycp"; @@ -262,7 +263,7 @@ // and when the testpage checkbox was activated. // To be safe test explicitely for 'true' because the checkbox value might be 'nil': if( true == (boolean)UI::QueryWidget(`id(`testpage_checkbox), `Value) ) - { if( ! Printer::ExecuteBashCommand( "/usr/bin/lp -d '" + { if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lp -d '" + queue_name + "' -o page-label=\"Testprint:$(hostname)\" /usr/share/cups/data/testprint.ps" ) Modified: branches/tmp/mzugec/printer2/src/basicmodify.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/basicmodify.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/basicmodify.ycp (original) +++ branches/tmp/mzugec/printer2/src/basicmodify.ycp Thu Jul 17 15:55:20 2008 @@ -34,6 +34,7 @@ import "Label"; import "Wizard"; import "Printer"; +import "Printerlib"; import "Popup"; include "printer/helps.ycp"; @@ -88,7 +89,7 @@ // is installed or configured, see "/usr/bin/cups-config --serverroot". if( "" != ppd ) { commandline = "test -r " + ppd; - if( Printer::ExecuteBashCommand( commandline ) ) + if( Printerlib::ExecuteBashCommand( commandline ) ) { driver_options_content = `HBox( `Label( _("All") + " " ), `PushButton( `id(`driver_options), _("Driver &Options") @@ -105,9 +106,9 @@ // which suppresses it in certain "lpinfo -m" output. // Note the YCP quoting: \" becomes " and \\n becomes \n in the commandline. commandline = "grep '^\*NickName' " + ppd + " | cut -s -d '\"' -f2 | sed -e 's/(recommended)//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -s ' ' | tr -d '\\n'"; - if( Printer::ExecuteBashCommand( commandline ) ) - { y2milestone( "'%1' stdout (nick_name) is: '%2'", commandline, Printer::result["stdout"]:"" ); - nick_name = Printer::result["stdout"]:""; + if( Printerlib::ExecuteBashCommand( commandline ) ) + { y2milestone( "'%1' stdout (nick_name) is: '%2'", commandline, Printerlib::result["stdout"]:"" ); + nick_name = Printerlib::result["stdout"]:""; driver_filter_input_text = nick_name; // Match only at the beginning of the NickName entry in the PPD: driver_filter_string = "^" + filterchars( tolower( nick_name ), Printer::lower_alnum_chars ); @@ -432,7 +433,7 @@ { Wizard::DisableBackButton(); Wizard::DisableAbortButton(); Wizard::DisableNextButton(); - if( ! Printer::ExecuteBashCommand( commandline ) ) + if( ! Printerlib::ExecuteBashCommand( commandline ) ) { Popup::Error( // Message of a Popup::Error // where %1 will be replaced by the queue name. // Only a simple message because this error does not happen on a normal system Modified: branches/tmp/mzugec/printer2/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/dialogs.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/dialogs.ycp (original) +++ branches/tmp/mzugec/printer2/src/dialogs.ycp Thu Jul 17 15:55:20 2008 @@ -40,6 +40,7 @@ include "printer/helps.ycp"; include "printer/overview.ycp"; +include "printer/printingvianetwork.ycp"; /** * DriverOptionsDialog dialog @@ -105,7 +106,7 @@ { Wizard::DisableBackButton(); Wizard::DisableAbortButton(); Wizard::DisableNextButton(); - if( ! Printer::ExecuteBashCommand( commandline ) ) + if( ! Printerlib::ExecuteBashCommand( commandline ) ) { Popup::Error( // Message of a Popup::Error // where %1 will be replaced by the queue name. // Only a simple message because this error does not happen on a normal system @@ -201,6 +202,68 @@ "init" : initOverview, "handle" : handleOverview + ], + "NETWORKPRINTING" : $[ + "widget" : `custom, + "custom_widget" : + `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"), + ! Printerlib::client_only && Printerlib::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)"), + Printerlib::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"), + ! Printerlib::client_only && ! Printerlib::browsing_on + ) + ), + `VSpacing( 1 ), + `Left( `RadioButton( `id(`client_only_check_box), + `opt(`notify), + _("Do all your printing directly via one single remote &CUPS server"), + Printerlib::client_only + ) + ), + `HBox( `HSpacing( 3 ), + `HWeight( 2, + `TextEntry( `id(`client_conf_server_name_input), + _("&Hostname / IP address"), + Printerlib::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() + ), + "handle" : handleNetworkPrinting ] ]; @@ -213,6 +276,14 @@ ), "widget_names" : ["OVERVIEW"] ], + "network" : $[ + "header" : _("Printing via Network"), + "tree_item_label" : _("Printing via Network"), + "contents" : `VBox ( + "NETWORKPRINTING" + ), + "widget_names" : ["NETWORKPRINTING"] + ], ]; @@ -220,7 +291,7 @@ string caption = _("Detected Printers"); symbol ret = DialogTree::ShowAndRun ($[ - "ids_order" : [ "overview" ], + "ids_order" : [ "overview", "network" ], "initial_screen" : "overview", "screens" : tabs_descr, "widget_descr" : wd, Modified: branches/tmp/mzugec/printer2/src/overview.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/overview.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/overview.ycp (original) +++ branches/tmp/mzugec/printer2/src/overview.ycp Thu Jul 17 15:55:20 2008 @@ -37,6 +37,7 @@ import "Wizard"; import "Wizard_hw"; import "Confirm"; +import "Printerlib"; import "Printer"; import "Service"; @@ -47,16 +48,16 @@ boolean local_content_selected = Printer::queue_filter_show_local; boolean remote_content_selected = Printer::queue_filter_show_remote; boolean local_cupsd_required = true; - boolean local_cupsd_accessible = Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ); + boolean local_cupsd_accessible = Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ); // 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: - if( Printer::client_only ) + if( Printerlib::client_only ) { // YCP string quoting: A double backslash '\\' results a single backslash '\' in the string. // At least the trailing newline character must be removed. - if( Printer::client_conf_server_name == "localhost" ) + if( Printerlib::client_conf_server_name == "localhost" ) { local_content_selected = true; remote_content_selected = true; @@ -85,7 +86,7 @@ 60 ); } - local_cupsd_accessible = Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ); + local_cupsd_accessible = Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ); 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 @@ -191,7 +192,7 @@ } if( "local" == Printer::queues[selected_queue_index,"config"]:"remote" ) Printer::selected_queues_index = selected_queue_index; - if( ! Printer::ExecuteBashCommand( "/usr/bin/lp -d '" + if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lp -d '" + queue_name + "' -o page-label=\"Testprint:$(hostname)\" /usr/share/cups/data/testprint.ps" ) @@ -215,14 +216,14 @@ if (event["EventReason"]:"" == "Activated" && event["ID"]:nil == `add){ // client only - if( Printer::client_only && Printer::client_conf_server_name != "localhost" ) + if( Printerlib::client_only && Printerlib::client_conf_server_name != "localhost" ) { if( ! Popup::YesNoHeadline( "Disable remote CUPS server setting", "A remote CUPS server setting conflicts with adding a print queue." ) ) return nil; // Disable the 'ServerName' entry in /etc/cups/client.conf: - if( ! Printer::ExecuteBashCommand( "sed -i.yast2.save -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee]/#ServerName/' /etc/cups/client.conf" ) ) + if( ! Printerlib::ExecuteBashCommand( "sed -i.yast2.save -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee]/#ServerName/' /etc/cups/client.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). @@ -231,7 +232,7 @@ return nil; } } - if( ! Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) + if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) { // No local running cupsd is accessible: if( ! Popup::YesNoHeadline( "Start local running CUPS daemon", "A local running CUPS daemon is needed to add a print queue." @@ -249,7 +250,7 @@ } Popup::TimedMessage( _("Waiting for the CUPS daemon to become ready to operate..."), 60 ); } - if( ! Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) + 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). Modified: branches/tmp/mzugec/printer2/src/printingvianetwork.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/printingvianetwork.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/printingvianetwork.ycp (original) +++ branches/tmp/mzugec/printer2/src/printingvianetwork.ycp Thu Jul 17 15:55:20 2008 @@ -34,12 +34,68 @@ import "Label"; import "Wizard"; import "Printer"; +import "Printerlib"; import "Popup"; import "Report"; import "Service"; include "printer/helps.ycp"; + + + +symbol handleNetworkPrinting(string key, map event){ + if( Printerlib::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( Printerlib::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 ); + } + + if ( event["EventReason"]:"" == "ValueChanged" ){ + if( event["ID"]:nil == `cupsd_conf_browsing_on_radio_button ) + { 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( event["ID"]:nil == `cupsd_conf_browsing_off_radio_button ) + { 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( event["ID"]:nil == `client_only_check_box) + { 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 (event["EventReason"]:""=="Activated" && event["ID"]:nil==`connection_wizard) return `connection_wizard; + + y2internal("event %1", event); + return nil; +} + + + + + + /** * Printing via network dialog * @return dialog result @@ -54,15 +110,15 @@ // 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( Printer::ExecuteBashCommand( commandline ) ) + 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( Printer::ExecuteBashCommand( commandline ) ) - { cupsd_conf_browse_deny = Printer::result["stdout"]:""; + 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. @@ -71,13 +127,13 @@ boolean client_only = false; string client_conf_server_name = ""; commandline = "egrep -i '^ServerName[[:space:]]+[[:alnum:]]' /etc/cups/client.conf"; - if( Printer::ExecuteBashCommand( commandline ) ) + 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( Printer::ExecuteBashCommand( commandline ) ) - { client_conf_server_name = Printer::result["stdout"]:""; + if( Printerlib::ExecuteBashCommand( commandline ) ) + { client_conf_server_name = Printerlib::result["stdout"]:""; } } term contents = `VBox( `VStretch(), @@ -195,7 +251,7 @@ { 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( ! Printer::ExecuteBashCommand( commandline ) ) + 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). @@ -210,14 +266,14 @@ // 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: - Printer::ExecuteBashCommand( "sed -i.yast2.save -e 's/^.*[Bb][Rr][Oo][Ww][Ss][Ii][Nn][Gg].*/Browsing On/' /etc/cups/cupsd.conf" ); - if( ! Printer::ExecuteBashCommand( "grep '^Browsing On$' /etc/cups/cupsd.conf" ) ) + 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 = ""; - Printer::ExecuteBashCommand( "sed -n -e '/[Bb][Rr][Oo][Ww][Ss]/=' /etc/cups/cupsd.conf | head -n 1" ); - first_browse_line = filterchars( Printer::result["stdout"]:"", Printer::number_chars ); + 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 = "$"; - Printer::ExecuteBashCommand( "sed -i.yast2.save -e '" + first_browse_line + "aBrowsing On' /etc/cups/cupsd.conf" ); - if( ! Printer::ExecuteBashCommand( "grep '^Browsing On$' /etc/cups/cupsd.conf" ) ) + 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). @@ -230,7 +286,7 @@ 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( ! Printer::ExecuteBashCommand( commandline ) ) + 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). @@ -244,7 +300,7 @@ { 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( ! Printer::ExecuteBashCommand( commandline ) ) + 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). @@ -256,7 +312,7 @@ 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( ! Printer::ExecuteBashCommand( commandline ) ) + 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). @@ -291,7 +347,7 @@ + server_name_input + "/' /etc/cups/client.conf"; } - if( ! Printer::ExecuteBashCommand( commandline ) ) + 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). @@ -340,7 +396,7 @@ } else { if( cupsd_start_required ) - { if( ! Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) + { 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.") ) @@ -362,7 +418,7 @@ } } if( cupsd_restart_required || cupsd_start_required ) - { if( ! Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) + { 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). @@ -395,7 +451,7 @@ continue; } if( "localhost" == server_name_input ) - { if( ! Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) + { 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.") ) @@ -416,7 +472,7 @@ ); } } - if( ! Printer::ExecuteBashCommand( "/usr/bin/lpstat -h localhost -r" ) ) + 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). @@ -425,13 +481,13 @@ continue; } } - if( ! Printer::ExecuteBashCommand( "netcat -w 1 -z " + server_name_input + " 631" ) ) + 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( ! Printer::ExecuteBashCommand( "echo -en 'GET / HTTP/1.1\n\n' | netcat -w 10 " + if( ! Printerlib::ExecuteBashCommand( "echo -en 'GET / HTTP/1.1\n\n' | netcat -w 10 " + server_name_input + " 631 | grep '^Server: CUPS'" ) ) Modified: branches/tmp/mzugec/printer2/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mzugec/printer2/src/wizards.ycp?rev=49226&r1=49225&r2=49226&view=diff ============================================================================== --- branches/tmp/mzugec/printer2/src/wizards.ycp (original) +++ branches/tmp/mzugec/printer2/src/wizards.ycp Thu Jul 17 15:55:20 2008 @@ -64,8 +64,9 @@ `add : "add", `modify : "modify", `delete : "overview", - `printing_via_network : "printing_via_network", - `sharing : "sharing" +// `printing_via_network : "printing_via_network", + `sharing : "sharing", + `connection_wizard : "printing_via_network_connection_wizard" ], "add" : $[ `abort : `abort, `next : "overview", @@ -85,10 +86,12 @@ "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" ], -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org