Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.6 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: PrintInstallationUnit.cpp
  4. //
  5. // Synopsis: Defines a PrintInstallationUnit
  6. // This object has the knowledge for installing the
  7. // printer services
  8. //
  9. // History: 02/06/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "PrintInstallationUnit.h"
  13. // Finish page help
  14. static PCWSTR CYS_PRINT_FINISH_PAGE_HELP = L"cys.chm::/cys_configuring_print_server.htm";
  15. PrintInstallationUnit::PrintInstallationUnit() :
  16. forAllClients(false),
  17. InstallationUnit(
  18. IDS_PRINT_SERVER_TYPE,
  19. IDS_PRINT_SERVER_DESCRIPTION,
  20. CYS_PRINT_FINISH_PAGE_HELP,
  21. PRINTSERVER_INSTALL)
  22. {
  23. LOG_CTOR(PrintInstallationUnit);
  24. }
  25. PrintInstallationUnit::~PrintInstallationUnit()
  26. {
  27. LOG_DTOR(PrintInstallationUnit);
  28. }
  29. InstallationReturnType
  30. PrintInstallationUnit::InstallService(HANDLE logfileHandle, HWND /*hwnd*/)
  31. {
  32. LOG_FUNCTION(PrintInstallationUnit::InstallService);
  33. InstallationReturnType result = INSTALL_SUCCESS;
  34. String resultText;
  35. // Always execute the Add Printer Wizard
  36. CYS_APPEND_LOG(String::load(IDS_PRINTER_WIZARD_CONFIG_LOG_TEXT));
  37. if (ExecuteWizard(CYS_PRINTER_WIZARD_NAME, resultText))
  38. {
  39. LOG(L"Add Printer Wizard succeeded");
  40. }
  41. else
  42. {
  43. LOG(L"Add Printer Wizard failed");
  44. result = INSTALL_FAILURE;
  45. }
  46. if (!resultText.empty())
  47. {
  48. CYS_APPEND_LOG(resultText);
  49. }
  50. if (forAllClients)
  51. {
  52. // Now execute the Add Printer Driver Wizard
  53. if (ExecuteWizard(CYS_PRINTER_DRIVER_WIZARD_NAME, resultText))
  54. {
  55. LOG(L"Add Printer Driver Wizard succeeded");
  56. }
  57. else
  58. {
  59. LOG(L"Add Printer Driver Wizard failed");
  60. result = INSTALL_FAILURE;
  61. }
  62. if (!resultText.empty())
  63. {
  64. CYS_APPEND_LOG(resultText);
  65. }
  66. }
  67. LOG_INSTALL_RETURN(result);
  68. return result;
  69. }
  70. bool
  71. PrintInstallationUnit::IsServiceInstalled()
  72. {
  73. LOG_FUNCTION(PrintInstallationUnit::IsServiceInstalled);
  74. // It is always possible to start the print wizards so
  75. // we just say that it is never installed.
  76. LOG_BOOL(false);
  77. return false;
  78. }
  79. bool
  80. PrintInstallationUnit::GetFinishText(String& message)
  81. {
  82. LOG_FUNCTION(PrintInstallationUnit::GetFinishText);
  83. if (forAllClients)
  84. {
  85. message += String::load(IDS_PRINT_FINISH_ALL_CLIENTS);
  86. }
  87. else
  88. {
  89. message += String::load(IDS_PRINT_FINISH_W2K_CLIENTS);
  90. }
  91. LOG_BOOL(true);
  92. return true;
  93. }
  94. void
  95. PrintInstallationUnit::SetClients(bool allclients)
  96. {
  97. LOG_FUNCTION2(
  98. PrintInstallationUnit::SetClients,
  99. allclients ? L"true" : L"false");
  100. forAllClients = allclients;
  101. }