Author: jsmeix
Date: Fri Aug 29 14:48:36 2008
New Revision: 50481
URL: http://svn.opensuse.org/viewcvs/yast?rev=50481&view=rev
Log:
- Some code cleanup.
- 2.17.7
Modified:
trunk/printer/VERSION
trunk/printer/package/yast2-printer.changes
trunk/printer/src/Printerlib.ycp
trunk/printer/src/basicmodify.ycp
trunk/printer/src/overview.ycp
trunk/printer/src/printingvianetwork.ycp
trunk/printer/tools/cups_client_only
Modified: trunk/printer/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/VERSION (original)
+++ trunk/printer/VERSION Fri Aug 29 14:48:36 2008
@@ -1 +1 @@
-2.17.6
+2.17.7
Modified: trunk/printer/package/yast2-printer.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/package/yast2-printer.changes (original)
+++ trunk/printer/package/yast2-printer.changes Fri Aug 29 14:48:36 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Fri Aug 29 14:45:28 CEST 2008 - jsmeix@suse.de
+
+- Some code cleanup.
+- 2.17.7
+
+-------------------------------------------------------------------
Thu Aug 28 18:19:32 CEST 2008 - jsmeix@suse.de
- Fixed build (new scripts were not packaged).
Modified: trunk/printer/src/Printerlib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/src/Printerlib.ycp (original)
+++ trunk/printer/src/Printerlib.ycp Fri Aug 29 14:48:36 2008
@@ -10,22 +10,6 @@
// rpm -qlp /work/CDs/all/full-sle10-sp2*/suse/*/yast2-printer.rpm | grep '/YaST2/bin/' | grep -v '/usr/lib/YaST2/bin/'
global string yast_bin_dir = "/usr/lib/YaST2/bin/";
-// By default there is no active "ServerName" entry in /etc/cups/client.conf:
-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 "BrowseAllow all" in /etc/cups/cupsd.conf
-// which is even the fallback if there is no "BrowseAllow" entry at all
-// or when the "BrowseAllow" entries are deactivated by a leading '#' character.
-global string cupsd_conf_browse_allow = "all";
-
// 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.
@@ -57,41 +41,97 @@
return true;
}
-global map operation_policy = $[];
-
-global map cups_autoconfig = $[];
+// By default there is no active "ServerName" entry in /etc/cups/client.conf:
+global string client_conf_server_name = "";
+global boolean client_only = false;
-global void Read()
-{ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf Browsing" ) )
- { // Ignore when this command fails and use the fallback "Printerlib::browsing_on = true"
- string browsing = tolower( Printerlib::result["stdout"]:"On" );
- if( "off" == browsing || "no" == browsing )
- { Printerlib::browsing_on = false;
- }
- }
- // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' values in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf BrowseAllow" ) )
- { // Ignore when this command fails and use the fallback "Printerlib::cupsd_conf_browse_allow = "all"
- Printerlib::cupsd_conf_browse_allow = Printerlib::result["stdout"]:"all";
- }
- // Determine the 'ServerName' value in /etc/cups/client.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only" ) )
- { // Ignore when this command fails and use the fallback "Printerlib::client_only = false"
- // and the fallback "Printerlib::client_conf_server_name = ""
- Printerlib::client_conf_server_name = Printerlib::result["stdout"]:"";
- if( "" != Printerlib::client_conf_server_name
- && "localhost" != Printerlib::client_conf_server_name )
- { // Note that even 'localhost' is a valid ServerName value
+global boolean DetermineClientOnly()
+{ // Determine the 'ServerName' value in /etc/cups/client.conf:
+ if( ExecuteBashCommand( yast_bin_dir + "cups_client_only" ) )
+ { client_conf_server_name = result["stdout"]:"";
+ if( "" != client_conf_server_name
+ && "localhost" != client_conf_server_name
+ && "127.0.0.1" != client_conf_server_name )
+ { // Note that even 'localhost' or '127.0.0.1' is a valid ServerName value
// which is used to force client tools (e.g. lpadmin, lpinfo, lpstat)
- // to ask the local cupsd via the IPP port on localhost (localhost:631)
+ // to ask the local cupsd via the IPP port on localhost (127.0.0.1:631)
// and not via the domain socket (/var/run/cups/cups.sock) because
// the latter failed in the past for certain third-party clients (e.g. Java).
// If the ServerName value in /etc/cups/client.conf is 'localhost'
// it is actually no client-only config because the local cupsd is used.
- Printerlib::client_only = true;
+ client_only = true;
+ }
+ else
+ { client_only = false;
}
}
+ else
+ { client_conf_server_name = "";
+ client_only = false;
+ }
+ // Ignore when it fails:
+ return true;
+}
+
+// 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;
+
+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;
+ }
+ else
+ { browsing_on = true;
+ }
+ }
+ // Ignore when it fails:
+ return true;
+}
+
+// By default there is "BrowseAllow all" in /etc/cups/cupsd.conf
+// which is even the fallback if there is no "BrowseAllow" entry at all
+// or when the "BrowseAllow" entries are deactivated by a leading '#' character.
+// Multiple BrowseAllow lines are allowed, e.g.:
+// BrowseAllow from @LOCAL
+// BrowseAllow from 192.168.200.1
+// BrowseAllow from 192.168.100.0/255.255.255.0
+// so that each BrowseAllow line value is stored as one string
+// in the cupsd_conf_browse_allow list of strings:
+global list< string > cupsd_conf_browse_allow = [ "all" ];
+
+global boolean DetermineBrowseAllow()
+{ // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' values in /etc/cups/cupsd.conf:
+ if( ExecuteBashCommand( yast_bin_dir + "modify_cupsd_conf BrowseAllow" ) )
+ { // The command outputs a line where multiple BrowseAllow values are separated by space
+ // but possible duplicate BrowseAllow values are not removed in the command output:
+ cupsd_conf_browse_allow = toset( splitstring( Printerlib::result["stdout"]:"all", " " ) );
+ }
+ else
+ { cupsd_conf_browse_allow = [ "all" ];
+ }
+ // Ignore when it fails:
+ return true;
+}
+
+global map operation_policy = $[];
+
+global map cups_autoconfig = $[];
+
+global void Read()
+{ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf and ignore when it fails:
+ DetermineBrowsing();
+ // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]'
+ // values in /etc/cups/cupsd.conf and ignore when it fails:
+ DetermineBrowseAllow();
+ // Determine the 'ServerName' value in /etc/cups/client.conf and ignore when it fails:
+ DetermineClientOnly();
// Read cups-autoconfiguration settings:
cups_autoconfig = (map)SCR::Read(.etc.cups-auto.all);
y2internal("read cups-auto %1", cups_autoconfig);
Modified: trunk/printer/src/basicmodify.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/basicmodify.ycp?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/src/basicmodify.ycp (original)
+++ trunk/printer/src/basicmodify.ycp Fri Aug 29 14:48:36 2008
@@ -446,10 +446,13 @@
Wizard::EnableNextButton();
}
else
- { Popup::TimedMessage( // Message of a Popup where %1 will be replaced by the queue name:
- sformat( _("Nothing changed for queue %1."), name ),
- 2
+ { Popup::ShowFeedback( // No title for such a simple feedback message:
+ "",
+ // Message of a Popup::ShowFeedback when nothing was changed:
+ _("Nothing changed.")
);
+ sleep( 1000 );
+ Popup::ClearFeedback();
}
// Exit this dialog in any case:
break;
Modified: trunk/printer/src/overview.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/overview.ycp?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/src/overview.ycp (original)
+++ trunk/printer/src/overview.ycp Fri Aug 29 14:48:36 2008
@@ -87,14 +87,11 @@
// 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:
+ // with an active ServerName entry which is not "localhost" or "127.0.0.1".
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( Printerlib::client_conf_server_name == "localhost" )
- {
- local_content_selected = true;
+ { if( Printerlib::client_conf_server_name == "localhost"
+ || Printerlib::client_conf_server_name == "127.0.0.1" )
+ { local_content_selected = true;
remote_content_selected = true;
}
else
@@ -104,11 +101,9 @@
}
}
if( local_cupsd_required && ! local_cupsd_accessible )
- {
- Popup::ErrorDetails( _("Start local running CUPS daemon"),
- _("A local running CUPS daemon is needed for your setup.")
- );
-
+ { Popup::ErrorDetails( _("Start local running CUPS daemon"),
+ _("A local running CUPS daemon is needed for your setup.")
+ );
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
@@ -180,21 +175,20 @@
_("Do not delete it"),
`focus_no
))
- {
- // To be safe invalidate Printer::selected_queues_index in any case:
- Printer::selected_queues_index = -1;
- y2milestone( "To be deleted:'%1', selected_queue_index = %2", queue_name, selected_queue_index );
- if( ! Printer::DeleteQueue( queue_name ) )
- { Popup::Error( // Message of a Popup::Error
- // where %1 will be replaced by the queue name.
- // Only a simple message because before the function Printer::DeleteQueue
- // was called and this function would have shown more specific messages.
- sformat( _("Failed to delete queue %1."), queue_name )
- );
- }
- // Re-run the OverviewDialog (with a re-created list of queues) via the sequencer:
- return `delete;
- }
+ { // To be safe invalidate Printer::selected_queues_index in any case:
+ Printer::selected_queues_index = -1;
+ y2milestone( "To be deleted:'%1', selected_queue_index = %2", queue_name, selected_queue_index );
+ if( ! Printer::DeleteQueue( queue_name ) )
+ { Popup::Error( // Message of a Popup::Error
+ // where %1 will be replaced by the queue name.
+ // Only a simple message because before the function Printer::DeleteQueue
+ // was called and this function would have shown more specific messages.
+ sformat( _("Failed to delete queue %1."), queue_name )
+ );
+ }
+ // Re-run the OverviewDialog (with a re-created list of queues) via the sequencer:
+ return `delete;
+ }
}
if (event["EventReason"]:"" == "Activated" && event["ID"]:nil == `test){
@@ -226,11 +220,12 @@
return nil;
}
if( "local" == Printer::queues[selected_queue_index,"config"]:"remote" )
- Printer::selected_queues_index = selected_queue_index;
+ { Printer::selected_queues_index = selected_queue_index;
+ }
if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lp -d '"
- + queue_name
- + "' -o page-label=\"Testprint:$(hostname)\" /usr/share/cups/data/testprint.ps"
- )
+ + queue_name
+ + "' -o page-label=\"Testprint:$(hostname)\" /usr/share/cups/data/testprint.ps"
+ )
)
{ Popup::Error( // Message of a Popup::Error
// where %1 will be replaced by the queue name.
@@ -251,18 +246,20 @@
if (event["EventReason"]:"" == "Activated" && event["ID"]:nil == `add){
// client only
- if( Printerlib::client_only && Printerlib::client_conf_server_name != "localhost" )
+ if( Printerlib::client_only
+ && Printerlib::client_conf_server_name != "localhost"
+ && Printerlib::client_conf_server_name != "127.0.0.1" )
{ 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( ! Printerlib::ExecuteBashCommand( "sed -i.yast2.save -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee]/#ServerName/' /etc/cups/client.conf" ) )
+ // Remove the 'ServerName' entry in /etc/cups/client.conf:
+ 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 disable the 'ServerName' entry in /etc/cups/client.conf")
+ _("Failed to remove the 'ServerName' entry in /etc/cups/client.conf")
);
return nil;
}
Modified: trunk/printer/src/printingvianetwork.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printingvianetwork.ycp?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/src/printingvianetwork.ycp (original)
+++ trunk/printer/src/printingvianetwork.ycp Fri Aug 29 14:48:36 2008
@@ -41,101 +41,170 @@
include "printer/helps.ycp";
-term widgetNetworkPrinting =
- `VBox( `VStretch(),
- `Frame( _("Use CUPS to Print Via Network"),
- `RadioButtonGroup( `id(`browsing_or_client_only_check_boxs),
- `VBox( `Left( `RadioButton( `id(`cupsd_conf_browsing_off_radio_button),
- `opt(`notify),
- _("&Do not Receive Printer Information from Remote CUPS servers")
- )
- ),
- `Left( `RadioButton( `id(`cupsd_conf_browsing_on_radio_button),
- `opt(`notify),
- _("Receive Printer &Information from Remote CUPS servers")
- )
- ),
- `HBox( `HSpacing( 3 ),
- `TextEntry( `id(`cupsd_conf_browse_allow_input),
- _("Accept Information from those &Servers (separated by a space)")
- )
- ),
- `VSpacing( 1 ),
- `Left( `RadioButton( `id(`client_only_radio_button),
- `opt(`notify),
- _("Do All Your Printing Directly via &One Remote CUPS Server")
- )
- ),
- `HBox( `HSpacing( 3 ),
- `HWeight( 2,
- `TextEntry( `id(`client_conf_server_name_input),
- _("&Hostname / IP Address")
- )
- ),
- `HWeight( 1,
- `PushButton( `id(`test_client_conf_server),
- _("&Test Server")
- )
- ),
- `HStretch()
- )
- )
- )
+boolean something_has_changed = false;
+boolean cupsd_restart_required = false;
+boolean cupsd_start_required = false;
+boolean cupsd_stop_required = false;
+
+boolean ApplyNetworkPrintingSettings()
+{ if( ! something_has_changed )
+ { y2milestone( "Nothing changed in 'Printing via Network' dialog." );
+ Popup::ShowFeedback( // No title for such a simple feedback message:
+ "",
+ // Message of a Popup::ShowFeedback when nothing was changed:
+ _("Nothing changed.")
+ );
+ sleep( 1000 );
+ Popup::ClearFeedback();
+ return true;
+ }
+ y2milestone( "Writing 'NetworkPrinting' settings to the system." );
+ // Nothing implemented yet:
+ Popup::AnyMessage( // Header of a Popup::AnyMessage when "ApplyNetworkPrintingSettings" is called:
+ _("Not yet implemented"),
+ // Body of a Popup::AnyMessage when the "ApplyNetworkPrintingSettings" is called:
+ _("Writing the settings to the system is not yet implemented.")
+ );
+ return false;
+}
+
+term widgetNetworkPrinting = `VBox
+ ( `VStretch(),
+ `Frame
+ ( _("Use CUPS to Print Via Network"),
+ `RadioButtonGroup
+ ( `id(`browsing_or_client_only_check_boxs),
+ `VBox
+ ( `Left
+ ( `RadioButton
+ ( `id(`cupsd_conf_browsing_off_radio_button),
+ `opt(`notify),
+ _("&Do not Receive Printer Information from Remote CUPS servers")
+ )
+ ),
+ `Left
+ ( `RadioButton
+ ( `id(`cupsd_conf_browsing_on_radio_button),
+ `opt(`notify),
+ _("Receive Printer &Information from Remote CUPS servers")
+ )
+ ),
+ `HBox
+ ( `HSpacing( 3 ),
+ `VBox
+ ( `Left
+ ( `Label
+ ( `id(`cupsd_conf_browse_allow_label),
+ _("Accept Information from the Following Servers")
+ )
+ ),
+ `Left
+ ( `ComboBox
+ ( `id(`cupsd_conf_browse_allow_combo_box),
+ _("Usual &General Setting"),
+ [ `item( `id(`browse_allow_local), "hosts in the local network" ),
+ `item( `id(`browse_allow_all), "all hosts" )
+ ]
+ )
+ ),
+ `Left
+ ( `TextEntry
+ ( `id(`cupsd_conf_browse_allow_input),
+ _("Specific IP Addresses or &Network/Netmask (separated by space)")
+ )
+ )
+ )
+ ),
+ `VSpacing( 1 ),
+ `Left
+ ( `RadioButton
+ ( `id(`client_only_radio_button),
+ `opt(`notify),
+ _("Do All Your Printing Directly via &One Remote CUPS Server")
+ )
+ ),
+ `HBox
+ ( `HSpacing( 3 ),
+ `HWeight
+ ( 2,
+ `TextEntry
+ ( `id(`client_conf_server_name_input),
+ _("&Hostname / IP Address")
+ )
+ ),
+ `HWeight
+ ( 1,
+ `PushButton
+ ( `id(`test_client_conf_server),
+ _("&Test Server")
+ )
+ ),
+ `HStretch()
+ )
+ )
+ )
),
- `VStretch(),
- `Frame( _("Use Another Print Server or Use a Network Printer Directly"),
- `Left( `PushButton( `id(`connection_wizard),
- _("&Connection Wizard")
- )
- )
+ `VStretch(),
+ `Frame
+ ( _("Use Another Print Server or Use a Network Printer Directly"),
+ `Left
+ ( `PushButton
+ ( `id(`connection_wizard),
+ _("&Connection Wizard")
+ )
+ )
),
- `VStretch()
- );
+ `VStretch(),
+ `Right
+ ( `PushButton
+ ( `id(`apply),
+ _("Apply")
+ )
+ )
+ );
-void initNetworkPrinting(string key)
+void initNetworkPrinting( string key )
{ y2milestone( "entering initNetworkPrinting with key '%1'", key );
- // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf Browsing" ) )
- { // Ignore when this command fails and use initially the fallback "Printerlib::browsing_on = true"
- string browsing = tolower( Printerlib::result["stdout"]:"On" );
- if( "off" == browsing || "no" == browsing )
- { Printerlib::browsing_on = false;
- }
- else
- { Printerlib::browsing_on = true;
- }
- }
- // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' values in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf BrowseAllow" ) )
- { // Ignore when this command fails and use initially the fallback "Printerlib::cupsd_conf_browse_allow = "all"
- Printerlib::cupsd_conf_browse_allow = Printerlib::result["stdout"]:"all";
- }
- // Determine the 'ServerName' value in /etc/cups/client.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only" ) )
- { // Ignore when this command fails and use initially the fallback "Printerlib::client_only = false"
- // and the initiall fallback "Printerlib::client_conf_server_name = ""
- Printerlib::client_conf_server_name = Printerlib::result["stdout"]:"";
- if( "" != Printerlib::client_conf_server_name
- && "localhost" != Printerlib::client_conf_server_name )
- { // Note that even 'localhost' is a valid ServerName value
- // which is used to force client tools (e.g. lpadmin, lpinfo, lpstat)
- // to ask the local cupsd via the IPP port on localhost (localhost:631)
- // and not via the domain socket (/var/run/cups/cups.sock) because
- // the latter failed in the past for certain third-party clients (e.g. Java).
- // If the ServerName value in /etc/cups/client.conf is 'localhost'
- // it is actually no client-only config because the local cupsd is used.
- Printerlib::client_only = true;
- }
- else
- { Printerlib::client_only = false;
- }
- }
+ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf and ignore when it fails:
+ Printerlib::DetermineBrowsing();
+ // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]'
+ // values in /etc/cups/cupsd.conf and ignore when it fails:
+ Printerlib::DetermineBrowseAllow();
+ // Determine the 'ServerName' value in /etc/cups/client.conf and ignore when it fails:
+ 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 );
+ // When by accident "all" and "@LOCAL" were set as BrowseAllow values,
+ // the "@LOCAL" entry is preselected in cupsd_conf_browse_allow_combo_box
+ // because this is the more secure setting:
+ if( contains( Printerlib::cupsd_conf_browse_allow, "all" ) )
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_all) );
+ }
+ if( contains( Printerlib::cupsd_conf_browse_allow, "@LOCAL" ) )
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_local) );
+ }
UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false );
- UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Value, Printerlib::cupsd_conf_browse_allow );
+ // The preset entry in cupsd_conf_browse_allow_input field
+ // should not contain "all" or "@LOCAL" because those are
+ // already selectable via cupsd_conf_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,
+ Printerlib::cupsd_conf_browse_allow,
+ { value = tolower( value ) ;
+ return( "all" != value
+ && "@local" != value
+ && "none" != value
+ );
+ }
+ ),
+ " "
+ );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Value, cupsd_conf_browse_allow_input_value );
UI::ChangeWidget( `id(`client_only_radio_button), `Value, false );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Value, Printerlib::client_conf_server_name );
@@ -152,8 +221,13 @@
}
else
{ UI::ChangeWidget( `id(`connection_wizard), `Enabled, true );
- if( Printerlib::browsing_on )
+ // If "none" is present as a BrowseAllow value, no 'Browsing On' widget is enabled:
+ if( Printerlib::browsing_on
+ && ! contains( Printerlib::cupsd_conf_browse_allow, "none" )
+ )
{ 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 );
UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true );
}
else
@@ -163,30 +237,45 @@
y2milestone( "leaving initNetworkPrinting" );
}
-symbol handleNetworkPrinting(string key, map event)
+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_on_radio_button == event["ID"]:nil )
- { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true );
+ { 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(`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 == event["ID"]:nil )
- { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, 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(`cupsd_conf_browse_allow_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_radio_button == event["ID"]:nil )
- { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, 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(`cupsd_conf_browse_allow_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( "Activated" == event["EventReason"]:"" )
- { if( `connection_wizard == event["ID"]:nil )
+ { 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( `connection_wizard == event["ID"]:nil )
{ return `connection_wizard;
}
}
@@ -195,12 +284,21 @@
return nil;
}
-void storeNetworkPrinting(string key, map event)
+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.")
+ );
+ }
y2milestone( "leaving storeNetworkPrinting" );
}
+
+
/**
* Printing via network dialog
* @return dialog result
Modified: trunk/printer/tools/cups_client_only
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/cups_client_only?rev=50481&r1=50480&r2=50481&view=diff
==============================================================================
--- trunk/printer/tools/cups_client_only (original)
+++ trunk/printer/tools/cups_client_only Fri Aug 29 14:48:36 2008
@@ -9,15 +9,18 @@
export LANG="POSIX"
umask 022
-SERVERNAME="$1"
+# When 'localhost' or its IP-address is to be set,
+# it is unified so that only 'localhost' or '127.0.0.1' are set
+# (but not stuff like 'LocalHost' or '127.000.000.001').
+SERVERNAME="$( echo $1 | sed -e 's/localhost/localhost/i' -e 's/127\.0*0\.0*0\.0*1/127.0.0.1/' )"
if test -n "$SERVERNAME"
then # When a SERVERNAME is specified, set it in /etc/cups/client.conf
# if SERVERNAME is not the magic word 'none' which
# is used to only remove all active ServerName entries.
- # Note that even 'localhost' is a valid entry there
+ # Note that even 'localhost' or '127.0.0.1' is a valid entry there
# which is used to force client tools (e.g. lpadmin, lpinfo, lpstat)
- # to ask the local cupsd via the IPP port on localhost (localhost:631)
+ # to ask the local cupsd via the IPP port on localhost (127.0.0.1:631)
# and not via the domain socket (/var/run/cups/cups.sock) because
# the latter failed in the past for certain third-party clients (e.g. Java).
# Note that (according to Michael Sweet) it is not a supported configuration
@@ -45,7 +48,10 @@
# the output is the empty string (i.e. nothing at all - not even a '\n' character).
# The 'tr ... [:blank:]' makes sure that all active ServerName entries
# are found if there is more than one which is a broken config.
-SERVERNAME="$( grep -i '^ServerName ' /etc/cups/client.conf | tr -s '[:blank:]' ' ' | cut -s -d' ' -f2 | tr -s '\n' ' ' | sed -e 's/ *$//' )"
+# Trailing spaces are removed and when 'localhost' or its IP-address is set,
+# it is unified so that YaST only needs to test for 'localhost' and '127.0.0.1'
+# (but not for stuff like 'LocalHost' or '127.000.000.001').
+SERVERNAME="$( grep -i '^ServerName ' /etc/cups/client.conf | tr -s '[:blank:]' ' ' | cut -s -d' ' -f2 | tr -s '\n' ' ' | sed -e 's/ *$//' -e 's/localhost/localhost/i' -e 's/127\.0*0\.0*0\.0*1/127.0.0.1/' )"
echo -n "$SERVERNAME"
# For a nicer output on a terminal where stdout and stderr is mixed up,
# output a '\n' on stderr to get subsequent stuff (e.g. the shell prompt
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org