Author: jsmeix Date: Wed Oct 8 12:10:28 2008 New Revision: 51967 URL: http://svn.opensuse.org/viewcvs/yast?rev=51967&view=rev Log: The "Share Printers" dialog should now work. Modified: trunk/printer/src/printingvianetwork.ycp trunk/printer/src/sharing.ycp trunk/printer/tools/modify_cupsd_conf Modified: trunk/printer/src/printingvianetwork.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printingvianetwork.ycp?rev=51967&r1=51966&r2=51967&view=diff ============================================================================== --- trunk/printer/src/printingvianetwork.ycp (original) +++ trunk/printer/src/printingvianetwork.ycp Wed Oct 8 12:10:28 2008 @@ -43,7 +43,8 @@ term widgetNetworkPrinting = `VBox ( `VStretch(), `Frame - ( _("Use CUPS to Print Via Network"), + ( // A caption for a Frame to set up to use CUPS to print via network: + _("Use CUPS to Print Via Network"), `RadioButtonGroup ( `id(`browsing_or_client_only_check_boxes), `VBox @@ -51,6 +52,7 @@ ( `RadioButton ( `id(`browsing_off_radio_button), `opt(`notify), + // A RadioButton to not receive printer information from remote CUPS servers: _("&Do not Receive Printer Information from Remote CUPS servers") ) ), @@ -58,6 +60,7 @@ ( `RadioButton ( `id(`browsing_on_radio_button), `opt(`notify), + // A RadioButton to receive printer information from remote CUPS servers: _("Receive Printer &Information from Remote CUPS servers") ) ), @@ -67,6 +70,8 @@ ( `Left ( `Label ( `id(`browse_allow_label), + // A header for a section to set up from which remote CUPS servers + // printer information is accepted: _("Accept Information from the Following Servers") ) ), @@ -74,6 +79,9 @@ ( `ComboBox ( `id(`browse_allow_combo_box), `opt(`notify), + // A header for a ComboBox from which the user can select + // a usual general setting from which remote CUPS servers + // printer information is accepted: _("Usual &General Setting"), [ `item( `id(`browse_allow_all), "all hosts" ), `item( `id(`browse_allow_local), "hosts in the local network" ), @@ -84,12 +92,18 @@ `Left ( `TextEntry ( `id(`browse_allow_input), + // A header for a TextEntry where the user can optionally + // enter specific IP addresses and/or network/netmask + // from where remote printer information is accepted: _("Optional Specific IP Addresses or &Network/Netmask") ) ), `Left ( `Label ( `id(`browse_allow_input_label), + // Label to show the syntax for the TextEntry where the user can + // enter specific IP addresses and/or network/netmask + // from where remote printer information is accepted: _("(each nnn.nnn.nnn.nnn or nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm separated by one space)") ) ) @@ -100,6 +114,8 @@ ( `RadioButton ( `id(`client_only_radio_button), `opt(`notify), + // A RadioButton to do all printing tasks directly + // only via one single remote CUPS server: _("Do All Your Printing Directly via &One Remote CUPS Server") ) ), @@ -109,6 +125,9 @@ ( 2, `TextEntry ( `id(`client_conf_server_name_input), + // A header for a TextEntry where the user can enter + // the one single remote CUPS server which is used + // to do all his printing tasks: _("&Hostname / IP Address") ) ), @@ -116,6 +135,8 @@ ( 1, `PushButton ( `id(`test_client_conf_server), + // A PushButton to test whether or not the one single remote CUPS server + // which is used to do all printing tasks is accessible: _("&Test Server") ) ), @@ -126,11 +147,15 @@ ), `VStretch(), `Frame - ( _("Use Another Print Server or Use a Network Printer Directly"), + ( // A caption for a Frame to set up to use another (i.e. non-CUPS) print server + // or to set up to use a network printer directly: + _("Use Another Print Server or Use a Network Printer Directly"), `Left ( `PushButton ( `id(`connection_wizard), - _("&Connection Wizard") + // Label of a PushButton to go to the "Connection Wizard" + // to specify the printer connection individually: + _("Connection &Wizard") ) ) ), @@ -418,9 +443,15 @@ 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_browse_allow - || current_browse_allow_input_value != initial_browse_allow_input_value - ) + if( current_browse_allow != initial_browse_allow ) + { printing_via_network_has_changed = true; + } + // Check if there are real changes in the values in browse_allow_input. + // Do not ignore changes in the case (e.g. from 'host.domain.com' to 'Host.Domain.com') + // because the user may like to have it exactly in cupsd.conf (even if actually case may not matter): + list< string > initial_browse_allow_input_set = toset( splitstring( initial_browse_allow_input_value, " " ) ); + list< string > current_browse_allow_input_set = toset( splitstring( current_browse_allow_input_value, " " ) ); + if( mergestring( current_browse_allow_input_set, "" ) != mergestring( initial_browse_allow_input_set, "" ) ) { printing_via_network_has_changed = true; } } @@ -694,6 +725,8 @@ ), " " ); + // Have a trailing space character so that the user can easily add something: + browse_allow_input_value = browse_allow_input_value + " "; 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 ); Modified: trunk/printer/src/sharing.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/sharing.ycp?rev=51967&r1=51966&r2=51967&view=diff ============================================================================== --- trunk/printer/src/sharing.ycp (original) +++ trunk/printer/src/sharing.ycp Wed Oct 8 12:10:28 2008 @@ -48,8 +48,8 @@ boolean initial_allow_local_network_access = false; boolean initial_publish_to_local_network = false; list< term > initial_interface_table_items = []; -string initial_allow_input = ""; -string initial_browse_address_input = ""; +string initial_allow_input_value = ""; +string initial_browse_address_input_value = ""; term widgetSharing = `VBox ( `VSpacing( 1 ), @@ -152,21 +152,21 @@ ( `id(`specific_addresses_frame), // A caption to allow remote access to local print queues // for hosts and/or networks specified in two TextEntries below: - _("Optional Specific IP Addresses or Networks"), + _("For Experts: Optional Specific IP Addresses or Networks"), `VBox ( `Left ( `TextEntry ( `id(`allow_input), // TextEntry to allow remote access to local print queues // for hosts and/or networks: - _("Allow remote access for &hosts or networks") + _("Allow remote access from those IP addresses or &network/netmask") ) ), `Left ( `Label ( `id(`allow_input_label), // Label to show the syntax for the TextEntry to allow remote access - // to local print queues for hosts and/or networks: + // to local print queues from IP addresses and/or networks: _("(each nnn.nnn.nnn.nnn or nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm separated by one space)") ) ), @@ -176,8 +176,8 @@ `TextEntry ( `id(`browse_address_input), // TextEntry to publish local print queues - // to hosts and/or networks: - _("Publish to hosts or network &broadcast addresses") + // to IP addresses and/or network broadcast addresses: + _("Publish to those IP addresses or network &broadcast addresses") ) ) ), @@ -265,8 +265,12 @@ y2milestone( "publish_to_local_network_check_box value: '%1'", publish_to_local_network ); interface_table_items = (list<term>)UI::QueryWidget( `interface_table, `Items ); y2milestone( "interface_table_items: %1", interface_table_items ); - string allow_values = ""; - string browse_address_values = ""; + string current_allow_input_value = (string)UI::QueryWidget( `id(`allow_input), `Value ); + y2milestone( "current_allow_input_value: %1", current_allow_input_value ); + string current_browse_address_input_value = (string)UI::QueryWidget( `id(`browse_address_input), `Value ); + y2milestone( "current_browse_address_input_value: %1", current_browse_address_input_value ); + string allow_values = current_allow_input_value; + string browse_address_values = current_browse_address_input_value; foreach( term interface_table_item, interface_table_items, { string interface_name = interface_table_item[1]:""; @@ -300,7 +304,8 @@ // because this is the safe setting (even when allow_values is not empty): if( deny_remote_access || ! allow_remote_access - || "" == allow_values + || "" == filterchars( allow_values, Printer::alnum_chars + "*" ) + || contains( splitstring( tolower( current_allow_input_value ), " " ), "none" ) ) { if( initial_deny_remote_access ) { // Nothing has changed: @@ -382,6 +387,19 @@ if( mergestring( interface_table_entries, "" ) != mergestring( initial_interface_table_entries, "" ) ) { sharing_has_changed = true; } + // Check if there are real changes in the values in allow_input and in browse_address_input. + // Do not ignore changes in the case (e.g. from 'host.domain.com' to 'Host.Domain.com') + // because the user may like to have it exactly in cupsd.conf (even if actually case may not matter): + list< string > initial_allow_input_set = toset( splitstring( initial_allow_input_value, " " ) ); + list< string > current_allow_input_set = toset( splitstring( current_allow_input_value, " " ) ); + if( mergestring( current_allow_input_set, "" ) != mergestring( initial_allow_input_set, "" ) ) + { sharing_has_changed = true; + } + list< string > initial_browse_address_input_set = toset( splitstring( initial_browse_address_input_value, " " ) ); + list< string > current_browse_address_input_set = toset( splitstring( current_browse_address_input_value, " " ) ); + if( mergestring( current_browse_address_input_set, "" ) != mergestring( initial_browse_address_input_set, "" ) ) + { sharing_has_changed = true; + } if( ! sharing_has_changed ) { // Nothing has changed: return true; @@ -611,26 +629,29 @@ initial_publish_to_local_network = false; UI::ChangeWidget( `publish_to_local_network_check_box, `Value, false ); initial_interface_table_items = []; - initial_allow_input = ""; - initial_browse_address_input = ""; + initial_allow_input_value = ""; + initial_browse_address_input_value = ""; // Split the allow_values list together with the browse_address_values list // into the different values for the different widgets in the dialog. // By default no remote access is allowed (see the defaults in widgetSharing) // but if there is at least one none-empty allow_value, remote access should be allowed // except when there is no remote Listen entry: + boolean none_empty_allow_values = false; + boolean allow_none = false; foreach( string allow_value, allow_values, { if( "" == filterchars( allow_value, Printer::alnum_chars ) ) { // Ignore an effectively empty allow_value: continue; } - if( listen_remote && initial_deny_remote_access ) - { UI::ChangeWidget( `deny_remote_access_radio_button, `Value, false ); - initial_deny_remote_access = false; - UI::ChangeWidget( `allow_remote_access_radio_button, `Value, true ); - initial_allow_remote_access = true; + none_empty_allow_values = true; + if( "none" == tolower( allow_value ) ) + { allow_none = true; } - if( "@LOCAL" == allow_value ) + // To be safe against any unexpected locale mess, I use tolower for both strings so that + // equal strings result true regardless of what tolower/toupper results in which locale + // instead of an asymmetric comparison like "@LOCAL" == toupper(allow_value): + if( tolower( "@LOCAL" ) == tolower( allow_value ) ) { UI::ChangeWidget( `allow_local_network_access_check_box, `Value, true ); initial_allow_local_network_access = true; // Check if this value appears also in the browse_address_values: @@ -640,7 +661,7 @@ } continue; } - if( issubstring( allow_value, "@IF" ) ) + if( issubstring( tolower( allow_value ), tolower( "@IF" ) ) ) { // The allow_value has the form '@IF(interface-name)' e.g. '@IF(eth1)'. // Check if this value appears also in the browse_address_values: string publish_via_this_interface = "no"; @@ -661,29 +682,43 @@ continue; } // When the allow_value is neither "@LOCAL" nor "@IF(...)" - // it is for the allow_input TextEntry: - initial_allow_input = initial_allow_input + allow_value; + // it is for the allow_input TextEntry (intentionally also if it is "none"). + // Have a trailing space character so that the user can easily add something: + initial_allow_input_value = initial_allow_input_value + allow_value + " "; } ); + // By default initial_deny_remote_access is true + // and initial_allow_remote_access is false (see above) + // and this is correct (i.e. it must not be changed) + // when the cupsd does not listen on a remote interface + // or when the allow_values are effectively empty + // or when one of the the allow_values is "none": + if( listen_remote && none_empty_allow_values && ! allow_none ) + { UI::ChangeWidget( `deny_remote_access_radio_button, `Value, false ); + initial_deny_remote_access = false; + UI::ChangeWidget( `allow_remote_access_radio_button, `Value, true ); + initial_allow_remote_access = true; + } foreach( string browse_address_value, browse_address_values, { if( "" == filterchars( browse_address_value, Printer::alnum_chars ) ) { // Ignore an effectively empty browse_address_value: continue; } - if( "@LOCAL" == browse_address_value ) + if( tolower( "@LOCAL" ) == tolower( browse_address_value ) ) { // Skip when the browse_address_value is "@LOCAL" // because this case is handled in the foreach for allow_values above: continue; } - if( issubstring( browse_address_value, "@IF" ) ) + if( issubstring( tolower( browse_address_value ), tolower( "@IF" ) ) ) { // Skip when the browse_address_value has the form '@IF(interface-name)' // because this case is handled in the foreach for allow_values above: continue; } // When the browse_address_value is neither "@LOCAL" nor "@IF(...)" - // it is for the browse_address_input TextEntry: - initial_browse_address_input = initial_browse_address_input + browse_address_value; + // it is for the browse_address_input TextEntry. + // Have a trailing space character so that the user can easily add something: + initial_browse_address_input_value = initial_browse_address_input_value + browse_address_value + " "; } ); y2milestone( "Initial interface_table_items: %1", interface_table_items ); @@ -691,9 +726,12 @@ initial_interface_table_items = interface_table_items; UI::ChangeWidget( `interface_table, `CurrentItem, -1 ); // Determine the currently available IPv4 (-family inet) network interfaces in the system. - // Omit loopback interfaces. + // Omit all non-eth* interfaces because loopback interfaces do not make sense here + // and ppp* interfaces are usually used for DSL and analog modems to access the + // untrusted Internet from which no remote access should be allowed by accident + // (the user can enter any interface manually if he knows what he does): available_interfaces = []; - if( Printerlib::ExecuteBashCommand( "ip -family inet -oneline link show | grep -v -i loopback | cut -s -d ':' -f 2 | tr -s '[:space:]' ' '" ) ) + if( Printerlib::ExecuteBashCommand( "ip -family inet -oneline link show | grep 'eth[0-9]' | cut -s -d ':' -f 2 | tr -s '[:space:]' ' '" ) ) { // The command outputs a line where multiple network interfaces are separated by space. // Remove empty or effectively empty entries (otherwise it would be something like ["", "eth0", "eth1"]): available_interfaces = filter( string interface_name, @@ -707,10 +745,10 @@ available_interfaces = []; } y2milestone( "available_interfaces: %1", available_interfaces ); - y2milestone( "Initial initial_allow_input: %1", initial_allow_input ); - UI::ChangeWidget( `id(`allow_input), `Value, initial_allow_input ); - y2milestone( "Initial initial_browse_address_input: %1", initial_browse_address_input ); - UI::ChangeWidget( `id(`browse_address_input), `Value, initial_browse_address_input ); + y2milestone( "Initial initial_allow_input_value: %1", initial_allow_input_value ); + UI::ChangeWidget( `id(`allow_input), `Value, initial_allow_input_value ); + y2milestone( "Initial initial_browse_address_input_value: %1", initial_browse_address_input_value ); + UI::ChangeWidget( `id(`browse_address_input), `Value, initial_browse_address_input_value ); y2milestone( "leaving initSharing" ); } Modified: trunk/printer/tools/modify_cupsd_conf URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/modify_cupsd_conf?rev=51967&r1=51966&r2=51967&view=diff ============================================================================== --- trunk/printer/tools/modify_cupsd_conf (original) +++ trunk/printer/tools/modify_cupsd_conf Wed Oct 8 12:10:28 2008 @@ -47,7 +47,10 @@ exit 2 fi -# Remove duplicates (ignore case) and remove duplicate, leading and trailing spaces: +# Remove duplicates (ignore case) and remove duplicate, leading and trailing spaces. +# Case is only ignored if there are duplicates (e.g. 'host.domain.com' and 'Host.Domain.com') +# but if there is e.g. only 'Host.Domain.com' it is written exactly this way to cupsd.conf +# because the user may like to have it exactly in cupsd.conf (even if actually case may not matter): VALUE="$( for V in $2 ; do echo $V ; done | sort -b -f -u | tr -s '[:space:]' ' ' | sed -e 's/ *$//' )" # Make a backup of /etc/cups/cupsd.conf if it would be changed: -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org