YaST2 Developers Documentation: Configuration of scanner



functions
files
intro

Configuration of scanner

modules/Scanner.ycp
Scanner settings, input and output functions
Representation of the configuration of scanner. Input and output routines.

Imports

  • Label
  • Package
  • Popup
  • Progress
  • Report
  • Service
  • Summary

Global Variables

Global Functions

Local Variables

Local Functions

global modified -> boolean

Something was committed to the system? True if system may have been modified.

global proposal_valid -> boolean

global write_only -> boolean

Write only, used during autoinstallation. Don't run services and SuSEconfig, it's all done at one place.

global Modified () -> boolean

Something was committed to the system?

Return value:
true if system may have been modified

global Abort () -> boolean

Abort function

Return value:
true if not modified and user requested abort

global database -> list< map< string, string > >

Scanner database: When package version of sane/hp-officeJet/iscan changes the database is created anew in Scanner::Read() which calls the bash script "/usr/lib/YaST2/bin/create_scanner_database YCP" which outputs on stdout a YCP list of scanner maps in the following format: [ $[ "package":"The package which provides the backend: sane/hplip/hp-officeJet/iscan (required)", "backend":"The name of the backend (required)", "manufacturer":"The manufacturer name of the scanner (required)", "model":"The model name of the scanner (required)", "firmware":"Whether or not firmware upload is required (value is 'required' or the empty string)", "interface":"None or one or more scanner interfaces (may be the empty string)", "status":"The support status: basic/complete/good/minimal/unsupported/untested (required)", "comment":"An optional comment (may be the empty string)" ], $[ ... ], ... $[] ]

global active_scanners -> list< map< string, string > >

Active scanners: Determined at runtime via Scanner::DetermineActiveScanners() which calls the bash script "/usr/lib/YaST2/bin/determine_active_scanners YCP" which outputs on stdout a YCP list of scanner maps in the following format: [ $[ "backend":"The name of the backend (required)", "sane_device":"The SANE device (required)", "manufacturer":"The manufacturer name of the scanner (required)", "model":"The model name of the scanner (required)", ], $[ ... ], ... $[] ]

global active_backends -> list< string >

Active backends: Determined at runtime via Scanner::DetermineActiveBackends() which calls the bash script "/usr/lib/YaST2/bin/determine_active_scanner_backends YCP" which outputs on stdout a YCP list of backends in the following format: [ "The name of the backend", ... "" ]

global autodetected_scanners -> list< map< string, string > >

Autodetected scanners: Determined at runtime via Scanner::AutodetectScanners() which calls the bash script "/usr/lib/YaST2/bin/autodetect_scanners YCP" which calls "sane-find-scanner" which may result for example the following description strings of autodetected scanners:

SCSI processor 'HP C6270A 3846' at /dev/sg0 USB scanner (vendor=0x05da, product=0x20b0) at libusb:002:005 USB scanner (vendor=0x03f0 [Hewlett-Packard], product=0x0201 [HP ScanJet 6200C]) at libusb:002:006 USB scanner (vendor=0x04a9 [Canon], product=0x220e [CanoScan], chip=LM9832/3) at libusb:001:005 USB scanner (vendor=0x04b8 [EPSON], product=0x010b [Perfection1240]) at libusb:001:004

Only in case of USB an automated extraction of manufacturer is possible. If there are two '[...]' substrings then the first one is the manufacturer and the second one is the model (but there may be only one or none substring).

global network_scanning_config -> map< string, string >

Network scanning configuration: Determined at runtime via Scanner::DetermineNetworkScanningConfig() which calls the bash script "/usr/lib/YaST2/bin/determine_network_scanner_config YCP" which outputs on stdout a YCP map in the following format: $[ "net_backend_hosts":"Comma seperated list of hosts in /etc/sane.d/net.conf", "saned_hosts":"Comma seperated list of hosts or subnets in /etc/sane.d/saned.conf" ]

global actual_environment -> map< string, string >

Environment values: It is a map in the following format: $[ "sane_version":"What 'rpm -q sane' returns (required)", "hplip_version":"What 'rpm -q hplip' returns (required)", "hp-officeJet_version":"What 'rpm -q hp-officeJet' returns (required)", "iscan_version":"What 'rpm -q iscan' returns (required)" ]

global selected_model_database_index -> integer

Other global variables:

local bash_result -> map

Local variables:

Info:

Local functions:

Info:

An ugly new version (with simple automated Popup::ShowFeedback which is shown too often):

