Author: jsmeix
Date: Thu Mar 18 15:40:13 2010
New Revision: 61386
URL: http://svn.opensuse.org/viewcvs/yast?rev=61386&view=rev
Log:
Cleaned up the AutoYaST printer client according to
bnc#588679 up to comment #5 which means:
Now there is verbatim cupsd.conf and client.conf
as XML CDATA in the AutoYaST control file.
The new AutoYaST map for printer settings is
$[ "cupsd_conf_content" :
$[ "file_contents" :
"string content of /etc/cups/cupds.conf"
],
"client_conf_content" :
$[ "file_contents" :
"string content of /etc/cups/client.conf"
]
]
This results the new AutoYaST control file structure
<printer>
<![CDATA[
... verbatim content of /etc/cups/client.conf ...
]]>
<![CDATA[
... verbatim content of /etc/cups/cupsd.conf ...
]]>
</printer>
Read and write of /etc/cups/cupsd.conf and
/etc/cups/client.conf is now implemented directly in
printer_auto.ycp via SCR::Read( .target.string, ... )
and SCR::Write( .target.string, ... ).
No longer needed and therefore removed are
Printerlib::WriteClientSettings and
Printerlib::WriteCupsSettings (those called
a special cups agent which did read and write
/etc/cups/cupsd.conf and /etc/cups/client.conf
by using a sophisticated YCP map) and
all what there was in the agents/ sub-directory
(where the special cups agent was implemented).
Prefer "manufacturer-PPD" over "recommended" PPD
(fixes bnc#589371).
In printer_proposal.ycp use Printer::DeriveModelName
and Printer::DeriveDriverFilterString the same way
as is basicadd.ycp so that the proposal results now
the same queue setup as if the user would have just
clicked [OK] in the BasicAddDialog.
Removed:
trunk/printer/agents/
Modified:
trunk/printer/src/Printer.ycp
trunk/printer/src/Printerlib.ycp
trunk/printer/src/printer_auto.ycp
trunk/printer/src/printer_proposal.ycp
trunk/printer/yast2-printer.spec.in
Modified: trunk/printer/src/Printer.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printer.ycp?rev=61386&r1=61385&r2=61386&view=diff
==============================================================================
--- trunk/printer/src/Printer.ycp (original)
+++ trunk/printer/src/Printer.ycp Thu Mar 18 15:40:13 2010
@@ -51,40 +51,6 @@
global boolean modified = false;
/**
- * Set to 'true' by AutoYaST by calling in printer_auto.ycp the "SetModified" function.
- * Read by AutoYaST by calling in printer_auto.ycp the "GetModified" function.
- * Preset to false which is the right default for AutoYast.
- */
-global boolean printer_auto_modified = false;
-
-/**
- * Filled in by AutoYaST by calling in printer_auto.ycp the "Import" function.
- * Reset to the empty map by AutoYaST by calling in printer_auto.ycp the "Reset" function.
- * Preset to the empty map which is the right default for AutoYast.
- */
-global map autoyast_printer_settings = $[];
-
-/**
- * Set to 'true' by AutoYaST by calling in printer_auto.ycp the "Change" function.
- * Lets the Overview dialog disable the checkbox to show local queues
- * which disables as a consequence in particular the [Delete] button.
- * Lets the Printing via Network dialog disable the button to
- * run the Connection Wizard (to set up a local queue for a network printer).
- * Preset to false which is the right default for all dialogs.
- */
-global boolean printer_auto_dialogs = false;
-
-/**
- */
-global boolean proposal_valid = false;
-
-/**
- * Write only, used during autoinstallation.
- * Don't run services and SuSEconfig, it's all done at one place.
- */
-global boolean write_only = false;
-
-/**
* Abort function
* return boolean return true if abort
*/
@@ -114,6 +80,43 @@
// Settings:
// Define all variables needed for configuration of a printer:
+/*
+ * Global variables:
+ */
+
+/**
+ * Used by AutoYaST by calling in printer_auto.ycp the "Summary" function.
+ */
+global string printer_auto_summary =
+_("<p>
+AutoYaST settings for printing with CUPS via network.<br>
+There is no AutoYaST support for local print queues.
+</p>");
+
+/**
+ * Set to 'true' by AutoYaST by calling in printer_auto.ycp the "SetModified" function.
+ * Read by AutoYaST by calling in printer_auto.ycp the "GetModified" function.
+ * Preset to false which is the right default for AutoYast.
+ */
+global boolean printer_auto_modified = false;
+
+/**
+ * Filled in by AutoYaST by calling in printer_auto.ycp the "Import" function.
+ * Reset to the empty map by AutoYaST by calling in printer_auto.ycp the "Reset" function.
+ * Preset to the empty map which is the right default for AutoYast.
+ */
+global map autoyast_printer_settings = $[];
+
+/**
+ * Set to 'true' by AutoYaST by calling in printer_auto.ycp the "Change" function.
+ * Lets the Overview dialog disable the checkbox to show local queues
+ * which disables as a consequence in particular the [Delete] button.
+ * Lets the Printing via Network dialog disable the button to
+ * run the Connection Wizard (to set up a local queue for a network printer).
+ * Preset to false which is the right default for all dialogs.
+ */
+global boolean printer_auto_dialogs = false;
+
/**
* Explicite listing of all alphanumeric ASCII characters.
* The reason is that in certain special locales for example [a-z] is not equivalent
@@ -1778,12 +1781,12 @@
// This is a PPD which was downloaded by the user:
string downloaded = "\\[downloaded/";
integer downloaded_weight = 32;
- // This is a recommended PPD:
- string recommended = "\\(recommended\\)";
- integer recommended_weight = 16;
// This is an original PPD from a manufacturer:
string manufacturerPPD = "\\[manufacturer-PPDs/";
- integer manufacturerPPD_weight = 8;
+ integer manufacturerPPD_weight = 16;
+ // This is a recommended PPD:
+ string recommended = "\\(recommended\\)";
+ integer recommended_weight = 8;
// This is a PPD from the HPLIP project (HP Linux Imaging and Printing):
string hplip = "/hplip/";
integer hplip_weight = 4;
Modified: trunk/printer/src/Printerlib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=61386&r1=61385&r2=61386&view=diff
==============================================================================
--- trunk/printer/src/Printerlib.ycp (original)
+++ trunk/printer/src/Printerlib.ycp Thu Mar 18 15:40:13 2010
@@ -630,20 +630,5 @@
return false;
}
-global boolean WriteCupsSettings(map ay){
- string cups_file="/etc/cups/cupsd.conf";
- y2milestone("Create backup of %1 file:%2", cups_file, SCR::Execute(.target.bash, sformat("mv %1 %1.$(date -I)", cups_file)));
- SCR::Write(.cups.server, ay);
- return true;
-}
-
-global boolean WriteClientSettings(map ay){
- string cups_file="/etc/cups/client.conf";
- y2milestone("Create backup of %1 file:%2", cups_file, SCR::Execute(.target.bash, sformat("mv %1 %1.$(date -I)", cups_file)));
- SCR::Write(.cups.client, ay);
- return true;
-}
-
-
}
Modified: trunk/printer/src/printer_auto.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printer_auto.ycp?rev=61386&r1=61385&r2=61386&view=diff
==============================================================================
--- trunk/printer/src/printer_auto.ycp (original)
+++ trunk/printer/src/printer_auto.ycp Thu Mar 18 15:40:13 2010
@@ -80,9 +80,50 @@
y2milestone("Printer auto func='%1'", func);
y2milestone("Printer auto param='%1'", param);
+string ReadFileContent( string file_name )
+{ if( -1 == SCR::Read( .target.size, file_name ) )
+ { // No user information popup because this would block autoinstallation.
+ // It is no error when /etc/cups/cupsd.conf or /etc/cups/client.conf
+ // cannot be read when those files just do not exist because
+ // it is perfectly o.k. to have a system without the package "cups"
+ // (e.g. a client-only setup without the "cups" RPM which provides /etc/cups/cupsd.conf)
+ // or even without a /etc/cups/client.conf file which is provided by the cups-libs RPM
+ // (e.g. a CUPS default setup where CUPS browsing is used and /etc/cups/client.conf was deleted)
+ y2milestone( "Warning: Cannot read %1 (file may not exist).", file_name );
+ Printer::printer_auto_summary = Printer::printer_auto_summary
+ + "<p>"
+ + sformat( // Warning message in the AutoYaST printer client
+ // which is added to its "Summary" text for AutoYaST
+ // where %1 is replaced by the file name which cannot be read.
+ _("Warning: Cannot read %1 (file may not exist)."),
+ file_name
+ )
+ + "</p>";
+ return "";
+ }
+ string content = (string)SCR::Read( .target.string, file_name );
+ if( "" == filterchars( content, Printer::alnum_chars ) )
+ { // No user information popup because this would block autoinstallation.
+ // It is an error when /etc/cups/cupsd.conf or /etc/cups/client.conf exist
+ // but are effectively empty because this indicates a broken CUPS config.
+ y2milestone( "Error: Failed to read %1 (possibly empty file).", file_name );
+ Printer::printer_auto_summary = Printer::printer_auto_summary
+ + "<p>"
+ + sformat( // Error message in the AutoYaST printer client
+ // which is added to its "Summary" text for AutoYaST
+ // where %1 is replaced by the file name which cannot be read.
+ _("Error: Failed to read %1 (possibly empty file)."),
+ file_name
+ )
+ + "</p>";
+ return "";
+ }
+ return content;
+}
+
/* Create a summary string */
if (func == "Summary")
-{ ret = _("AutoYaST settings for printing with CUPS via network. There is no AutoYaST support for local print queues.");
+{ ret = Printer::printer_auto_summary;
}
/*
* Reset the AutoYaST related printer settings to system defaults
@@ -100,7 +141,7 @@
* and to /etc/cups/cupsd.conf (regardless that their content
* is already reset to system defaults).
* Accordingly return the Printer::autoyast_printer_settings map
- * to AutoYaST so that also the printer related settings inside AutoYaSTare
+ * to AutoYaST so that also the printer related settings inside AutoYaST
* are reset to system defaults so that a subsequent call of the Import
* function by AutoYaST would provide the correct system default values.
*/
@@ -111,8 +152,11 @@
// so that there is no change of system config files in case of errors.
Printerlib::ExecuteBashCommand( "cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf" );
Printerlib::ExecuteBashCommand( "sed -i -e '/^[^#]/s/^/#/' /etc/cups/client.conf" );
- Printer::autoyast_printer_settings = $[ "server_settings" : (map)SCR::Read(.cups.server),
- "cups_remote_server" : (map)SCR::Read(.cups.client)
+ // Ignore read failures and reset to even empty content because to what else could it be reset instead:
+ Printer::autoyast_printer_settings = $[ "cupsd_conf_content" :
+ $[ "file_contents" : ReadFileContent( "/etc/cups/cupsd.conf" ) ],
+ "client_conf_content" :
+ $[ "file_contents" : ReadFileContent( "/etc/cups/client.conf" ) ]
];
ret = Printer::autoyast_printer_settings;
}
@@ -159,15 +203,14 @@
}
/*
* Read AutoYaST related printer configuration from this system's config files
- * and export them to AutoYaST as a single map which contains
- * the cupsd.conf entries in a "server_settings" sub-map and
- * the client.conf entries in a "cups_remote_server" sub-map
- * so that it can be imported later on another system from AutoYaST
- * when AutoYaST on the other system calls the above Import function.
+ * and export them to AutoYaST as a single map so that it can be imported later
+ * on another system from AutoYaST when AutoYaST on the other system
+ * calls the above Import function.
*/
else if (func == "Export")
-{ ret = $[ "server_settings" : (map)SCR::Read(.cups.server),
- "cups_remote_server" : (map)SCR::Read(.cups.client)
+{ // Ignore read failures and export even empty content because what else could be exported instead:
+ ret = $[ "cupsd_conf_content" : $[ "file_contents" : ReadFileContent( "/etc/cups/cupsd.conf" ) ],
+ "client_conf_content" : $[ "file_contents" : ReadFileContent( "/etc/cups/client.conf" ) ]
];
}
/*
@@ -201,17 +244,33 @@
* according to the Printer::autoyast_printer_settings_import map
* which was stored by a previous call of the Import function by AutoYaST
* or reset to an empty map by a previous call of the Reset function.
- * The map contains the cupsd.conf entries in a "server_settings" sub-map
- * and the client.conf entries in a "cups_remote_server" sub-map.
- * The cupsd.conf and client.conf entries are written by calling
- * Printerlib::WriteClientSettings to write /etc/cups/client.conf and
- * Printerlib::WriteCupsSettings to write /etc/cups/cupsd.conf
- * where empty sub-maps would result empty system config files.
*/
else if (func == "Write")
{ y2milestone("Writing to system '%1'", Printer::autoyast_printer_settings);
- Printerlib::WriteClientSettings( Printer::autoyast_printer_settings["cups_remote_server"]:$[] );
- Printerlib::WriteCupsSettings( Printer::autoyast_printer_settings["server_settings"]:$[] );
+ if( ! SCR::Write( .target.string,
+ "/etc/cups/cupsd.conf",
+ Printer::autoyast_printer_settings["cupsd_conf_content","file_contents"]:""
+ )
+ )
+ { // No user information popup because this would block autoinstallation:
+ y2milestone( "Error: Failed to write /etc/cups/cupsd.conf" );
+ Printer::printer_auto_summary = Printer::printer_auto_summary
+ + "<p>"
+ + _("Error: Failed to write /etc/cups/cupsd.conf")
+ + "</p>";
+ }
+ if( ! SCR::Write( .target.string,
+ "/etc/cups/client.conf",
+ Printer::autoyast_printer_settings["client_conf_content","file_contents"]:""
+ )
+ )
+ { // No user information popup because this would block autoinstallation:
+ y2milestone( "Error: Failed to write /etc/cups/client.conf" );
+ Printer::printer_auto_summary = Printer::printer_auto_summary
+ + "<p>"
+ + _("Error: Failed to write /etc/cups/client.conf")
+ + "</p>";
+ }
return true;
}
/* Unknown function */
Modified: trunk/printer/src/printer_proposal.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printer_proposal.ycp?rev=61386&r1=61385&r2=61386&view=diff
==============================================================================
--- trunk/printer/src/printer_proposal.ycp (original)
+++ trunk/printer/src/printer_proposal.ycp Thu Mar 18 15:40:13 2010
@@ -57,9 +57,8 @@
string warning = nil;
symbol warning_level = nil;
boolean force_reset = param["force_reset"]:false;
- if( force_reset || ! Printer::proposal_valid )
- { Printer::proposal_valid = true;
- // Do not call Printer::Read() here to
+ if( force_reset )
+ { // Do not call Printer::Read() here to
// avoid that the hardware proposal asks the user
// to install the packages cups-client and cups, see
// https://bugzilla.novell.com/show_bug.cgi?id=445719#c13
@@ -201,14 +200,19 @@
{ string uri = String::CutBlanks(printer[2]:"");
if( "" != uri )
{ y2internal("Setting up a queue for URI '%1'", uri);
+ // See basicadd.ycp how a queue_name_proposal is set there:
string queue_name = Printer::NewQueueName( tolower( model ) );
if( contains( already_set_up_uris, uri ) )
{ y2internal("Skipping printer '%1' because a queue with the same URI already exists.", printer);
continue;
}
y2milestone("Proposed queue name: %1", queue_name);
- string driver_filter_string = "^" + filterchars( tolower( model ), Printer::lower_alnum_chars );
- if( "^" != driver_filter_string )
+ // See basicadd.ycp how driver_filter_input_text and driver_filter_string are set there.
+ // The same is done here so that the proposal results the same as if the user
+ // would have blindly clicked [OK] in the BasicAddDialog:
+ string driver_filter_input_text = Printer::DeriveModelName( model, 0 );
+ string driver_filter_string = Printer::DeriveDriverFilterString( driver_filter_input_text );
+ if( "" != driver_filter_string )
{ list drivers = Printer::DriverItems( driver_filter_string, true );
// Printer::DriverItems may result a drivers list with one single element
// [ `item( `id( -1 ), _("No matching driver found.") ) ]
@@ -228,7 +232,11 @@
&& Printer::selected_connections_index >= 0
)
{ y2internal("Selected driver: %1", drivers[0]:nil);
- if( Printer::AddQueue( queue_name, "" ) )
+ // An empty default_paper_size results CUPS's default paper size
+ // (see the Printer::AddQueue function) so that the proposal results the same
+ // as if the user would have blindly clicked [OK] in the BasicAddDialog:
+ string default_paper_size = "";
+ if( Printer::AddQueue( queue_name, default_paper_size ) )
{ already_set_up_uris = add( already_set_up_uris, uri );
// Autodetect queues again so that Printer::NewQueueName
// can compare with existing queue names but ignore whatever failures
Modified: trunk/printer/yast2-printer.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/yast2-printer.spec.in?rev=61386&r1=61385&r2=61386&view=diff
==============================================================================
--- trunk/printer/yast2-printer.spec.in (original)
+++ trunk/printer/yast2-printer.spec.in Thu Mar 18 15:40:13 2010
@@ -9,12 +9,6 @@
Requires: /bin/mktemp /bin/ping /usr/bin/sed
Requires: yast2 >= 2.16.12
-Provides: yast2-config-cups yast2-agent-cups yast2-lib-printer yast2-config-printer y2c_cups y2c_prnt y2l_printer y2a_cups yast2-trans-printer yast2-trans-libprinter yast2-trans-cups yast2-cups-devel
-Obsoletes: yast2-config-cups yast2-agent-cups yast2-lib-printer yast2-config-printer y2c_cups y2c_prnt y2l_printer y2a_cups yast2-trans-printer yast2-trans-libprinter yast2-trans-cups yast2-cups-devel
-
-Provides: yast2-agent-cups-devel y2d_prnt y2t_prnt
-Obsoletes: yast2-agent-cups-devel y2d_prnt y2t_prnt
-
# Used to exclude libX11, libXau, libxcb, and libxcb-xlib from the requires list
# which are pulled in by Autoreqprov because of the basicadd_displaytest tool:
%define my_requires /tmp/my-requires
@@ -57,8 +51,6 @@
@clientdir@/printer*
@yncludedir@/printer/*
@schemadir@/autoyast/rnc/printer.rnc
-@scrconfdir@/*
-@agentdir@/*
@ydatadir@/testprint.ps
@ybindir@/autodetect_print_queues
@ybindir@/autodetect_printers
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org