Leaked source code of windows server 2003
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.

247 lines
9.4 KiB

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved.
  7. //
  8. // FILE: Features.h
  9. //
  10. //
  11. // PURPOSE: Defines wrapper class for WinXP PS Features and Options.
  12. //
  13. //
  14. // PLATFORMS: Windows XP, Windows Server 2003
  15. //
  16. //
  17. #ifndef _FEATURES_H
  18. #define _FEATURES_H
  19. #include "precomp.h"
  20. #include "helper.h"
  21. ////////////////////////////////////////////////////////
  22. // Defines and Macros
  23. ////////////////////////////////////////////////////////
  24. ////////////////////////////////////////////////////////
  25. // Type Definitions
  26. ////////////////////////////////////////////////////////
  27. // Struct used to map keyword to information
  28. // such as display name and stickiness.
  29. typedef struct _tagKeywordMap
  30. {
  31. PCSTR pszKeyword;
  32. PCWSTR pwszModule;
  33. UINT uDisplayNameID;
  34. DWORD dwMode;
  35. DWORD dwFlags;
  36. } KEYWORDMAP, *PKEYWORDMAP;
  37. // Struct container for info about
  38. // feature that is in conflict.
  39. typedef struct _tagConflict
  40. {
  41. PCSTR pszFeatureKeyword;
  42. PCWSTR pszFeature;
  43. PSTR pszOptionKeyword;
  44. PWSTR pszOption;
  45. PSTR pmszReasons;
  46. DWORD dwReasonsSize;
  47. } CONFLICT, *PCONFLICT;
  48. ////////////////////////////////////////////////////////
  49. // Class Definitions
  50. ////////////////////////////////////////////////////////
  51. // Class wrapper and container for Core Driver Feature Options.
  52. class COptions
  53. {
  54. private:
  55. // Option Infomation
  56. class OPTION_INFO
  57. {
  58. public:
  59. PKEYWORDMAP pMapping;
  60. PWSTR pszDisplayName;
  61. public:
  62. OPTION_INFO()
  63. {
  64. pMapping = NULL;
  65. pszDisplayName = NULL;
  66. }
  67. virtual ~OPTION_INFO(){}
  68. };
  69. typedef class OPTION_INFO *POPTION_INFO;
  70. // Data Members
  71. WORD m_wOptions; // Count of the number of options contained for an instance of the class.
  72. BYTE m_cType; // CPSUI Option Type (i.e. what to set pOptItem->pOptType->Type to).
  73. PSTR m_pmszRaw; // The RAW multi NULL terminated string buffer used for IPrintCoreUI2::EnumOptions().
  74. PCSTR m_pszFeature; // Pointer to the feature for which the enumerate options belong.
  75. PCSTR *m_ppszOptions; // String list pointer that points to begining of each of the strings in multi-SZ pointed to by m_pmszRaw.
  76. POINT m_ptRange; // Option range for features, such as %JobTimeout, that have a range of possible vaules not a small selection list.
  77. DWORD m_dwSize; // Size of m_pmszRaw buffer.
  78. PWSTR m_pszUnits; // String that contains the unit specifier for options, such as %JobTimeout, which need Units (i.e. seconds).
  79. HANDLE m_hHeap; // Heap to do allocations from.
  80. POPTION_INFO m_pInfo; // Array of Info about each option for a feature.
  81. union { // Current selected option for a feature.
  82. LONG m_Sel; // This is what pOptItem->m_pSel or pOptItem->m_Sel
  83. LPTSTR m_pSel; // will be set to.
  84. };
  85. public:
  86. COptions();
  87. virtual ~COptions();
  88. // Populate Options list for specified keyword.
  89. HRESULT COptions::Acquire(HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj,
  90. PCSTR pszFeature);
  91. // Returns number of feature options contained in class instance.
  92. inline WORD GetCount() const {return m_wOptions;}
  93. // Returns selection.
  94. inline LPTSTR GetSelection() const {return m_pSel;}
  95. // Return nth options keyword.
  96. PCSTR GetKeyword(WORD wIndex) const;
  97. // Return nth option Display Name.
  98. PCWSTR GetName(WORD wIndex) const;
  99. // Find option with matching keyword string.
  100. WORD FindOption(PCSTR pszOption, WORD wDefault) const;
  101. // Initializes options portion of OPTITEM.
  102. HRESULT InitOptItem(HANDLE hHeap, POPTITEM pOptItem);
  103. // Refresh option selection.
  104. HRESULT RefreshSelection(CUIHelper &Helper, POEMUIOBJ poemuiobj);
  105. private:
  106. void Init();
  107. void Clear();
  108. void FreeOptionInfo();
  109. HRESULT GetOptionsForSpecialFeatures(CUIHelper &Helper, POEMUIOBJ poemuiobj);
  110. HRESULT GetOptionsForOutputPSLevel(CUIHelper &Helper, POEMUIOBJ poemuiobj);
  111. HRESULT GetOptionSelectionString(CUIHelper &Helper, POEMUIOBJ poemuiobj, PSTR *ppszSel);
  112. HRESULT GetOptionSelectionLong(CUIHelper &Helper, POEMUIOBJ poemuiobj);
  113. HRESULT GetOptionSelectionShort(CUIHelper &Helper, POEMUIOBJ poemuiobj);
  114. HRESULT GetOptionSelectionIndex(CUIHelper &Helper, POEMUIOBJ poemuiobj);
  115. };
  116. // Class wrapper and container for Cor Driver Features.
  117. class CFeatures
  118. {
  119. private:
  120. // Feature Infomation
  121. class FEATURE_INFO
  122. {
  123. public:
  124. PKEYWORDMAP pMapping;
  125. PWSTR pszDisplayName;
  126. COptions Options;
  127. DWORD dwMode;
  128. public:
  129. FEATURE_INFO()
  130. {
  131. pMapping = NULL;
  132. pszDisplayName = NULL;
  133. dwMode = 0;
  134. }
  135. virtual ~FEATURE_INFO() {}
  136. };
  137. typedef class FEATURE_INFO *PFEATURE_INFO;
  138. WORD m_wFeatures; // Count of the number of features.
  139. WORD m_wDocFeatures; // Count of the number of Document sticky features.
  140. WORD m_wPrintFeatures; // Count of the number of Printer sticky features.
  141. PSTR m_pmszRaw; // Buffer for multi-SZ for call to IPrintCoreUI2::EnumFeatures.
  142. PCSTR *m_ppszKeywords; // String list that points to each of the strings in m_pmszRaw.
  143. DWORD m_dwSize; // Size of m_pmszRaw.
  144. HANDLE m_hHeap; // Heap to do allocations from.
  145. PFEATURE_INFO m_pInfo; // Array of feature information about each of the enumerate features.
  146. public:
  147. CFeatures();
  148. virtual ~CFeatures();
  149. // Populates the Feature list
  150. HRESULT Acquire(HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj);
  151. // Returns number of features contained in class instance.
  152. WORD GetCount(DWORD dwMode = 0) const;
  153. // Returns feature keyword.
  154. PCSTR GetKeyword(WORD wIndex, DWORD dwMode = 0) const;
  155. // Return feature Display Name.
  156. PCWSTR GetName(WORD wIndex, DWORD dwMode = 0) const;
  157. // Returns pointer to option class for nth feature.
  158. COptions* GetOptions(WORD wIndex, DWORD dwMode = 0) const;
  159. // Initializes OPTITEM for the feature.
  160. HRESULT InitOptItem(HANDLE hHeap, POPTITEM pOptItem, WORD wIndex, DWORD dwMode);
  161. private:
  162. void Init();
  163. void Clear();
  164. void FreeFeatureInfo();
  165. WORD GetModelessIndex(WORD wIndex, DWORD dwMode) const;
  166. };
  167. ////////////////////////////////////////////////////////
  168. // Prototypes
  169. ////////////////////////////////////////////////////////
  170. HRESULT DetermineFeatureDisplayName(HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj,
  171. PCSTR pszKeyword, const PKEYWORDMAP pMapping,
  172. PWSTR *ppszDisplayName);
  173. HRESULT DetermineOptionDisplayName(HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj,
  174. PCSTR pszFeature, PCSTR pszOption,
  175. const PKEYWORDMAP pMapping, PWSTR *ppszDisplayName);
  176. HRESULT DetermineStickiness(CUIHelper &Helper, POEMUIOBJ poemuiobj, PCSTR pszKeyword,
  177. const PKEYWORDMAP pMapping,PDWORD pdwMode);
  178. PKEYWORDMAP FindKeywordMapping(PKEYWORDMAP pKeywordMap, WORD wMapSize, PCSTR pszKeyword);
  179. HRESULT GetDisplayNameFromMapping(HANDLE hHeap, PKEYWORDMAP pMapping, PWSTR *ppszDisplayName);
  180. BOOL IsFeatureOptitem(POPTITEM pOptItem);
  181. HRESULT SaveFeatureOptItems(HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj,
  182. HWND hWnd, POPTITEM pOptItem, WORD wItems);
  183. HRESULT GetWhyConstrained(HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj,
  184. PCSTR pszFeature, PCSTR pszOption, PSTR *ppmszReason,
  185. PDWORD pdwSize);
  186. HRESULT GetChangedFeatureOptions(HANDLE hHeap, POPTITEM pOptItem, WORD wItems,
  187. PSTR *ppmszPairs, PWORD pdwPairs, PDWORD pdwSize);
  188. PSTR GetOptionKeywordFromOptItem(HANDLE hHeap, POPTITEM pOptItem);
  189. PWSTR GetOptionDisplayNameFromOptItem(HANDLE hHeap, POPTITEM pOptItem);
  190. HRESULT RefreshOptItemSelection(CUIHelper *pHelper, POEMUIOBJ poemuiobj, POPTITEM pOptItems,
  191. WORD wItems);
  192. HRESULT GetFirstConflictingFeature(HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj,
  193. POPTITEM pOptItem, WORD wItems, PCONFLICT pConflict);
  194. #endif