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.

269 lines
10 KiB

  1. //
  2. #ifndef _PROPITEM_H
  3. #define _PROPITEM_H
  4. const TCHAR c_szNumAlt[] = TEXT("NumAlt");
  5. const TCHAR c_szMasterLM[] = TEXT("MasterLM");
  6. const TCHAR c_szCtxtFeed[] = TEXT("ContextFeed");
  7. const TCHAR c_szEnableLMA[] = TEXT("EnableLMA");
  8. const TCHAR c_szSerialize[] = TEXT("Serialize");
  9. const TCHAR c_szDictModebias[] = TEXT("DictModebias");
  10. // const TCHAR c_szDocBlockSize[] = TEXT("docblocksize");
  11. // const TCHAR c_szMaxCandChars[] = TEXT("MaxCandChars");
  12. const TCHAR c_szDictCmd[] = TEXT("DictationCommands"); // Enable / Disbale commands in Dictation mode
  13. const TCHAR c_szKeyboardCmd[] = TEXT("KeyboardCmd");
  14. const TCHAR c_szSelectCmd[] = TEXT("SelectCmd");
  15. const TCHAR c_szNavigateCmd[] = TEXT("NavigateCmd");
  16. const TCHAR c_szCaseCmd[] = TEXT("CasingCmd");
  17. const TCHAR c_szEditCmd[] = TEXT("EditCmd");
  18. const TCHAR c_szLangBarCmd[] = TEXT("LangBarCmd");
  19. const TCHAR c_szTTSCmd[] = TEXT("TTSCmd");
  20. const TCHAR c_szModeButton[] = TEXT("ModeButton");
  21. const TCHAR c_szDictKey[] = TEXT("DictationKey");
  22. const TCHAR c_szCmdKey[] = TEXT("CommandKey");
  23. const TCHAR c_szHighConf[] = TEXT("HighConfidenceForShortWord");
  24. const TCHAR c_szRemoveSpace[] = TEXT("RemoveSpaceForSymbol");
  25. const TCHAR c_szDisDictTyping[] = TEXT("DisableDictTyping");
  26. const TCHAR c_szPlayBack[] = TEXT("PlayBackCandUI");
  27. const TCHAR c_szDictCandOpen[] = TEXT("DictCandOpen");
  28. #define UNINIT_VALUE 0xffff
  29. //
  30. // Take use of the below enum type as a common status type to replace
  31. // the many previous similar enum types for different individual items,
  32. // such as KEYCMD, LMSTAT, GSTAT, DICTCMD, etc.
  33. //
  34. typedef enum
  35. {
  36. PROP_UNINITIALIZED = 0x0,
  37. PROP_ENABLED = 0x1,
  38. PROP_DISABLED = 0x2
  39. } PROP_STATUS;
  40. typedef enum
  41. {
  42. PropId_Min_Item_Id = 0,
  43. // Property Items in the top property page.
  44. PropId_Min_InPropPage = 0,
  45. PropId_Hide_Balloon = 0, // Enable/Disable hiding speech balloon
  46. PropId_Support_LMA = 1, // Enable/Disable LMA Support
  47. PropId_High_Confidence = 2, // Require High Confidence for short words
  48. PropId_Save_Speech_Data = 3, // Enable/Disable Save Speech Data
  49. PropId_Remove_Space = 4, // Enable removing whitespace for punctations
  50. PropId_DisDict_Typing = 5, // Support disabling dictation while typing
  51. PropId_PlayBack = 6, // Enable playback audio while candidate UI is to open.
  52. PropId_Dict_CandOpen = 7, // Allow dictation while candidate UI is open.
  53. PropId_Cmd_DictMode = 8, // Enable/Disable all commands in dictation mode
  54. PropId_Mode_Button = 9, // Enable/Disable Mode Buttons
  55. PropId_MaxId_InPropPage = 9,
  56. // Property Items in the voice command setting dialog
  57. PropId_MinId_InVoiceCmd = 10,
  58. PropId_Cmd_Select_Correct = 10, // Enable/Disable Selection commands
  59. PropId_Cmd_Navigation = 11, // Enalbe/Disable Navigation commands
  60. PropId_Cmd_Casing = 12, // Enable/Disable Casing Commands
  61. PropId_Cmd_Editing = 13, // Enable/Disable Editing Commands
  62. PropId_Cmd_Keyboard = 14, // Enable/Disable Keyboard simulation commands
  63. PropId_Cmd_TTS = 15, // Enable/Disable TTS commands
  64. PropId_Cmd_Language_Bar = 16, // Enable/Disalbe Langauge Bar commands
  65. PropId_MaxId_InVoiceCmd = 16,
  66. // Property Items in the Mode button setting dialog
  67. PropId_MinId_InModeButton = 17,
  68. PropId_Dictation_Key = 17, // Virtual key for Dictation Key
  69. PropId_Command_Key = 18, // Virtual key for Command Key
  70. PropId_MaxId_InModeButton = 18,
  71. // Property items which are not configurable through property page.
  72. PropId_Max_Alternates = 19, // Maximum number of alternates
  73. PropId_MaxChar_Cand = 20, // Maximum number of candidate characters
  74. PropId_Context_Feeding = 21, // Enable/Disable Context Feeding
  75. PropId_Dict_ModeBias = 22, // Enable/Disable Dictation while ModeBias
  76. PropId_LM_Master_Cand = 23, // Enable/Disable Master LM for candidates
  77. PropId_Max_Item_Id = 24
  78. } PROP_ITEM_ID;
  79. typedef struct _Prop_Item
  80. {
  81. PROP_ITEM_ID idPropItem;
  82. const TCHAR *lpszValueName;
  83. GUID *pguidComp;
  84. DWORD dwMaskBit;
  85. BOOL fIsStatus; // TRUE means this is Enable/Disable item
  86. // FALSE means this is a value item, DWORD
  87. union
  88. {
  89. DWORD dwDefault;
  90. PROP_STATUS psDefault;
  91. };
  92. } PROP_ITEM;
  93. class _declspec(novtable) CPropItem
  94. {
  95. public:
  96. CPropItem(PROP_ITEM_ID idPropItem, LPCTSTR lpszValueName, PROP_STATUS psDefault);
  97. CPropItem(PROP_ITEM_ID idPropItem, LPCTSTR lpszValueName, DWORD dwDefault);
  98. CPropItem(PROP_ITEM_ID idPropItem, GUID *pguidComp, DWORD dwMaskBit, PROP_STATUS psDefault);
  99. CPropItem(CPropItem *pItem);
  100. ~CPropItem( );
  101. BOOL GetPropStatus(BOOL fForceFromReg=FALSE);
  102. DWORD GetPropValue(BOOL fForceFromReg=FALSE );
  103. void SetPropStatus(BOOL fEnable);
  104. void SetPropValue(DWORD dwValue);
  105. void SavePropData( );
  106. void SaveDefaultRegValue( );
  107. BOOL IsStatusPropItem( ) { return m_fIsStatus; }
  108. PROP_ITEM_ID GetPropItemId( ) { return m_PropItemId; }
  109. BOOL IsGlobalCompartPropItem( ) { return ((m_pguidComp && !m_lpszValueName) ? TRUE : FALSE); }
  110. TCHAR *GetRegValue( ) { return m_lpszValueName; }
  111. GUID *GetCompGuid( ) { return m_pguidComp; }
  112. DWORD GetMaskBit( ) { return m_dwMaskBit; }
  113. PROP_STATUS GetPropDefaultStatus( ) { return m_psDefault; }
  114. DWORD GetPropDefaultValue( ) { return m_dwDefault; }
  115. private:
  116. HRESULT _GetRegValue(HKEY hRootKey, DWORD *dwValue);
  117. void _SetRegValue(HKEY hRootKey, DWORD dwValue);
  118. PROP_ITEM_ID m_PropItemId;
  119. TCHAR *m_lpszValueName;
  120. GUID *m_pguidComp;
  121. DWORD m_dwMaskBit;
  122. BOOL m_fIsStatus; // TRUE means this prop keeps bool (Enable/Disable).
  123. // FALSE means this prop keeps raw data (ulong).
  124. union
  125. {
  126. DWORD m_dwDefault;
  127. PROP_STATUS m_psDefault;
  128. };
  129. union
  130. {
  131. DWORD m_dwValue;
  132. PROP_STATUS m_psStatus;
  133. };
  134. };
  135. class __declspec(novtable) CSpPropItemsServer
  136. {
  137. public:
  138. CSpPropItemsServer( );
  139. CSpPropItemsServer(CSpPropItemsServer *pItemBaseServer, PROP_ITEM_ID idPropMin, PROP_ITEM_ID idPropMax);
  140. ~CSpPropItemsServer( );
  141. CPropItem *_GetPropItem(PROP_ITEM_ID idPropItem);
  142. DWORD _GetPropData(PROP_ITEM_ID idPropItem, BOOL fForceFromReg=FALSE );
  143. DWORD _GetPropDefaultData(PROP_ITEM_ID idPropItem);
  144. void _SetPropData(PROP_ITEM_ID idPropItem, DWORD dwData);
  145. void _SavePropData( );
  146. void _SaveDefaultData( );
  147. DWORD _GetNumPropItems( ) { return m_dwNumOfItems; }
  148. HRESULT _MergeDataFromServer(CSpPropItemsServer *pItemBaseServer, PROP_ITEM_ID idPropMin, PROP_ITEM_ID idPropMax);
  149. private:
  150. HRESULT _Initialize( );
  151. CPropItem **m_PropItems;
  152. BOOL m_fInitialized;
  153. DWORD m_dwNumOfItems;
  154. };
  155. //
  156. // This is a server wrap derived by CSapiIMX.
  157. //
  158. class __declspec(novtable) CSpPropItemsServerWrap : public CSpPropItemsServer
  159. {
  160. public:
  161. CSpPropItemsServerWrap( )
  162. {
  163. #if 0
  164. for (DWORD i=0; i<(DWORD)PropId_Max_Item_Id; i++)
  165. m_bChanged[i] = FALSE;
  166. #else
  167. memset(m_bChanged, 0, sizeof(m_bChanged));
  168. #endif
  169. };
  170. ~CSpPropItemsServerWrap( ){ };
  171. ULONG _GetMaxAlternates( );
  172. ULONG _GetMaxCandidateChars( );
  173. BOOL _MasterLMEnabled( ) { return (BOOL)_GetPropData(PropId_LM_Master_Cand); }
  174. BOOL _ContextFeedEnabled( ) { return (BOOL)_GetPropData(PropId_Context_Feeding); }
  175. BOOL _IsModeBiasDictationEnabled( ) { return (BOOL) _GetPropData(PropId_Dict_ModeBias); }
  176. BOOL _SerializeEnabled( ) { return (BOOL) _GetPropData(PropId_Save_Speech_Data);}
  177. BOOL _LMASupportEnabled( ) { return (BOOL) _GetPropData(PropId_Support_LMA); }
  178. BOOL _RequireHighConfidenceForShorWord( ) { return (BOOL) _GetPropData(PropId_High_Confidence); }
  179. BOOL _NeedRemovingSpaceForPunctation( ) { return (BOOL) _GetPropData(PropId_Remove_Space);}
  180. BOOL _NeedDisableDictationWhileTyping( ) { return (BOOL) _GetPropData(PropId_DisDict_Typing); }
  181. BOOL _EnablePlaybackWhileCandUIOpen( ) {return (BOOL) _GetPropData(PropId_PlayBack); }
  182. BOOL _AllowDictationWhileCandOpen( ) { return (BOOL) _GetPropData(PropId_Dict_CandOpen); }
  183. BOOL _SelectCorrectCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_Select_Correct); }
  184. BOOL _NavigationCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_Navigation); }
  185. BOOL _CasingCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_Casing); }
  186. BOOL _EditingCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_Editing); }
  187. BOOL _KeyboardCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_Keyboard); }
  188. BOOL _TTSCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_TTS); }
  189. BOOL _LanguageBarCmdEnabled( ) { return (BOOL) _GetPropData(PropId_Cmd_Language_Bar); }
  190. BOOL _AllDictCmdsDisabled( ) { return !(BOOL) _GetPropData(PropId_Cmd_DictMode); }
  191. BOOL _AllCmdsEnabled( );
  192. BOOL _AllCmdsDisabled( );
  193. void _RenewAllPropDataFromReg( );
  194. BOOL _IsModeKeysEnabled( ) { return (BOOL) _GetPropData(PropId_Mode_Button); }
  195. DWORD _GetDictationButton( ) { return _GetPropData(PropId_Dictation_Key); }
  196. DWORD _GetCommandButton( ) { return _GetPropData(PropId_Command_Key); }
  197. BOOL _IsPropItemChangedSinceLastRenew(PROP_ITEM_ID idPropItem) { return m_bChanged[(DWORD)idPropItem]; }
  198. private:
  199. BOOL m_bChanged[(DWORD)PropId_Max_Item_Id]; // indicates if the items have been changed since last
  200. // renew from Registry.
  201. };
  202. #endif // _PROPITEM_H