Configuration of scanner |
modules/Scanner.ycp |
Scanner settings, input and output functions | |
|
|
This module has an unstable interface. |
Something was committed to the system? True if system may have been modified.
Write only, used during autoinstallation. Don't run services and SuSEconfig, it's all done at one place.
Something was committed to the system?
- Return value:
-
true if system may have been modified
Abort function
- Return value:
-
true if not modified and user requested abort
Scanner database: When package version of sane/hp-officeJet/iscan/iscan-free 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_model_map where the last list entry is an emtpy map.
Structure scanner_model_map
$[ "package":"The package which provides the backend: sane/hplip/hp-officeJet/iscan/iscan-free (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)" ]
Manufacturer list: List of unique manufacturer names. Derived during startup from the scanner database (in the Read function stage "Read or create the scanner database").
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 active_scanner_map where the last list entry is an emtpy map.
Structure active_scanner_map
$[ "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)", ]
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 [ "The name of the backend", ... "" ] where the last list entry is an empty 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 description strings in the example below. 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). The result is a YCP list of autodetected_scanner_map where the last list entry is an emtpy map.
Structure autodetected_scanner_map
$[ "connection":"Either USB or SCSI (required)", "device":"The device, e.g. '/dev/sg0' or 'libusb:001:002' (may be the empty string)" "manufacturer":"The manufacturer name of the scanner (may be the empty string)", "usb_vendor_id":"The vendor ID (e.g. 0x04b8) of a USB scanner (may be the empty string)", "model":"The model name of the scanner (may be the empty string)", "usb_product_id":"The product ID (e.g. 0x010b) of a USB scanner (may be the empty string)", "description":"The sane-find-scanner output description string (required)" ]
- Example
-
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
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 network_scanner_config
Structure network_scanner_config
$[ "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" ]
Firewall network scanning configuration: Determined at runtime via Scanner::DetermineNetworkScanningConfig() which calls SuSEFirewall functions to fill the map firewall_config except "ui_no_firewall_for_int" and "ui_deny_from_ext" which are the user settings in the dialog. The entries are such that "true" is the default, reasonable and intended setting.
Structure firewall_config
$[ "suse_firewall_used":"true if Suse Firewall and no other firewall is used", "firewall_active":"true if Suse Firewall is actually running", "no_firewall_for_int":"true if Suse Firewall does not potect the INT zone", "ui_no_firewall_for_int":"true if user has set in dialog no Suse Firewall protection for INT", "denied_from_ext":"true if saned access (sane-port 6566) is denied from EXT zone", "ui_deny_from_ext":"true if user has set in dialog to deny access from EXT" ]
Environment values: It is a map of environment_values
Structure environment_values
$[ "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)" "iscan-free_version":"What 'rpm -q iscan-free' returns (required)" ]
Selected model database index: The index in the scanner database list (of model maps) for the model which was selected by the user in the SelectModelDialog. Preset to -1 which indicates that no model is selected.
Selected autodetected scanners index: The index in the autodetected scanners list (of autodetected scanner maps) for the model which was selected by the user in the OverviewDialog. Preset to -1 which indicates that no model is selected.
Wrapper for SCR::Execute to execute a bash command to increase verbosity via y2milestone. It reports the command via y2milestone in any case and it reports exit code, stdout and stderr via y2milestone in case of non-zero exit code.
- Parameters:
-
bash_commandline string of the bash command to be executed
- Return value:
-
true on success
Determine the version of an installed package by calling a bash command (rpm).
- Parameters:
-
package_name string of the package name
- Return value:
-
of the version of an installed package or "failed to determine" otherwise
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). The packages iscan and iscan-free require special handling: iscan and iscan-free conflict with each other, iscan is only available on i386 compatible architectures because iscan contains proprietary binary-only i386-only software, some scanners require the non-free software.
- Parameters:
-
package_name string of the package name
- Return value:
-
true on success
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 of active_scanner_map
- Return value:
-
true on success
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 of active backends.
- Return value:
-
true on success
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 of autodetected_scanner_map
- Return value:
-
true on success
Search the autodetected_scanners list for USB scanners
and if at least one USB scanner was found,
then do the following:
1.
Notify resmgr to grant access for locally logged in users via the command:
/sbin/resmgr add /dev/bus/usb/
- Return value:
-
true on success
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"). Note that it must search for ":/dev/" to find only SCSI scanners ("backend:/dev/sg...") because for example the hpaio backend may have also "/dev/" in its device, e.g.: "hpaio:/usb/HP_LaserJet_1220?device=/dev/usb/lp0", this depends on the particular model (e.g. when it doesn't report a serial number).
- Return value:
-
true on success
Test whether there exist a print queue which depends on the specified SANE backend. Examples: hpaio (package hplip): Setting up the hpaio backend requires to activate/start the hplip service. It may happen that the conflicting service ptal is in use by the CUPS printing system. I.e. there may be a print queue which uses the ptal CUPS backend. hpoj (package hp-officeJet): Setting up the hpoj backend requires to initialize/activate/start the ptal service. It may happen that the conflicting service hplip is in use by the CUPS printing system. I.e. there may be a print queue which uses the hp CUPS backend. Note: The test is only implememnted for the CUPS printing system. A dependant print queue can exists only for the SANE backends hpaio and hpoj. For all other backends no dependant print queue can exists.
- Parameters:
-
backend_name string of the SANE backend name
- Return value:
-
true if a dependant CUPS print queue exists for the backends hpaio or hpoj
Read all scanner settings: - Check installed packages - Read or create the scanner database - Determine active scanners - Determine active backends - Try to autodetect USB and SCSI scanners
- Return value:
-
true on success
Write scanner settings: - Save the actual environment
- Return value:
-
true on success
Restart the whole autodetection by calling all autodetection functions in the same order as during the initial Read(): DetermineActiveScanners results a new active_scanners map which is empty if nothing was detected or if DetermineActiveScanners fails. DetermineActiveBackends results a new active_backends list which is empty if nothing was detected or if DetermineActiveBackends fails. AutodetectScanners results a new autodetected_scanners map which is empty if nothing was detected or if AutodetectScanners fails. RestartDetection is called when the user restarts the detection in the OverviewDialog and if testing of an active scanner failed (see the TestBackend function). The result is that all information in the OverviewDialog is recreated.
- Return value:
-
true in any case (errors result only empty maps or list).
Create the content for WizardHW::SetContents
- Return value:
-
a list of maps with keys "id" : string = the identification of the device, "rich_descr" : string = RichText description of the device "table_descr" : list = fields of the table
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)
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
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
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
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. Additionally call SuSEFirewall functions to determine the firewall settings regarding remote access to the saned (service "sane-port" 6566/tcp,6566/udp).
- Return value:
-
true on success
Setup the network scanning config by calling a bash script which activates or deactivates the "net" backend and 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. Additionally call SuSEFirewall functions to commit changed firewall settings regarding remote access to the saned (service "sane-port" 6566/tcp,6566/udp).
- Return value:
-
true on success
Get all scanner settings from the first parameter. For use by autoinstallation.
- Parameters:
-
settings The YCP structure to be imported.
- Return value:
-
true on success
Dump the scanner settings to a single map. For use by autoinstallation.
- Return value:
-
Dumped settings (later acceptable by Import ())
Return packages needed to be installed and removed during autoinstallation to insure module has all needed software installed.
- Return value:
-
with 2 lists.