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.

278 lines
9.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: config.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _INC_CSCVIEW_CONFIG_H
  11. #define _INC_CSCVIEW_CONFIG_H
  12. #ifndef _INC_CSCVIEW_UTILS_H
  13. # include "util.h"
  14. #endif
  15. class CConfig
  16. {
  17. public:
  18. ~CConfig(void) { }
  19. enum SyncAction
  20. {
  21. eSyncNone = -1, // No sync.
  22. eSyncPartial, // Sync only transient files at logoff.
  23. eSyncFull, // Sync all files at logoff.
  24. eNumSyncActions
  25. };
  26. enum OfflineAction
  27. {
  28. //
  29. // These MUST match the order of the IDS_GOOFFLINE_ACTION_XXXXX
  30. // string resource IDs.
  31. //
  32. eGoOfflineSilent = 0, // Silently transition share to offline mode.
  33. eGoOfflineFail, // Fail the share (NT4 behavior).
  34. eNumOfflineActions
  35. };
  36. //
  37. // Represents one custom go-offline action.
  38. //
  39. struct OfflineActionInfo
  40. {
  41. TCHAR szServer[MAX_PATH]; // Name of the associated server.
  42. int iAction; // Action code. One of enum OfflineAction.
  43. };
  44. //
  45. // Represents one entry in the customized server list.
  46. // "GOA" is "GoOfflineAction".
  47. //
  48. class CustomGOA
  49. {
  50. public:
  51. CustomGOA(void)
  52. : m_action(eGoOfflineSilent),
  53. m_bSetByPolicy(false) { m_szServer[0] = TEXT('\0'); }
  54. CustomGOA(LPCTSTR pszServer, OfflineAction action, bool bSetByPolicy)
  55. : m_action(action),
  56. m_bSetByPolicy(bSetByPolicy) { StringCchCopy(m_szServer, ARRAYSIZE(m_szServer), pszServer); }
  57. bool operator == (const CustomGOA& rhs) const
  58. { return (m_action == rhs.m_action &&
  59. 0 == CompareByServer(rhs)); }
  60. bool operator != (const CustomGOA& rhs) const
  61. { return !(*this == rhs); }
  62. bool operator < (const CustomGOA& rhs) const;
  63. int CompareByServer(const CustomGOA& rhs) const;
  64. void SetServerName(LPCTSTR pszServer)
  65. { StringCchCopy(m_szServer, ARRAYSIZE(m_szServer), pszServer); }
  66. void SetAction(OfflineAction action)
  67. { m_action = action; }
  68. void GetServerName(LPTSTR pszServer, UINT cchServer) const
  69. { StringCchCopy(pszServer, cchServer, m_szServer); }
  70. const LPCTSTR GetServerName(void) const
  71. { return m_szServer; }
  72. OfflineAction GetAction(void) const
  73. { return m_action; }
  74. bool SetByPolicy(void) const
  75. { return m_bSetByPolicy; }
  76. private:
  77. TCHAR m_szServer[MAX_PATH]; // The name of the server.
  78. OfflineAction m_action; // The action code.
  79. bool m_bSetByPolicy; // Was action set by policy?
  80. };
  81. //
  82. // Iterator for enumerating custom go-offline actions.
  83. //
  84. class OfflineActionIter
  85. {
  86. public:
  87. OfflineActionIter(const CConfig *pConfig = NULL);
  88. ~OfflineActionIter(void);
  89. HRESULT Next(OfflineActionInfo *pInfo);
  90. void Reset(void)
  91. { m_iAction = 0; }
  92. private:
  93. CConfig *m_pConfig;
  94. HDPA m_hdpaGOA;
  95. int m_iAction;
  96. };
  97. static CConfig& GetSingleton(void);
  98. bool CscEnabled(bool *pbSetByPolicy = NULL) const
  99. { return boolify(GetValue(iVAL_CSCENABLED, pbSetByPolicy)); }
  100. DWORD DefaultCacheSize(bool *pbSetByPolicy = NULL) const
  101. { return GetValue(iVAL_DEFCACHESIZE, pbSetByPolicy); }
  102. int EventLoggingLevel(bool *pbSetByPolicy = NULL) const
  103. { return int(GetValue(iVAL_EVENTLOGGINGLEVEL, pbSetByPolicy)); }
  104. bool FirstPinWizardShown(void) const
  105. { return boolify(GetValue(iVAL_FIRSTPINWIZARDSHOWN)); }
  106. void GetCustomGoOfflineActions(HDPA hdpaGOA, bool *pbSetByPolicy = NULL);
  107. int GoOfflineAction(bool *pbSetByPolicy = NULL) const
  108. { return int(GetValue(iVAL_GOOFFLINEACTION, pbSetByPolicy)); }
  109. int GoOfflineAction(LPCTSTR pszServer) const;
  110. int InitialBalloonTimeoutSeconds(bool *pbSetByPolicy = NULL) const
  111. { return int(GetValue(iVAL_INITIALBALLOONTIMEOUTSECONDS, pbSetByPolicy)); }
  112. bool NoCacheViewer(bool *pbSetByPolicy = NULL) const
  113. { return boolify(GetValue(iVAL_NOCACHEVIEWER, pbSetByPolicy)); }
  114. bool NoConfigCache(bool *pbSetByPolicy = NULL) const
  115. { return boolify(GetValue(iVAL_NOCONFIGCACHE, pbSetByPolicy)); }
  116. bool NoMakeAvailableOffline(bool *pbSetByPolicy = NULL) const
  117. { return boolify(GetValue(iVAL_NOMAKEAVAILABLEOFFLINE, pbSetByPolicy)); }
  118. bool NoReminders(bool *pbSetByPolicy = NULL) const
  119. { return boolify(GetValue(iVAL_NOREMINDERS, pbSetByPolicy)); }
  120. bool PurgeAtLogoff(bool *pbSetByPolicy = NULL) const
  121. { return boolify(GetValue(iVAL_PURGEATLOGOFF, pbSetByPolicy)); }
  122. bool PurgeOnlyAutoCachedFilesAtLogoff(bool *pbSetByPolicy = NULL) const
  123. { return boolify(GetValue(iVAL_PURGEONLYAUTOCACHEATLOGOFF, pbSetByPolicy)); }
  124. bool AlwaysPinSubFolders(bool *pbSetByPolicy = NULL) const
  125. { return boolify(GetValue(iVAL_ALWAYSPINSUBFOLDERS, pbSetByPolicy)); }
  126. bool NoAdminPinSpecialFolders(bool *pbSetByPolicy = NULL) const
  127. { return boolify(GetValue(iVAL_NOFRADMINPIN, pbSetByPolicy)); }
  128. bool EncryptCache(bool *pbSetByPolicy = NULL) const
  129. { return boolify(GetValue(iVAL_ENCRYPTCACHE, pbSetByPolicy)); }
  130. int ReminderBalloonTimeoutSeconds(bool *pbSetByPolicy = NULL) const
  131. { return int(GetValue(iVAL_REMINDERBALLOONTIMEOUTSECONDS, pbSetByPolicy)); }
  132. int ReminderFreqMinutes(bool *pbSetByPolicy = NULL) const
  133. { return int(GetValue(iVAL_REMINDERFREQMINUTES, pbSetByPolicy)); }
  134. int SyncAtLogoff(bool *pbSetByPolicy = NULL) const
  135. { return int(GetValue(iVAL_SYNCATLOGOFF, pbSetByPolicy)); }
  136. int SyncAtLogon(bool *pbSetByPolicy = NULL) const
  137. { return int(GetValue(iVAL_SYNCATLOGON, pbSetByPolicy)); }
  138. int SyncAtSuspend(bool *pbSetByPolicy = NULL) const
  139. { return int(GetValue(iVAL_SYNCATSUSPEND, pbSetByPolicy)); }
  140. int SlowLinkSpeed(bool *pbSetByPolicy = NULL) const
  141. { return int(GetValue(iVAL_SLOWLINKSPEED, pbSetByPolicy)); }
  142. OfflineActionIter CreateOfflineActionIter(void) const
  143. { return OfflineActionIter(this); }
  144. static HRESULT SaveCustomGoOfflineActions(HKEY hkey, HDPA hdpaGOA);
  145. static void ClearCustomGoOfflineActions(HDPA hdpaGOA);
  146. private:
  147. //
  148. // Indexes into s_rgpszSubkeys[].
  149. //
  150. enum eSubkeys
  151. {
  152. iSUBKEY_PREF,
  153. iSUBKEY_POL,
  154. MAX_SUBKEYS
  155. };
  156. //
  157. // Indexes into s_rgpszValues[].
  158. //
  159. enum eValues
  160. {
  161. iVAL_DEFCACHESIZE,
  162. iVAL_CSCENABLED,
  163. iVAL_GOOFFLINEACTION,
  164. iVAL_NOCONFIGCACHE,
  165. iVAL_NOCACHEVIEWER,
  166. iVAL_NOMAKEAVAILABLEOFFLINE,
  167. iVAL_SYNCATLOGOFF,
  168. iVAL_SYNCATLOGON,
  169. iVAL_SYNCATSUSPEND,
  170. iVAL_NOREMINDERS,
  171. iVAL_REMINDERFREQMINUTES,
  172. iVAL_INITIALBALLOONTIMEOUTSECONDS,
  173. iVAL_REMINDERBALLOONTIMEOUTSECONDS,
  174. iVAL_EVENTLOGGINGLEVEL,
  175. iVAL_PURGEATLOGOFF,
  176. iVAL_PURGEONLYAUTOCACHEATLOGOFF,
  177. iVAL_FIRSTPINWIZARDSHOWN,
  178. iVAL_SLOWLINKSPEED,
  179. iVAL_ALWAYSPINSUBFOLDERS,
  180. iVAL_ENCRYPTCACHE,
  181. iVAL_NOFRADMINPIN,
  182. MAX_VALUES
  183. };
  184. //
  185. // Mask to specify source of a config value.
  186. //
  187. enum eSources
  188. {
  189. eSRC_PREF_CU = 0x00000001,
  190. eSRC_PREF_LM = 0x00000002,
  191. eSRC_POL_CU = 0x00000004,
  192. eSRC_POL_LM = 0x00000008,
  193. eSRC_POL = eSRC_POL_LM | eSRC_POL_CU,
  194. eSRC_PREF = eSRC_PREF_LM | eSRC_PREF_CU
  195. };
  196. static LPCTSTR s_rgpszSubkeys[MAX_SUBKEYS];
  197. static LPCTSTR s_rgpszValues[MAX_VALUES];
  198. DWORD GetValue(eValues iValue, bool *pbSetByPolicy = NULL) const;
  199. bool CustomGOAExists(HDPA hdpaGOA, const CustomGOA& goa);
  200. static bool IsValidGoOfflineAction(DWORD dwAction)
  201. { return ((OfflineAction)dwAction == eGoOfflineSilent ||
  202. (OfflineAction)dwAction == eGoOfflineFail); }
  203. static bool IsValidSyncAction(DWORD dwAction)
  204. { return ((SyncAction)dwAction == eSyncPartial ||
  205. (SyncAction)dwAction == eSyncFull); }
  206. //
  207. // Enforce use of GetSingleton() for instantiation.
  208. //
  209. CConfig(void) { }
  210. //
  211. // Prevent copy.
  212. //
  213. CConfig(const CConfig& rhs);
  214. CConfig& operator = (const CConfig& rhs);
  215. };
  216. #endif // _INC_CSCVIEW_CONFIG_H