235. Scanner

Scanner settings, input and output functions

235.1. Summary of Module Globals

List of Global Functions

  • Abort - Abort function

  • ActivateBackend - 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.

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

  • DeactivateBackend - 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.

  • DetermineNetworkScanningConfig - 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).

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

  • Import - Get all scanner settings from the first parameter. For use by autoinstallation.

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

  • Modified - Something was committed to the system?

  • OverviewContents - Create the content for WizardHW::SetContents

  • Read - 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 and HP all-in-one USB and NETWORK scanners

  • RestartDetection - 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.

  • RunHpsetup - Run hp-setup:

  • SetupNetworkScanningConfig - 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).

  • TestBackend - Test the backend according to the specified backend_name.

  • Write - Write scanner settings: - Save the actual environment

List of Global Variables

  • active_backends - 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.

  • active_scanners - 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 @ref active_scanner_map where the last list entry is an emtpy map.

  • actual_environment - Environment values: It is a map of @ref environment_values

  • autodetected_scanners - 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" and (if available) "hp-probe" 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 @ref autodetected_scanner_map where the last list entry is an emtpy map.

  • database - Scanner database: When package version of sane-backends/hplip/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 @ref scanner_model_map where the last list entry is an emtpy map.

  • database_manufacturers - 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").

  • database_usbids - Known USB scanner USB IDs list: List of known USB scanner USB vendor and product IDs. Derived during startup from the scanner database (in the Read function stage "Read or create the scanner database").

  • firewall_config - Firewall network scanning configuration: Determined at runtime via Scanner::DetermineNetworkScanningConfig() which calls SuSEFirewall functions to fill the map @ref 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.

  • ignore_unknown_USB_scanners - Ignore unknown USB scanners: Whether or not unknown USB scanners should be ignored during AutodetectScanners. As there is no USB device class for scanners (they have the unspecific USB device class 255), sane-find-scanner can only do some best guess to determine if a USB device is a scanner or not. Therefore also other USB devices with the device class 255 are reported as possible USB scanners. Preset to true so that initially only scanners for which the USB IDs are known by SANE are shown. It changes to false (i.e. show all USB devices with the device class 255 as possible USB scanners) when the user explicitely requests a "Restart Detection" in the OverviewDialog. A second "Restart Detection" changes it back to true so that "Restart Detection" toggles it. The idea behind is that the user can simply "Restart Detection" as often as he likes until the result is o.k. for him because "Restart Detection" does not cause harm and it avoids a separated button or check-box to determine the autodetection behaviour which would require additional explanatory (complicated) help text about the whole stuff. Examples: Assume there is a known powered-off USB scanner and another USB device with class 255: Initially nothing is shown. After the first "Restart Detection" only the other USB device with class 255 is shown. This unexpected result makes the user think about what is wrong and he powers-on the scanner. After the second "Restart Detection" only the USB scanner is shown. Assume there is an unknown powered-off USB scanner and another USB device with class 255. Initially nothing is shown. After the first "Restart Detection" only the other USB device with class 255 is shown. This unexpected result makes the user think about what is wrong and he powers-on the scanner. After the second "Restart Detection" nothing is shown. A third "Restart Detection" shows both the USB scanner and the other USB device with class 255. This is the best possible result because it is not possible to show only the unknown USB scanner.

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

  • network_scanning_config - 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 @ref network_scanner_config

  • number_chars - Explicite listing of all alphanumeric ASCII characters. The reason is that in certain special locales for example [a-z] is not equivalent to "abcdefghijklmnopqrstuvwxyz" because in certain special languages the 'z' is not the last character in the alphabet, e.g. the Estonian alphabet ends with ... s ... z ... t u v w ... x y (non-ASCII characters omitted here) so that [a-z] would exclude t u v w x y in an Estonian locale. Therefore uppercase and lowercase characters are both explicitely listed to avoid any unexpected result e.g. of "tolower(uppercase_characters)".

  • proposal_valid -

  • selected_autodetected_scanners_index - 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.

  • selected_model_database_index - 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.

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

235.2. Global Functions

235.2.1. Abort

Abort function

Return value

  • boolean - true if not modified and user requested abort

235.2.2. ActivateBackend

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.

Function parameters

  • string backend_name

  • integer database_index

  • boolean user_confirmation

Return value

  • boolean - true on success

235.2.3. AutoPackages

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

Return value

  • map - with 2 lists.

235.2.4. DeactivateBackend

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.

Function parameters

  • string backend_name

  • integer database_index

  • boolean user_confirmation

Return value

  • boolean - true on success

235.2.5. DetermineNetworkScanningConfig

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

  • boolean - true on success

235.2.6. Export

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

Return value

  • map - Dumped settings (later acceptable by Import ())

235.2.7. Import

Get all scanner settings from the first parameter. For use by autoinstallation.

Function parameters

  • map settings

Return value

  • boolean - true on success

235.2.8. ModelItems

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

Function parameters

  • string filter_string

Return value

  • list - of model strings (manufacturer, model, backend, comment)

235.2.9. Modified

Something was committed to the system?

Return value

  • boolean - true if system may have been modified

235.2.10. OverviewContents

