Module: Yast::PrinterPrintingvianetworkInclude
- Defined in:
- ../../src/include/printer/printingvianetwork.rb
Instance Method Summary (collapse)
- - (Object) ApplyNetworkPrintingSettings
- - (Object) handleNetworkPrinting(key, event)
- - (Object) initialize_printer_printingvianetwork(include_target)
- - (Object) initNetworkPrinting(key)
- - (Object) ShowBrowsingFirewallPopup
Instance Method Details
- (Object) ApplyNetworkPrintingSettings
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
# File '../../src/include/printer/printingvianetwork.rb', line 217 def ApplyNetworkPrintingSettings current_browsing = Convert.to_boolean( UI.QueryWidget(Id(:browsing_check_box), :Value) ) current_browse_allow = UI.QueryWidget(Id(:browse_allow_combo_box), :Value) current_browse_allow_input_value = Convert.to_string( UI.QueryWidget(Id(:browse_allow_input), :Value) ) current_browse_poll = Convert.to_boolean( UI.QueryWidget(Id(:browse_poll_check_box), :Value) ) current_browse_poll_input_value = Convert.to_string( UI.QueryWidget(Id(:browse_poll_input), :Value) ) current_client_only = Convert.to_boolean( UI.QueryWidget(Id(:client_only_check_box), :Value) ) current_client_conf_input_value = Convert.to_string( UI.QueryWidget(Id(:client_conf_input), :Value) ) Builtins.y2milestone( "ApplyNetworkPrintingSettings with\n" + "current_browsing = '%1'\n" + "current_browse_allow = '%2'\n" + "current_browse_allow_input_value = '%3'\n" + "current_browse_poll = '%4'\n" + "current_browse_poll_input_value = '%5'\n" + "current_client_only = '%6'\n" + "current_client_conf_input_value = '%7'", current_browsing, current_browse_allow, current_browse_allow_input_value, current_browse_poll, current_browse_poll_input_value, current_client_only, current_client_conf_input_value ) # Sanitise the BrowseAllow and BrowsePoll values. # Changes in the ordering (e.g. from 'host2 host1' to 'host1 host2') # are ignored because toset() sorts the list and removes duplicates. # Changes in the case (e.g. from 'host' to 'Host') are not ignored because # the user may like to have it exactly in cupsd.conf (even if actually case may not matter): initial_browse_allow_value = Builtins.mergestring( Builtins.toset( Builtins.splitstring(@initial_browse_allow_input_value, " ") ), " " ) current_browse_allow_value = Builtins.mergestring( Builtins.toset( Builtins.splitstring(current_browse_allow_input_value, " ") ), " " ) initial_browse_poll_value = Builtins.mergestring( Builtins.toset( Builtins.splitstring(@initial_browse_poll_input_value, " ") ), " " ) current_browse_poll_value = Builtins.mergestring( Builtins.toset( Builtins.splitstring(current_browse_poll_input_value, " ") ), " " ) # Sanitise the "client only" value. # Keep only the first server name if there is more than one server name: initial_client_conf_value = Ops.get( Builtins.toset( Builtins.splitstring(@initial_client_conf_input_value, " ") ), 0, "" ) current_client_conf_value = Ops.get( Builtins.toset( Builtins.splitstring(current_client_conf_input_value, " ") ), 0, "" ) Builtins.y2milestone( "ApplyNetworkPrintingSettings with sanitised values:\n" + "initial_browse_allow_value = '%1'\n" + "current_browse_allow_value = '%2'\n" + "initial_browse_poll_value = '%3'\n" + "current_browse_poll_value = '%4'\n" + "initial_client_conf_value = '%5'\n" + "current_client_conf_value = '%6'", initial_browse_allow_value, current_browse_allow_value, initial_browse_poll_value, current_browse_poll_value, initial_client_conf_value, current_client_conf_value ) # Test if something meaningful has changed. # It is meaningful if an item (BrowseAllow, BrowsePoll or "client only") # was activated which was initially deactivated or vice versa. # It is meaningful if a value for an activated item was changed. # But it is meaningless if a value for a deactivated item was changed. # I.e. if a value for BrowseAllow, BrowsePoll or the client only server name was changed # but then the whole item was deactivated via its check box # the change of the value is meaningless and the changed value will not be written. if current_browsing != @initial_browsing || current_browse_poll != @initial_browse_poll || current_client_only != @initial_client_only || current_browsing && current_browse_allow != @initial_browse_allow || current_browsing && current_browse_allow_value != initial_browse_allow_value || current_browse_poll && current_browse_poll_value != initial_browse_poll_value || current_client_only && current_client_conf_value != initial_client_conf_value @printing_via_network_has_changed = true else @printing_via_network_has_changed = false # Nothing has changed: return true end # First of all handle the client-only config # when the client-only item is enabled and exit this function # when there is an effectively non-empty server name value # because anything else (BrowseAllow, BrowsePoll) is meningless because # those items are automatically disabled when client-only is enabled. # When a real client-only config (when the server name is not "localhost" or "127.0.0.1") # is set up, the local cupsd is stopped so that any BrowseAllow and BrowsePoll stuff # becomes effectively disabled (during shutdown cupsd also stops cups-polld processes). # Is is not posible to change BrowseAllow and/or BrowsePoll values # in the dialog first and then switch to a client-only config but # get the changed BrowseAllow and/or BrowsePoll values written nevertheless. # A switch to a client-only config leaves the existing BrowseAllow # and/or BrowsePoll values in /etc/cups/cupsd.conf unchanged. # This behaviour is more reasonable than the other one # because the other behaviour seems oversophisticated because # a switch to client-only grays out the BrowseAllow and/or BrowsePoll widgets # which should have the meaning that the matching values are now out of scope. if current_client_only && !@initial_client_only || current_client_only && current_client_conf_value != initial_client_conf_value # or it was initially a client-only config but its server name value changed: if "" == current_client_conf_value || "none" == Builtins.tolower(current_client_conf_value) if !@initial_client_only # to a client-only config but with an effectively empty server name. # Such a client-only config does not make sense: Popup.Error(_("A valid CUPS server name must be entered.")) return false end # It was initially a client-only config but the user has # changed the server name value to be effectively empty. # This is the same as to turn off the client-only config # so that the "turn off client-only" case below is triggered here: @initial_client_only = true current_client_only = false else enforce_client_only_server_setting = false # A non-accessible client-only server leads to an endless sequence of weird further behaviour # of the module so that a non-accessible server is not accepted. # This means that it is not possible to set up a client-only config first # and then make the client-only server accessible (e.g. boot the client-only server, # open ports in firewall, set up the network connection, whatever else). # This would be a problem when a workstation is set up by an admin in the IP department # for a client-only config but the workstation is currently not connected to the network # where the client-only server is (e.g. in the department for which the workstation is set up). # Therefore the admin can force YaST to proceed here. # Do not show additional error messages here because Printer::TestClientOnlyServer() # shows sufficient popups to the user: if !Printer.TestClientOnlyServer(current_client_conf_value) if !Popup.ContinueCancelHeadline( Builtins.sformat( # when a client-only server is not accessible # where %1 will be replaced by the server name: _("Continue regardless that '%1' is not accessible?"), current_client_conf_value ), # Header of a Popup::ContinueCancelHeadline # Body of a Popup::ContinueCancelHeadline # when a client-only server is not accessible: _( "A non-accessible server leads to an endless sequence of failures." ) ) return false end # The user has decided to continue regardless that the client-only server is not accessible: enforce_client_only_server_setting = true end if !@initial_client_only # but now the user has switched to "client-only". # If the server name is not "localhost" and not "127.0.0.1" # a real client-only config is to be set up and then # a possibly running local cupsd will be stopped. if "localhost" != Builtins.tolower(current_client_conf_value) && "127.0" != Builtins.substring(current_client_conf_value, 0, 5) if Printerlib.GetAndSetCupsdStatus("") return false if !Printerlib.GetAndSetCupsdStatus("stop") end end end if !Printerlib.ExecuteBashCommand( Ops.add( Ops.add(Printerlib.yast_bin_dir, "cups_client_only "), current_client_conf_value ) ) if enforce_client_only_server_setting # In this case the cups_client_only tool fails in any case because it also tests accessibility. # But the cups_client_only tool might have failed for whatever other reason. # Therefore a Popup::MessageDetails is shown to inform about the actual result: Popup.MessageDetails( # where %1 will be replaced by the server name. Builtins.sformat( _("Tried to set 'ServerName %1' in /etc/cups/client.conf."), current_client_conf_value ), Ops.get_string(Printerlib.result, "stderr", "") ) # Exit successfully in this special case regardless of whatever failures: return true end Popup.ErrorDetails( # where %1 will be replaced by the server name. Builtins.sformat( _("Failed to set 'ServerName %1' in /etc/cups/client.conf."), current_client_conf_value ), Ops.get_string(Printerlib.result, "stderr", "") ) return false end # Exit successfully by default and as fallback: return true end # A client-only config with effectively empty server name value continues here # and triggers the following "turn off client-only" case: end # Before handling BrowseAllow and/or BrowsePoll # turn off the client-only config # if the user had disabled the client-only item: if @initial_client_only && !current_client_only # but now the user has deactivated it # so that the client-only config should be disabled: if !Popup.YesNoHeadline( # where %1 will be replaced by the server name: Builtins.sformat( _("Disable Remote CUPS Server '%1'"), Printerlib.client_conf_server_name ), # PopupYesNoHeadline body: _( "The checkbox to do all printing via one CUPS server was disabled." ) ) return false end # Remove the 'ServerName' entry in /etc/cups/client.conf: if !Printerlib.ExecuteBashCommand( Ops.add(Printerlib.yast_bin_dir, "cups_client_only none") ) Popup.ErrorDetails( _( "Failed to remove the 'ServerName' entry in /etc/cups/client.conf" ), Ops.get_string(Printerlib.result, "stderr", "") ) return false end # The local cupsd is not started here because it is not clear at this point # if a local running cupsd is really needed. E.g. when both Browsing and BrowsePoll # are also disabled, there is no need to start the local cupsd in this dialog. # Other dialogs are on their own to start the local cupsd if needed, # see the "Different Workflow What Actually Happens" section at # http://en.opensuse.org/Archive:YaST_Printer_redesign#Basic_Implementation_Principles: end # When handling both BrowseAllow and BrowsePoll # the cupsd may need to be started or restarted in both cases. # But actually the cupsd should be at most once started or restarted # for both BrowseAllow and BrowsePoll at the very end: printing_via_network_restart_running_cupsd = false printing_via_network_needs_running_cupsd = false # Handle BrowseAllow: if current_browsing && !@initial_browsing || current_browsing && current_browse_allow != @initial_browse_allow || current_browsing && current_browse_allow_value != initial_browse_allow_value # or it was initially a BrowseAllow config but its values changed: if :browse_allow_none == current_browse_allow # This is the same as to disable the BrowseAllow config # so that the "BrowseAllow config should be disabled" case below is triggered here: @initial_browsing = true current_browsing = false else if :browse_allow_all == current_browse_allow current_browse_allow_value = "all" end if :browse_allow_local == current_browse_allow if "" != Builtins.filterchars( current_browse_allow_value, Printer.alnum_chars ) current_browse_allow_value = Ops.add( current_browse_allow_value, " @LOCAL" ) else current_browse_allow_value = "@LOCAL" end end # Write to cupsd.conf only if the current_browse_allow_value is effectively non-empty: if "" != Builtins.filterchars( current_browse_allow_value, Printer.alnum_chars ) # test whether or not a firewall seems to be active and # if yes show a popup regarding firewall if it was not yet shown: if !@browsing_firewall_popup_was_shown if ShowBrowsingFirewallPopup() @browsing_firewall_popup_was_shown = true end end # An effectively non-empty current_browse_allow_value requires "Browsing On" in cupsd.conf: if !Printerlib.ExecuteBashCommand( Ops.add( Printerlib.yast_bin_dir, "modify_cupsd_conf Browsing On" ) ) Popup.ErrorDetails( _("Failed to set 'Browsing On' in /etc/cups/cupsd.conf."), Ops.get_string(Printerlib.result, "stderr", "") ) return false end # Write the BrowseAllow values to cupsd.conf: if !Printerlib.ExecuteBashCommand( Ops.add( Ops.add( Ops.add( Printerlib.yast_bin_dir, "modify_cupsd_conf BrowseAllow '" ), current_browse_allow_value ), "'" ) ) Popup.ErrorDetails( # where %1 will be replaced by the values for BrowseAllow. Builtins.sformat( _( "Failed to set BrowseAllow value(s) '%1' in /etc/cups/cupsd.conf." ), current_browse_allow_value ), Ops.get_string(Printerlib.result, "stderr", "") ) return false end # An effectively non-empty current_browse_allow_value requires a local running cupsd: printing_via_network_needs_running_cupsd = true end end end if @initial_browsing && !current_browsing # but now the user has deactivated it # so that the BrowseAllow config should be disabled. # Do not change the global "Browsing On/Off" entry in cupsd.conf # because "Browsing Off" disables also sharing of local printers # which might be needed by the "Share Printers" dialog. # Instead set only "BrowseAllow none" in cupsd.conf: if !Printerlib.ExecuteBashCommand( Ops.add( Printerlib.yast_bin_dir, "modify_cupsd_conf BrowseAllow none" ) ) Popup.ErrorDetails( _("Failed to set 'BrowseAllow none' in /etc/cups/cupsd.conf."), Ops.get_string(Printerlib.result, "stderr", "") ) return false end printing_via_network_restart_running_cupsd = true end # Handle BrowsePoll: if current_browse_poll && !@initial_browse_poll || current_browse_poll && current_browse_poll_value != initial_browse_poll_value # or it was initially a BrowsePoll config but its server name values changed: if "" == current_browse_poll_value || "none" == Builtins.tolower(current_browse_poll_value) if !@initial_browse_poll # a BrowsePoll config but with effectively empty server names. # Such a BrowsePoll config does not make sense: Popup.Error( _("At least one valid CUPS server name must be entered.") ) return false end # It was initially a BrowsePoll config but the user has # changed the server name values to be effectively empty. # This is the same as to turn off the BrowsePoll config so that # the "BrowsePoll config should be disabled" case below is triggered here: @initial_browse_poll = true current_browse_poll = false else if "" != Builtins.filterchars( current_browse_poll_value, Printer.alnum_chars ) if !Printerlib.ExecuteBashCommand( Ops.add( Printerlib.yast_bin_dir, "modify_cupsd_conf Browsing On" ) ) Popup.ErrorDetails( _("Failed to set 'Browsing On' in /etc/cups/cupsd.conf."), Ops.get_string(Printerlib.result, "stderr", "") ) return false end # Write the BrowsePoll values to cupsd.conf: if !Printerlib.ExecuteBashCommand( Ops.add( Ops.add( Ops.add( Printerlib.yast_bin_dir, "modify_cupsd_conf BrowsePoll '" ), current_browse_poll_value ), "'" ) ) Popup.ErrorDetails( # where %1 will be replaced by the values for BrowsePoll. Builtins.sformat( _( "Failed to set BrowsePoll value(s) '%1' in /etc/cups/cupsd.conf" ), current_browse_poll_value ), Ops.get_string(Printerlib.result, "stderr", "") ) return false end # An effectively non-empty current_browse_poll_value requires a local running cupsd: printing_via_network_needs_running_cupsd = true end end end if @initial_browse_poll && !current_browse_poll # but now the user has deactivated it # so that the BrowsePoll config should be disabled: # Set only "BrowsePoll none" in cupsd.conf: if !Printerlib.ExecuteBashCommand( Ops.add( Printerlib.yast_bin_dir, "modify_cupsd_conf BrowsePoll none" ) ) Popup.ErrorDetails( _("Failed to set 'BrowsePoll none' in /etc/cups/cupsd.conf"), Ops.get_string(Printerlib.result, "stderr", "") ) return false end printing_via_network_restart_running_cupsd = true end # Make sure cupsd is running: if printing_via_network_needs_running_cupsd if Printerlib.GetAndSetCupsdStatus("") return false if !Printerlib.GetAndSetCupsdStatus("restart") else return false if !Printerlib.GetAndSetCupsdStatus("start") end # Exit successfully by default and as fallback: return true end # Restart cupsd only when it is already running: if printing_via_network_restart_running_cupsd # otherwise do nothing (i.e. leave it stopped) because # disabling of a BrowseAllow or BrowsePoll config # does not require a running cupsd. # Other dialogs are on their own to start the local cupsd if needed, # see the "Different Workflow What Actually Happens" section at # http://en.opensuse.org/Archive:YaST_Printer_redesign#Basic_Implementation_Principles: if Printerlib.GetAndSetCupsdStatus("") return false if !Printerlib.GetAndSetCupsdStatus("restart") # A "accept browsing info" config with a local running cupsd # was switched to a "not accept browsing info" config or # a BrowsePoll config with a local running cupsd was disabled. # A cups-polld polls remote servers for a list of available printer queues. # Those information is then broadcast to the localhost interface (127.0.0.1) # on the specified browse port for reception by the local cupsd. # Theerfore for the cupsd BrowsePoll information is the same # as the usual Browsing information via BrowseAllow. # The default BrowseTimeout value for the local cupsd is 5 minutes. # Therefore it takes by default 5 minutes until printer information # that was previously received by Browsing is removed (via timeout) # from the local cupsd's list. # I assume most users do not like to wait 5 minutes which is no problem # because they can just click the [OK] button to continue but then # they are at least informend why there may be still remote queues: Popup.TimedMessage( _( "When switching from 'accept printer announcements' to 'not accept announcements'\n" + "or after 'request printer information from CUPS servers' was disabled\n" + "it takes usually 5 minutes until already received information faded away..." ), 300 ) end end # Exit successfully by default and as fallback: true end |
- (Object) handleNetworkPrinting(key, event)
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 |
# File '../../src/include/printer/printingvianetwork.rb', line 979 def handleNetworkPrinting(key, event) event = deep_copy(event) Builtins.y2milestone( "entering handleNetworkPrinting with key '%1'\nand event '%2'", key, event ) if "ValueChanged" == Ops.get_string(event, "EventReason", "") if :browsing_check_box == Ops.get(event, "ID") if Convert.to_boolean(UI.QueryWidget(:browsing_check_box, :Value)) UI.ChangeWidget(Id(:browse_allow_combo_box), :Enabled, true) if :browse_allow_none == UI.QueryWidget(Id(:browse_allow_combo_box), :Value) || :browse_allow_all == UI.QueryWidget(Id(:browse_allow_combo_box), :Value) # it would be contradicting to accept it from specific IPs or networks # or if browsing info is accepted from all hosts, # it is useless to additionally accept it from specific IPs or networks: UI.ChangeWidget(Id(:browse_allow_input), :Enabled, false) else UI.ChangeWidget(Id(:browse_allow_input), :Enabled, true) end if !Printerlib.client_only && !Printer.printer_auto_dialogs # and disabled if currently a "client_only" config is active. # In this case it is never again enabled as long as the dialog runs, see above. # It is also disabled in case of Printer::printer_auto_dialogs # and then it must stay disabled as long as the dialog runs. UI.ChangeWidget(Id(:connection_wizard), :Enabled, true) end UI.ChangeWidget(Id(:client_only_check_box), :Value, false) UI.ChangeWidget(Id(:client_conf_input), :Enabled, false) UI.ChangeWidget(Id(:test_client_conf_server), :Enabled, false) else UI.ChangeWidget(Id(:browse_allow_combo_box), :Enabled, false) UI.ChangeWidget(Id(:browse_allow_input), :Enabled, false) end end if :browse_poll_check_box == Ops.get(event, "ID") if Convert.to_boolean(UI.QueryWidget(:browse_poll_check_box, :Value)) UI.ChangeWidget(Id(:browse_poll_input), :Enabled, true) if !Printerlib.client_only && !Printer.printer_auto_dialogs # and disabled if currently a "client_only" config is active. # In this case it is never again enabled as long as the dialog runs, see above. # It is also disabled in case of Printer::printer_auto_dialogs # and then it must stay disabled as long as the dialog runs. UI.ChangeWidget(Id(:connection_wizard), :Enabled, true) end UI.ChangeWidget(Id(:client_only_check_box), :Value, false) UI.ChangeWidget(Id(:client_conf_input), :Enabled, false) UI.ChangeWidget(Id(:test_client_conf_server), :Enabled, false) else UI.ChangeWidget(Id(:browse_poll_input), :Enabled, false) end end if :client_only_check_box == Ops.get(event, "ID") if Convert.to_boolean(UI.QueryWidget(:client_only_check_box, :Value)) UI.ChangeWidget(Id(:browsing_check_box), :Value, false) UI.ChangeWidget(Id(:browse_allow_combo_box), :Enabled, false) UI.ChangeWidget(Id(:browse_allow_input), :Enabled, false) UI.ChangeWidget(Id(:browse_poll_check_box), :Value, false) UI.ChangeWidget(Id(:browse_poll_input), :Enabled, false) UI.ChangeWidget(Id(:client_conf_input), :Enabled, true) UI.ChangeWidget(Id(:test_client_conf_server), :Enabled, true) UI.ChangeWidget(Id(:connection_wizard), :Enabled, false) else if Convert.to_boolean(UI.QueryWidget(:browsing_check_box, :Value)) UI.ChangeWidget(Id(:browse_allow_combo_box), :Enabled, true) UI.ChangeWidget(Id(:browse_allow_input), :Enabled, true) end if Convert.to_boolean( UI.QueryWidget(:browse_poll_check_box, :Value) ) UI.ChangeWidget(Id(:browse_poll_input), :Enabled, true) end if !Printerlib.client_only && !Printer.printer_auto_dialogs # and disabled if currently a "client_only" config is active. # In this case it is never again enabled as long as the dialog runs, see above. # It is also disabled in case of Printer::printer_auto_dialogs # and then it must stay disabled as long as the dialog runs. UI.ChangeWidget(Id(:connection_wizard), :Enabled, true) end UI.ChangeWidget(Id(:client_conf_input), :Enabled, false) UI.ChangeWidget(Id(:test_client_conf_server), :Enabled, false) end end if :browse_allow_combo_box == Ops.get(event, "ID") current_browse_allow = UI.QueryWidget( Id(:browse_allow_combo_box), :Value ) if :browse_allow_none == current_browse_allow # it would be contradicting to accept it from specific IPs or networks: UI.ChangeWidget(Id(:browse_allow_input), :Enabled, false) # Furthermore the check box to accept printer information is un-checked: UI.ChangeWidget(Id(:browsing_check_box), :Value, false) end if :browse_allow_all == current_browse_allow # it is useless to additionally accept it from specific IPs or networks: UI.ChangeWidget(Id(:browse_allow_input), :Enabled, false) # Furthermore the check box to accept printer information is checked: UI.ChangeWidget(Id(:browsing_check_box), :Value, true) end if :browse_allow_local == current_browse_allow || :browse_allow_specific == current_browse_allow # to additionally accept from specific IPs or networks: UI.ChangeWidget(Id(:browse_allow_input), :Enabled, true) # Furthermore the check box to accept printer information is checked: UI.ChangeWidget(Id(:browsing_check_box), :Value, true) end end end if "Activated" == Ops.get_string(event, "EventReason", "") if :abort == Ops.get(event, "ID") || :cancel == Ops.get(event, "ID") || :back == Ops.get(event, "ID") # There is only a "Cancel" functionality (via the "back" button) which goes back one step # and the button with the "abort" functionality is not shown at all (see dialogs.ycp). # Unfortunately when the YaST package installer is run via Printerlib::TestAndInstallPackage # it leaves a misused "abort" button labeled "Skip Autorefresh" with WidgetID "`abort" # so that this case is mapped to the "Cancel" functionality: return :printing_via_network_back end if :next == Ops.get(event, "ID") if !ApplyNetworkPrintingSettings() Popup.Error(_("Failed to apply the settings to the system.")) # In case of an error stay on the "Print via Network" dialog # so that the user can either change his settings until it works # or he can use the [Cancel] button to return to the Overview dialog: #Does not work: #return nil; end if !@printing_via_network_has_changed Builtins.y2milestone( "Nothing changed in 'Printing via Network' dialog." ) else # when something was to be changed, # enforce to show also remote queues in the "Overview" # in particular when no local queues were shown before: Printer.queue_filter_show_remote = true end return :printing_via_network_next end if :connection_wizard == Ops.get(event, "ID") # so that the getCurrentDeviceURI function in connectionwizard.ycp fails # to avoid that the URI of whatever preselected queue in the Overview dialog # becomes preselected in the Connection Wizard which should actually # start without any preselection because a new queue is to be set up # when the Connection Wizard is called from the Print via Network dialog: Printer.selected_connections_index = -1 Printer.selected_queues_index = -1 return :printing_via_network_connection_wizard end if :test_client_conf_server == Ops.get(event, "ID") current_client_conf_input_value = Convert.to_string( UI.QueryWidget(Id(:client_conf_input), :Value) ) server_name = Builtins.deletechars( Builtins.tolower(current_client_conf_input_value), " " ) # No need for error popups because TestClientOnlyServer shows sufficient error popups: if Printer.TestClientOnlyServer(server_name) Popup.Message( Builtins.sformat( # where %1 will be replaced by the server name. _("The server '%1' is accessible via port 631 (IPP/CUPS)."), server_name ) # Popup message ) end end end nil end |
- (Object) initialize_printer_printingvianetwork(include_target)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File '../../src/include/printer/printingvianetwork.rb', line 30 def initialize_printer_printingvianetwork(include_target) Yast.import "UI" textdomain "printer" Yast.import "Printer" Yast.import "Printerlib" Yast.import "Popup" Yast.include include_target, "printer/helps.rb" @printing_via_network_has_changed = false @initial_browsing = false @initial_browse_allow = nil @initial_browse_allow_input_value = "" @initial_browse_poll = false @initial_browse_poll_input_value = "" @initial_client_only = false @initial_client_conf_input_value = "" @browsing_firewall_popup_was_shown = false # An entry for a ComboBox from which the user can select # that printer information is not accepted from any remote CUPS servers: @browse_allow_none_string = _("do not accept any printer announcement") # An entry for a ComboBox from which the user can select # that printer information is accepted from # all remote CUPS servers: @browse_allow_all_string = _("accept all announcements from anywhere") # An entry for a ComboBox from which the user can select # that printer information is accepted from # remote CUPS servers in the local network: @browse_allow_local_string = _( "accept from all hosts in the local network" ) # An entry for a ComboBox from which the user can select # that printer information is accepted only from # remote CUPS servers with specific addresses # where the specific addresses are specified in a TextEntry below: @browse_allow_specific_string = _( "accept only from the specific addresses below" ) @widgetNetworkPrinting = VBox( VStretch(), Frame( _("Use CUPS to Print Via Network"), VBox( Left( CheckBox( Id(:browsing_check_box), Opt(:notify), # A CheckBox to accept printer information from remote CUPS servers: _("&Accept Printer Announcements from CUPS Servers"), true ) ), Left( HBox( HSpacing(4), VBox( Left( ComboBox( Id(:browse_allow_combo_box), Opt(:notify), # A header for a ComboBox from which the user can select # a usual general setting from which remote CUPS servers # printer information is accepted: _("&General Setting"), [ Item( Id(:browse_allow_none), @browse_allow_none_string, true ), Item(Id(:browse_allow_all), @browse_allow_all_string), Item( Id(:browse_allow_local), @browse_allow_local_string ), Item( Id(:browse_allow_specific), @browse_allow_specific_string ) ] ) ), Left( TextEntry( Id(:browse_allow_input), # A header for a TextEntry where the user can additionally # enter specific IP addresses and/or network/netmask # from where remote printer information is accepted: _( "Additional IP Addresses or &Network/Netmask (separated by space)" ) ) ) ) ) ), Left( CheckBox( Id(:browse_poll_check_box), Opt(:notify), # A CheckBox to poll printer information from remote CUPS servers: _("&Request Printer Information from CUPS Servers"), false ) ), Left( HBox( HSpacing(4), TextEntry( Id(:browse_poll_input), # A header for a TextEntry where the user can enter # CUPS server names and/or IP addresses # from where remote printer information is polled: _( "Polled CUPS server names or &IP Addresses (separated by space)" ) ) ) ), Left( CheckBox( Id(:client_only_check_box), Opt(:notify), # A CheckBox to do all printing tasks directly # only via one single remote CUPS server: _("&Do All Printing Directly via One Single CUPS Server"), false ) ), Left( HBox( HSpacing(4), TextEntry( Id(:client_conf_input), # A header for a TextEntry where the user can enter # the one single remote CUPS server which is used # to do all his printing tasks: _("&One single CUPS server name or IP Address") ), VBox( Label(""), PushButton( Id(:test_client_conf_server), # A PushButton to test whether or not the one single remote CUPS server # which is used to do all printing tasks is accessible: _("&Test Server") ) ), HStretch() ) ) ) ), # A caption for a Frame to set up to use CUPS to print via network: VStretch(), Frame( # or to set up to use a network printer directly: _("Use Another Print Server or Use a Network Printer Directly"), Left( PushButton( Id(:connection_wizard), # Label of a PushButton to go to the "Connection Wizard" # to specify the printer connection individually: _("Connection &Wizard") ) ) ), # A caption for a Frame to set up to use another (i.e. non-CUPS) print server VStretch() ) end |
- (Object) initNetworkPrinting(key)
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
# File '../../src/include/printer/printingvianetwork.rb', line 740 def initNetworkPrinting(key) Builtins.y2milestone("entering initNetworkPrinting with key '%1'", key) # Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf # and ignore when it fails (i.e. use the fallback value silently): Printerlib.DetermineBrowsing # Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' # values in /etc/cups/cupsd.conf and ignore when it fails (i.e. use the fallback value silently): Printerlib.DetermineBrowseAllow # Determine the 'BrowsePoll [IP-address]' values in /etc/cups/cupsd.conf # and ignore when it fails (i.e. use the fallback value silently): Printerlib.DetermineBrowsePoll # Determine the 'ServerName' value in /etc/cups/client.conf # and ignore when it fails (i.e. use the fallback value silently): Printerlib.DetermineClientOnly Builtins.y2milestone( "system values in initNetworkPrinting:\n" + "cupsd_conf_browsing_on = '%1'\n" + "cupsd_conf_browse_allow = '%2'\n" + "cupsd_conf_browse_poll = '%3'\n" + "client_only = '%4'\n" + "client_conf_server_name = '%5'", Printerlib.cupsd_conf_browsing_on, Printerlib.cupsd_conf_browse_allow, Printerlib.cupsd_conf_browse_poll, Printerlib.client_only, Printerlib.client_conf_server_name ) # Have all widgets disabled initially and preset them with fallback values here # but nevertheless fill in the values of the current settings in the system later # regardless if a widget is disabled or not, see "Make the actual ... settings" below: UI.ChangeWidget(Id(:browsing_check_box), :Value, false) @initial_browsing = false UI.ChangeWidget(Id(:browse_allow_combo_box), :Enabled, false) UI.ChangeWidget( Id(:browse_allow_combo_box), :Value, Id(:browse_allow_specific) ) @initial_browse_allow = :browse_allow_specific UI.ChangeWidget(Id(:browse_allow_input), :Enabled, false) UI.ChangeWidget(Id(:browse_allow_input), :Value, "") @initial_browse_allow_input_value = "" UI.ChangeWidget(Id(:browse_poll_check_box), :Value, false) @initial_browse_poll = false UI.ChangeWidget(Id(:browse_poll_input), :Enabled, false) UI.ChangeWidget(Id(:browse_poll_input), :Value, "") @initial_browse_poll_input_value = "" UI.ChangeWidget(Id(:client_only_check_box), :Value, false) @initial_client_only = false UI.ChangeWidget(Id(:client_conf_input), :Enabled, false) UI.ChangeWidget(Id(:client_conf_input), :Value, "") @initial_client_conf_input_value = "" UI.ChangeWidget(Id(:test_client_conf_server), :Enabled, false) # Only the "Connection Wizard" button is enabled by default # and disabled in case of "client_only" (see "Client only settings" below) # and also disabled in case of Printer::printer_auto_dialogs. UI.ChangeWidget(Id(:connection_wizard), :Enabled, true) # Make the actual Browsing settings: # If "none" is present as a BrowseAllow value it is actually no Browsing config. # If the BrowseAllow values are effectively empty it is also no Browsing config. # If there is an active ServerName (!="localhost") in /etc/cups/client.conf # it is actually a client-only config and therefore also actually no Browsing config: if Printerlib.cupsd_conf_browsing_on && !Builtins.contains(Printerlib.cupsd_conf_browse_allow, "none") && "" != Builtins.filterchars( Builtins.mergestring(Printerlib.cupsd_conf_browse_allow, ""), Printer.alnum_chars ) && !Printerlib.client_only UI.ChangeWidget(Id(:browsing_check_box), :Value, true) @initial_browsing = true UI.ChangeWidget(Id(:browse_allow_combo_box), :Enabled, true) # When it is actually a Browsing config # test whether or not a firewall seems to be active and # if yes show a popup regarding firewall if it was not yet shown: if !@browsing_firewall_popup_was_shown if ShowBrowsingFirewallPopup() @browsing_firewall_popup_was_shown = true end end else # for the browse_allow_combo_box so that the user can easily switch # only via the browsing_check_box to a reasonable Browsing config # without the need for further adjustments in the browse_allow_combo_box: UI.ChangeWidget( Id(:browse_allow_combo_box), :Value, Id(:browse_allow_local) ) @initial_browse_allow = :browse_allow_local # The value of browsing_firewall_popup_was_shown is kept as long as the # whole yast2-printer module runs so that the user could launch this dialog # several times in one module run and switch between a Browsing config # and no Browsing config several times in one run of the yast2-printer module. # When in the previous run of this dialog a no Browsing config was set up # but in the current run of this dialog it was switched back to a Browsing config # make sure in the current run of this dialog the popup regarding firewall # is shown again during ApplyNetworkPrintingSettings(): @browsing_firewall_popup_was_shown = false end # Fill in the Browsing values of the current settings in the system # regardless if it is actually a Browsing config or not (see above). # When by accident "all" and "@LOCAL" were set as BrowseAllow values, # the "@LOCAL" entry is preselected in browse_allow_combo_box # because this is the more secure setting. # When "none" is one of the BrowseAllow values, # the "none" entry is preselected in browse_allow_combo_box # because this is the most secure setting. if Builtins.contains(Printerlib.cupsd_conf_browse_allow, "all") UI.ChangeWidget( Id(:browse_allow_combo_box), :Value, Id(:browse_allow_all) ) @initial_browse_allow = :browse_allow_all # If browsing info is accepted from "all" hosts # it would be useless to additionally accept it from specific IPs or networks. end if Builtins.contains(Printerlib.cupsd_conf_browse_allow, "@LOCAL") UI.ChangeWidget( Id(:browse_allow_combo_box), :Value, Id(:browse_allow_local) ) @initial_browse_allow = :browse_allow_local UI.ChangeWidget(Id(:browse_allow_input), :Enabled, true) end if Builtins.contains(Printerlib.cupsd_conf_browse_allow, "none") UI.ChangeWidget( Id(:browse_allow_combo_box), :Value, Id(:browse_allow_none) ) @initial_browse_allow = :browse_allow_none # If browsing info is accepted from "none" hosts # it would be contradicting to additionally accept it from specific IPs or networks. end # The preset entry in the browse_allow_input field # should not contain "all" or "@LOCAL" or "none" # because those are selectable via browse_allow_combo_box: browse_allow_input_value = Builtins.mergestring( Builtins.filter(Printerlib.cupsd_conf_browse_allow) do |value| value = Builtins.tolower(value) "all" != value && "@local" != value && "none" != value end, " " ) if "" != Builtins.filterchars(browse_allow_input_value, Printer.alnum_chars) browse_allow_input_value = Ops.add(browse_allow_input_value, " ") UI.ChangeWidget(Id(:browse_allow_input), :Enabled, true) UI.ChangeWidget( Id(:browse_allow_input), :Value, browse_allow_input_value ) @initial_browse_allow_input_value = browse_allow_input_value if @initial_browse_allow != :browse_allow_none && @initial_browse_allow != :browse_allow_all # it would be contradicting to accept it from specific IPs or networks # and if browsing info is accepted from all hosts, # it is useless to additionally accept it from specific IPs or networks: UI.ChangeWidget(Id(:browse_allow_input), :Enabled, true) end end # Make the actual BrowsePoll settings: browse_poll_input_value = Builtins.mergestring( Printerlib.cupsd_conf_browse_poll, " " ) if "" != Builtins.filterchars(browse_poll_input_value, Printer.alnum_chars) if !Printerlib.client_only # it is actually a client-only config and therefore also actually no Browsing config. UI.ChangeWidget(Id(:browse_poll_check_box), :Value, true) @initial_browse_poll = true UI.ChangeWidget(Id(:browse_poll_input), :Enabled, true) end # Have a trailing space character so that the user can easily add something: browse_poll_input_value = Ops.add(browse_poll_input_value, " ") # Fill in the BrowsePoll values of the current settings in the system # regardless if it is actually a BrowsePoll config or not (see above): UI.ChangeWidget(Id(:browse_poll_input), :Value, browse_poll_input_value) @initial_browse_poll_input_value = browse_poll_input_value end # Make the actual client-only settings: if Printerlib.client_only UI.ChangeWidget(Id(:client_only_check_box), :Value, true) @initial_client_only = true UI.ChangeWidget(Id(:client_conf_input), :Enabled, true) UI.ChangeWidget(Id(:test_client_conf_server), :Enabled, true) # The "Connection Wizard" button is disabled in case of "client_only". # In this case it is never again enabled as long as the dialog runs # because the user can select one of the radio buttons # to receive or not receive printer information via CUPS Browsing # which would switch from "client_only" to a local running cupsd # but only when finishing the dialog via ApplyNetworkPrintingSettings(). # Therefore in case of "client_only" to use a network printer directly # the user must first switch from "client_only" to a local running cupsd # (e.g. by changing the client-only server to the empty string or to 'none') # and close the dialog to apply this change and re-launch the dialog afterwards. UI.ChangeWidget(Id(:connection_wizard), :Enabled, false) end # Fill in the client-only values of the current settings in the system # regardless if it is actually a client-only config or not (see above): UI.ChangeWidget( Id(:client_conf_input), :Value, Printerlib.client_conf_server_name ) if Printer.printer_auto_dialogs # (by calling in printer_auto.ycp the "Change" function) # it does not make sense to let the user set up a local queue # for a network printer via the "Connection Wizard": UI.ChangeWidget(Id(:connection_wizard), :Enabled, false) end @initial_client_conf_input_value = Printerlib.client_conf_server_name Builtins.y2milestone( "leaving initNetworkPrinting with\n" + "initial_browsing = '%1'\n" + "initial_browse_allow = '%2'\n" + "initial_browse_allow_input_value = '%3'\n" + "initial_browse_poll = '%4'\n" + "initial_browse_poll_input_value = '%5'\n" + "initial_client_only = '%6'\n" + "initial_client_conf_input_value = '%7'", @initial_browsing, @initial_browse_allow, @initial_browse_allow_input_value, @initial_browse_poll, @initial_browse_poll_input_value, @initial_client_only, @initial_client_conf_input_value ) nil end |
- (Object) ShowBrowsingFirewallPopup
203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File '../../src/include/printer/printingvianetwork.rb', line 203 def ShowBrowsingFirewallPopup if Printerlib.FirewallSeemsToBeActive Popup.AnyMessage( # Use the exact same wording "printer announcements from CUPS servers" # as in the matching CheckBox to accept printer information from remote CUPS servers: _("A firewall may reject printer announcements from CUPS servers"), # Popup::AnyMessage message: _("Regarding firewall setup see the help text of this dialog.") ) return true end false end |