Author: jsmeix Date: Tue Oct 7 16:13:42 2008 New Revision: 51923 URL: http://svn.opensuse.org/viewcvs/yast?rev=51923&view=rev Log: Removed the too strict syntax tests for tools/modify_cupsd_conf so that any value in the cupsd.conf file is supported. Chnaged the "share printers" dialog so that any value for Allow and BrowseAddress in cupsd.conf is supported. Currently arbitrary values for Allow and BrowseAddress are not yet written to cupsd.conf (for tomorrow). Modified: trunk/printer/src/sharing.ycp trunk/printer/tools/modify_cupsd_conf Modified: trunk/printer/src/sharing.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/sharing.ycp?rev=51923&r1=51922&r2=51923&view=diff ============================================================================== --- trunk/printer/src/sharing.ycp (original) +++ trunk/printer/src/sharing.ycp Tue Oct 7 16:13:42 2008 @@ -41,7 +41,6 @@ boolean share_printers_dialog_is_useless = false; list< term > interface_table_items = []; -list< term > ip_table_items = []; list< string > available_interfaces = []; boolean sharing_has_changed = false; boolean initial_deny_remote_access = true; @@ -49,6 +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 = ""; term widgetSharing = `VBox ( `VSpacing( 1 ), @@ -147,60 +148,52 @@ ) ), `VSpacing( 1 ), - - // Have the IP table disabled until its functionality is implemented: `Frame - ( "This functionality is not yet implemented:", - `VBox - ( - - `Left - ( `Label - ( `id(`ip_table_label), - // A caption for a table to allow remote access to local print queues - // for hosts and/or networks specified in the table below: - _("For hosts / networks specified below") - ) - ), - `Table - ( `id(`ip_table), - `opt(`keepSorting), - `header - ( // A table column header where the column lists IP addresses: - _("IP address"), - // A table column header where the column shows whether or not - // local print queues are published by default - // via the IP address in the other table column: - _("Publish printers by default for this address") - ), - ip_table_items - ), - `Left - ( `HBox - ( `PushButton - ( `id(`add_ip), - // A PushButton label to add an IP address to the table which shows - // the IP addresses to allow remote access to local print queues: - _("A&dd") + ( `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"), + `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") + ) ), - `PushButton - ( `id(`edit_ip), - // A PushButton label to change an IP address in the table which shows - // the IP addresses to allow remote access to local print queues: - _("Ed&it") + `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: + _("(each nnn.nnn.nnn.nnn or nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm separated by one space)") + ) ), - `PushButton - ( `id(`delete_ip), - // A PushButton label to delete an IP address from the table which shows - // the IP addresses to allow remote access to local print queues: - _("De&lete") + `Left + ( `HBox + ( `HSpacing( 2 ), + `TextEntry + ( `id(`browse_address_input), + // TextEntry to publish local print queues + // to hosts and/or networks: + _("Publish to hosts or network &broadcast addresses") + ) + ) + ), + `Left + ( `HBox + ( `HSpacing( 2 ), + `Label + ( `id(`browse_address_input_label), + // Label to show the syntax for the TextEntry to to publish + // local print queues to hosts and/or networks: + _("(each nnn.nnn.nnn.nnn or nnn.nnn.nnn.255 separated by one space)") + ) + ) ) ) ) - - ) - ) - ) ), `VSpacing( 1 ) @@ -252,37 +245,6 @@ return interface_map; } -map showIPPopup(string device, boolean publish){ - map result = $[]; - UI::OpenDialog( `VBox( - `CheckBox(`id(`publish), _("&Publish printers by default via "), publish), - // translators: input field label for list of configured IPs - `InputField( `id(`device), _("Network &Address:"), device ), - `VSpacing(), - `HBox( - `PushButton( `id(`ok), Label::OKButton() ), - `PushButton( `id(`cancel), Label::CancelButton() ) - ) - )); - if(device!="") UI::ChangeWidget(`device, `Value, device); - while(true){ - any ret = UI::UserInput(); - if (ret==`cancel){ - result=nil; - break; - } - if (ret==`ok){ - publish = (boolean)UI::QueryWidget(`publish, `Value); - device = (string)UI::QueryWidget(`device, `Value); - result["device"]=device; - result["publish"]=publish ? "yes" : "no"; - break; - } - } - UI::CloseDialog(); - return result; -} - boolean ApplySharingSettings() { sharing_has_changed = false; // Get the actual settings and values from the dialog. @@ -558,16 +520,15 @@ UI::ChangeWidget( `add_interface, `Enabled, false ); UI::ChangeWidget( `edit_interface, `Enabled, false ); UI::ChangeWidget( `delete_interface, `Enabled, false ); - UI::ChangeWidget( `ip_table_label, `Enabled, false ); - UI::ChangeWidget( `ip_table, `Enabled, false ); - UI::ChangeWidget( `add_ip, `Enabled, false ); - UI::ChangeWidget( `edit_ip, `Enabled, false ); - UI::ChangeWidget( `delete_ip, `Enabled, false ); + UI::ChangeWidget( `specific_addresses_frame, `Enabled, false ); + UI::ChangeWidget( `allow_input, `Enabled, false ); + UI::ChangeWidget( `allow_input_label, `Enabled, false ); + UI::ChangeWidget( `browse_address_input, `Enabled, false ); + UI::ChangeWidget( `browse_address_input_label, `Enabled, false ); } // Regardless whether or not the "Share Printers" dialog is useless, // fill in the values of the current settings in the system: interface_table_items = []; - ip_table_items = []; // Determine the 'Listen' values in /etc/cups/cupsd.conf: // By default there is 'Listen localhost:631' and 'Listen /var/run/cups/cups.sock'. // 'Listen localhost' is mandatory (i.e. it is a broken config when it is missing). @@ -650,6 +611,8 @@ 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 = ""; // 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) @@ -657,7 +620,11 @@ // except when there is no remote Listen entry: foreach( string allow_value, allow_values, - { if( "" != allow_value && listen_remote ) + { 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 ); @@ -671,6 +638,7 @@ { UI::ChangeWidget( `publish_to_local_network_check_box, `Value, true ); initial_publish_to_local_network = true; } + continue; } if( issubstring( allow_value, "@IF" ) ) { // The allow_value has the form '@IF(interface-name)' e.g. '@IF(eth1)'. @@ -690,7 +658,32 @@ ) ); } + 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; + } + ); + 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 ) + { // 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" ) ) + { // 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; } ); y2milestone( "Initial interface_table_items: %1", interface_table_items ); @@ -714,14 +707,10 @@ available_interfaces = []; } y2milestone( "available_interfaces: %1", available_interfaces ); - - // Have the IP table disabled until its functionality is implemented: - UI::ChangeWidget( `ip_table_label, `Enabled, false ); - UI::ChangeWidget( `ip_table, `Enabled, false ); - UI::ChangeWidget( `add_ip, `Enabled, false ); - UI::ChangeWidget( `edit_ip, `Enabled, false ); - UI::ChangeWidget( `delete_ip, `Enabled, false ); - + 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( "leaving initSharing" ); } @@ -854,47 +843,6 @@ { y2error("Unproper index for current interface table item: %1", current_item); } break; - case `add_ip : - ret = showIPPopup("", false); - if (ret!=nil){ - list items = (list)UI::QueryWidget(`ip_table, `Items); - items=add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); - UI::ChangeWidget(`ip_table, `Items, items); - UI::ChangeWidget(`ip_table, `CurrentItem, current_item); - } - break; - - case `edit_ip : - current_item = (integer)UI::QueryWidget(`ip_table, `CurrentItem); - term this2 = (term)UI::QueryWidget(`ip_table, `Item(current_item)); - ret = showIPPopup((string)this2[1]:"", (this2[2]:"no"=="yes")); - if (ret!=nil){ - list items = []; - foreach(term oneItem, (list<term>)UI::QueryWidget(`ip_table, `Items), { - if (current_item != oneItem[0, 0]:-1){ - items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); - } else { - y2milestone("Changing item %1", oneItem); - items = add(items, `item(`id(size(items)), ret["device"]:"", ret["publish"]:"")); - } - }); - UI::ChangeWidget(`ip_table, `Items, items); - UI::ChangeWidget(`ip_table, `CurrentItem, current_item); - } - break; - case `delete_ip : - current_item = (integer)UI::QueryWidget(`ip_table, `CurrentItem); - if (current_item!=nil && current_item>-1){ - list items = []; - foreach(term oneItem, (list<term>)UI::QueryWidget(`ip_table, `Items), { - if (current_item != oneItem[0, 0]:-1){ - items = add(items, `item(`id(size(items)), oneItem[1]:"", oneItem[2]:"")); - } else y2milestone("Deleting item %1", oneItem); - - }); - UI::ChangeWidget(`ip_table, `Items, items); - } else y2error("Unproper index for current item: %1", current_item); - break; } } if( ! share_printers_dialog_is_useless ) @@ -917,30 +865,18 @@ UI::ChangeWidget(`add_interface, `Enabled, remote_access); UI::ChangeWidget(`edit_interface, `Enabled, remote_access); UI::ChangeWidget(`delete_interface, `Enabled, remote_access); - UI::ChangeWidget(`ip_table_label, `Enabled, remote_access); - UI::ChangeWidget(`ip_table, `Enabled, remote_access); - UI::ChangeWidget(`add_ip, `Enabled, remote_access); - UI::ChangeWidget(`edit_ip, `Enabled, remote_access); - UI::ChangeWidget(`delete_ip, `Enabled, remote_access); + UI::ChangeWidget(`specific_addresses_frame, `Enabled, remote_access); + UI::ChangeWidget(`allow_input, `Enabled, remote_access); + UI::ChangeWidget(`allow_input_label, `Enabled, remote_access); + UI::ChangeWidget(`browse_address_input, `Enabled, remote_access); + UI::ChangeWidget(`browse_address_input_label, `Enabled, remote_access); if( remote_access ) { boolean interface_modify_buttons = true; if( 0 == size((list)UI::QueryWidget(`interface_table, `Items)) ) interface_modify_buttons = false; UI::ChangeWidget(`edit_interface, `Enabled, interface_modify_buttons); UI::ChangeWidget(`delete_interface, `Enabled, interface_modify_buttons); - boolean ip_modify_buttons = true; - if( 0 == size((list)UI::QueryWidget(`ip_table, `Items)) ) ip_modify_buttons = false; - UI::ChangeWidget(`edit_ip, `Enabled, ip_modify_buttons); - UI::ChangeWidget(`delete_ip, `Enabled, ip_modify_buttons); } } - - // Have the IP table disabled until its functionality is implemented: - UI::ChangeWidget( `ip_table_label, `Enabled, false ); - UI::ChangeWidget( `ip_table, `Enabled, false ); - UI::ChangeWidget( `add_ip, `Enabled, false ); - UI::ChangeWidget( `edit_ip, `Enabled, false ); - UI::ChangeWidget( `delete_ip, `Enabled, false ); - return nil; } Modified: trunk/printer/tools/modify_cupsd_conf URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/modify_cupsd_conf?rev=51923&r1=51922&r2=51923&view=diff ============================================================================== --- trunk/printer/tools/modify_cupsd_conf (original) +++ trunk/printer/tools/modify_cupsd_conf Tue Oct 7 16:13:42 2008 @@ -34,8 +34,10 @@ echo "BrowseAddress [ @LOCAL | @IF(name) | host-address | broadcast-address ] | BrowseAddress none" 1>&2 echo "e.g.: BrowseAddress '@LOCAL @IF(eth1) 192.168.100.1 192.168.200.255'" 1>&2 echo " BrowseAddress none (to send no browse packets, i.e. no BrowseAddress line)" 1>&2 - echo "There is a strict syntax for keywords and values:" 1>&2 - echo "Case matters." 1>&2 + echo "For the syntax for keywords and values see 'man cupsd.conf'" 1>&2 + echo "and http://www.cups.org/documentation.php/ref-cupsd-conf.html" 1>&2 + echo "In case of ambiguity use the syntax which is described above." 1>&2 + echo "Usually case matters, in particular for special keywords like On Off @LOCAL @IF none all." 1>&2 echo "Multiple values for a keyword must be separated by space." 1>&2 exit 1 fi @@ -67,12 +69,7 @@ # Function to deal with 'Browsing [On|Off]' Browsing() { if test -n "$VALUE" - then # If a value was specified, only 'On' or 'Off' (case sensitive) are allowed: - if ! test "On" = "$VALUE" -o "Off" = "$VALUE" - then echo "Only '$KEY [ On | Off ]' is supported." 1>&2 - exit 5 - fi - # Try to substitute an existing active Browsing line (ignore case). + then # Try to substitute an existing active Browsing line (ignore case). # (If there is more than one active Browsing line it is a broken config file): sed -i -e "s/^[[:space:]]*$KEY.*/$KEY $VALUE/i" $CUPSDCONF # There may exist no Browsing line: @@ -108,20 +105,7 @@ # Function to deal with 'BrowseAllow [ all | @LOCAL | host-address | network-address/netmask ] | BrowseAllow none' BrowseAllow() { if test -n "$VALUE" - then # If a value was specified, only 'all' or 'none' or '@LOCAL' (case sensitive) - # or one or more IP-addresses are allowed: - if ! test "none" = "$VALUE" - then for V in $VALUE - do if ! test "all" = "$V" -o "@LOCAL" = "$V" - then # Test if value matches to IP-address syntax: - if ! echo "$V" | egrep -q '^([0-9]{1,3}\.){3}[0-9]{1,3}(/([0-9]{1,2})|/(([0-9]{1,3}\.){3}[0-9]{1,3}))?$' - then echo "Only '$KEY [ all | @LOCAL | host-address | network-address/netmask ]' or '$KEY none' is supported." 1>&2 - exit 5 - fi - fi - done - fi - # Set 'BrowseOrder allow,deny' to deny browse packets by default + then # Set 'BrowseOrder allow,deny' to deny browse packets by default # and then allow them from certain sources via BrowseAllow entries # and finally deny from certain sources via BrowseDeny entries. # All existing active BrowseOrder lines are removed (ignore case). @@ -178,19 +162,7 @@ # Function to deal with 'Listen [ all | network-address ] | Listen localhost' Listen() { if test -n "$VALUE" - then # If a value was specified, only 'all' or 'localhost' or one or more network-addresses are allowed: - if ! test "localhost" = "$VALUE" - then for V in $VALUE - do if ! test "all" = "$V" - then # Test if value matches to IP-address syntax: - if ! echo "$V" | egrep -q '^([0-9]{1,3}\.){3}[0-9]{1,3}$' - then echo "Only '$KEY [ all | network-address ]' or '$KEY localhost' is supported." 1>&2 - exit 5 - fi - fi - done - fi - # Determine if it listens on the domain socket: + then # Determine if it listens on the domain socket: LISTEN_DOMAIN_SOCKET_LINE_CONTENT="$( grep -i '^[[:space:]]*Listen.*/cups.sock' $CUPSDCONF | head -n 1 )" # All existing active Port lines are deactivated (ignore case). # Those lines are not removed because YaST does not support Port lines @@ -256,23 +228,7 @@ # Function to deal with 'Allow [ all | @LOCAL | @IF(name) | host-address | network-address/netmask ] | Allow none' Allow() { if test -n "$VALUE" - then # If a value was specified, only 'all' or 'none' or '@LOCAL' (case sensitive) - # or '@IF(name)' or one or more IP-addresses are allowed: - if ! test "none" = "$VALUE" - then for V in $VALUE - do if ! test "all" = "$V" -o "@LOCAL" = "$V" - then # Test if value matches to @IF(name) syntax: - if ! echo "$V" | egrep -q '^@IF\([^)]*\)$' - then # Test if value matches to IP-address syntax: - if ! echo "$V" | egrep -q '^([0-9]{1,3}\.){3}[0-9]{1,3}(/([0-9]{1,2})|/(([0-9]{1,3}\.){3}[0-9]{1,3}))?$' - then echo "Only '$KEY [ all | @LOCAL | @IF(name) | host-address | network-address/netmask ]' or '$KEY none' is supported." 1>&2 - exit 5 - fi - fi - fi - done - fi - # Determine where the (first) root location starts (ignore case and ignore spaces): + then # Determine where the (first) root location starts (ignore case and ignore spaces): ROOT_LOCATION_LINE_NUMBER="$( sed -n -e '/[[:space:]]*<[[:space:]]*Location[[:space:]]*\/[[:space:]]*>/I=' $CUPSDCONF | head -n 1 )" # Remove all root locations (ignore case and ignore spaces). # (If there is more than one root location it is a broken config file). @@ -324,23 +280,7 @@ # Function to deal with 'BrowseAddress [ @LOCAL | @IF(name) | host-address | broadcast-address ] | BrowseAddress none' BrowseAddress() { if test -n "$VALUE" - then # If a value was specified, only 'none' (case sensitive) - # or '@IF(name)' or one or more IP-addresses are allowed: - if ! test "none" = "$VALUE" - then for V in $VALUE - do if ! test "@LOCAL" = "$V" - then # Test if value matches to @IF(name) syntax: - if ! echo "$V" | egrep -q '^@IF\([^)]*\)$' - then # Test if value matches to IP-address syntax: - if ! echo "$V" | egrep -q '^([0-9]{1,3}\.){3}[0-9]{1,3}$' - then echo "Only '$KEY [ @LOCAL | @IF(name) | host-address | broadcast-address ]' or '$KEY none' is supported." 1>&2 - exit 5 - fi - fi - fi - done - fi - # All existing active BrowseAddress lines are removed (ignore case). + then # All existing active BrowseAddress lines are removed (ignore case). # Those lines can be removed because YaST supports BrowseAddress lines # (YaST shows BrowseAddress entries in the "share printers" dialog): sed -i -e '/^[[:space:]]*BrowseAddress.*/Id' $CUPSDCONF -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org