Create the content for WizardHW::SetContents

Return value

  • list< map< string, any > > - a list of maps with keys "id" : string = the identification of the device, "rich_descr" : string = RichText description of the device "table_descr" : list<string> = fields of the table

235.2.11. Read

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 and HP all-in-one USB and NETWORK scanners

Return value

  • boolean - true on success

235.2.12. RestartDetection

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

  • boolean - true in any case (errors result only empty maps or list).

235.2.13. RunHpsetup

Run hp-setup:

Return value

  • boolean - false if hp-setup cannot be run and return true in any other case because there is no usable exit code of hp-setup (always zero even in case of error).

235.2.14. SetupNetworkScanningConfig

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

  • boolean - true on success

235.2.15. TestBackend

Test the backend according to the specified backend_name.

Function parameters

  • string backend_name

Return value

  • boolean - true on success

235.2.16. Write

Write scanner settings: - Save the actual environment

Return value

  • boolean - true on success

235.3. Global Variables

235.3.1. active_backends

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.

235.3.2. active_scanners

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 @ref active_scanner_map where the last list entry is an emtpy map.

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)",
  ]

235.3.3. actual_environment

Environment values: It is a map of @ref environment_values

environment_values
 $[ "sane-backends_version":"What 'rpm -q sane-backends' returns (required)",
    "hplip_version":"What 'rpm -q hplip' returns (required)",
    "iscan_version":"What 'rpm -q iscan' returns (required)"
    "iscan-free_version":"What 'rpm -q iscan-free' returns (required)"
  ]

235.3.4. autodetected_scanners

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" and (if available) "hp-probe" 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 @ref autodetected_scanner_map where the last list entry is an emtpy map.

autodetected_scanner_map
 $[ "connection":"Either USB or SCSI or NETWORK (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)"
  ]

235.3.5. database

Scanner database: When package version of sane-backends/hplip/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 @ref scanner_model_map where the last list entry is an emtpy map.

scanner_model_map
 $[ "package":"The package which provides the backend: sane-backends/hplip/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)",
    "usbid":"USBvendorID:USBproductID" e.g. "0x0a1b:0x2c3d" (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)"
  ]

235.3.6. database_manufacturers

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").

235.3.7. database_usbids

Known USB scanner USB IDs list: List of known USB scanner USB vendor and product IDs. Derived during startup from the scanner database (in the Read function stage "Read or create the scanner database").

235.3.8. firewall_config

Firewall network scanning configuration: Determined at runtime via Scanner::DetermineNetworkScanningConfig() which calls SuSEFirewall functions to fill the map @ref 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.

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"
  ]

235.3.9. ignore_unknown_USB_scanners

Ignore unknown USB scanners: Whether or not unknown USB scanners should be ignored during AutodetectScanners. As there is no USB device class for scanners (they have the unspecific USB device class 255), sane-find-scanner can only do some best guess to determine if a USB device is a scanner or not. Therefore also other USB devices with the device class 255 are reported as possible USB scanners. Preset to true so that initially only scanners for which the USB IDs are known by SANE are shown. It changes to false (i.e. show all USB devices with the device class 255 as possible USB scanners) when the user explicitely requests a "Restart Detection" in the OverviewDialog. A second "Restart Detection" changes it back to true so that "Restart Detection" toggles it. The idea behind is that the user can simply "Restart Detection" as often as he likes until the result is o.k. for him because "Restart Detection" does not cause harm and it avoids a separated button or check-box to determine the autodetection behaviour which would require additional explanatory (complicated) help text about the whole stuff. Examples: Assume there is a known powered-off USB scanner and another USB device with class 255: Initially nothing is shown. After the first "Restart Detection" only the other USB device with class 255 is shown. This unexpected result makes the user think about what is wrong and he powers-on the scanner. After the second "Restart Detection" only the USB scanner is shown. Assume there is an unknown powered-off USB scanner and another USB device with class 255. Initially nothing is shown. After the first "Restart Detection" only the other USB device with class 255 is shown. This unexpected result makes the user think about what is wrong and he powers-on the scanner. After the second "Restart Detection" nothing is shown. A third "Restart Detection" shows both the USB scanner and the other USB device with class 255. This is the best possible result because it is not possible to show only the unknown USB scanner.

235.3.10. modified

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

235.3.11. network_scanning_config

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 @ref network_scanner_config

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"
  ]

235.3.12. number_chars

Explicite listing of all alphanumeric ASCII characters. The reason is that in certain special locales for example [a-z] is not equivalent to "abcdefghijklmnopqrstuvwxyz" because in certain special languages the 'z' is not the last character in the alphabet, e.g. the Estonian alphabet ends with ... s ... z ... t u v w ... x y (non-ASCII characters omitted here) so that [a-z] would exclude t u v w x y in an Estonian locale. Therefore uppercase and lowercase characters are both explicitely listed to avoid any unexpected result e.g. of "tolower(uppercase_characters)".

235.3.13. proposal_valid

235.3.14. selected_autodetected_scanners_index

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.

235.3.15. selected_model_database_index

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.

235.3.16. write_only

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

235.4. Module Requirements

235.4.1. Module Imports

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

235.4.2. Module Includes