boolean ExecuteBashCommand( string bash_commandline ) { y2milestone( "Executing bash commandline: %1", bash_commandline ); // if( "" == feeback_title ) // { feeback_title = "Executing " + bash_commandline; string feeback_title = "Executing " + bash_commandline; // } // Show feedback in any case: Popup::ShowFeedback( feeback_title, _("Please wait...") ); bash_result = (map)SCR::Execute( .target.bash_output, bash_commandline ); // Wait at least one more second before clearing the feedback // so that the user can read the feedback text in any case: sleep( 1000 ); Popup::ClearFeedback(); if( bash_result["exit"]:9999 != 0 ) { y2milestone( "'%1' exit code is: %2", bash_commandline, bash_result["exit"]:9999 ); y2milestone( "'%1' stdout is: %2", bash_commandline, bash_result["stdout"]:"" ); y2milestone( "'%1' stderr is: %2", bash_commandline, bash_result["stderr"]:"" ); return false; } return true; }

A future version (with sophisticated automated Popup::ShowFeedback), see yast/trunk/core/agents-perl/doc/ag_background.html

local TestAndInstallPackage (string package_name) -> boolean

Test whether the package is installed (Package::Installed) and if not then test whether the package is available to be installed (Package::Available) and if yes then install it (Package::Install).

Parameters:
package_name string of the package name
Return value:
true on success

local DetermineActiveScanners () -> boolean

Determine the active scanners by calling a bash script which calls "scanimage -L" and processes its output and stores the results as YCP list in a temporary file and then read the temporary file (SCR::Read) to get the YCP list

Return value:
true on success

local DetermineActiveBackends () -> boolean

Determine the active backends by calling a bash script which calls "grep ... /etc/sane.d/dll.conf" and processes its output and stores the results as YCP list in a temporary file and then read the temporary file (SCR::Read) to get the YCP list

Return value:
true on success

local AutodetectScanners () -> boolean

Try to autodetect USB and SCSI scanners by calling a bash script which calls "sane-find-scanner" and processes its output and stores the results as YCP list in a temporary file and then read the temporary file (SCR::Read) to get the YCP list

Return value:
true on success

local SetScsiScannerAccessPermissions () -> boolean

Search the active_scanners list for possible SCSI scanners ("/dev/" in SANE device) and if at least one possible SCSI scanner was found, then run /etc/init.d/sane-dev (using "restart" to be safe that outdated permissions are reset) and enable it for reboot ("insserv") otherwise stop it and disable it for reboot ("insserv -r")

Return value:
true on success

Info:

Global functions:

global Write () -> boolean

Write scanner settings: - Save the actual environment

Return value:
true on success

global Summary () -> list

Create a textual summary and a list of detected scanners

Return value:
of the currently activated scanners and activated backends

global ModelItems (string filter_string) -> list

Create a list of items from the database entries which is used for the SelectionBox in the SelectModelDialog

Parameters:
filter_string string of a search string to return only matching models (retunr all models if filter_string is the empty string)
Return value:
of model strings (manufacturer, model, backend, comment)

global ActivateBackend (string backend_name, integer database_index, boolean user_confirmation) -> boolean

Activate the backend in /etc/sane.d/dll.conf according to the specified backend_name or if the specified backend_name is the empty string then set the backend_name according to a specified database_index.

Parameters:
backend_name string of a backend which should be activated (if backend_name is the empty string then database_index must be >= 0)
database_index integer which points to an entry in the model database (if backend_name is the empty string then the backend according to the database_index is used)
user_confirmation boolean true if user confirmation popup in case of problems is requested
Return value:
true on success

global DeactivateBackend (string backend_name, integer database_index, boolean user_confirmation) -> boolean

Deactivate the backend in /etc/sane.d/dll.conf according to the specified backend_name or if the specified backend_name is the empty string then set the backend_name according to a specified database_index.

Parameters:
backend_name string of a backend which should be deactivated (if backend_name is the empty string then database_index must be >= 0)
database_index integer which points to an entry in the model database (if backend_name is the empty string then the backend according to the database_index is used)
user_confirmation boolean true if user confirmation popup in case of problems is requested
Return value:
true on success

global TestBackend (string backend_name) -> boolean

Test the backend according to the specified backend_name.

Parameters:
backend_name string of a backend which should be tested
Return value:
true on success

global Overview () -> list

Create an overview table with all active scanners and backends

Return value:
of table items

global DetermineNetworkScanningConfig () -> boolean

Determine the network scanning config by calling a bash script which calls "grep ... /etc/sane.d/net.conf" and "grep ... /etc/sane.d/saned.conf" and processes its output and stores the results as YCP map in a temporary file and then read the temporary file (SCR::Read) to get the YCP map

Return value:
true on success

global SetupNetworkScanningConfig () -> boolean

Setup the network scanning config by calling a bash script which writes into /etc/sane.d/net.conf, /etc/sane.d/saned.conf, and /etc/xinetd.d/sane-port and reloads or starts the xinetd dependig on whether it is running or not

Return value:
true on success

Info:

Autoinstallation stuff:

global Export () -> map

Dump the scanner settings to a single map. For use by autoinstallation.

Return value:
Dumped settings (later acceptable by Import ())

global AutoPackages () -> map

Return packages needed to be installed and removed during autoinstallation to insure module has all needed software installed.

Return value:
with 2 lists.

YaST2 Developers Documentation