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.

266 lines
9.7 KiB

  1. #pragma once
  2. // names of all known profile fields ....
  3. #define PROF_MEMBERNAME "SignInName"
  4. #define PROF_DOMAIN "Domain"
  5. #define PROF_EMAIL "Email"
  6. #define PROF_PASSWORD "Password"
  7. #define PROF_SECRETQ "SecretQuestion"
  8. #define PROF_SECRETA "SecretAnswer"
  9. #define PROF_BIRTHDATE "Birthdate"
  10. #define PROF_COUNTRY "Country"
  11. #define PROF_REGION "Region"
  12. #define PROF_POSTALCODE "PostalCode"
  13. #define PROF_SPACER "Spacer"
  14. #define PROF_GENDER "Gender"
  15. #define PROF_LANGUAGE "LanguagePreference"
  16. #define PROF_ACCESSIBILITY "Accessibility"
  17. #define PROF_EMAIL_SHARE "Email_1"
  18. #define PROF_NICKNAME "NickName"
  19. #define PROF_FIRSTNAME "FirstName"
  20. #define PROF_LASTNAME "LastName"
  21. #define PROF_TIMEZONE "TimeZone"
  22. #define PROF_OCCUPATION "Occupation"
  23. #define PROF_EMAIL_SPAM "NA_1"
  24. #define PROF_CONGRAT "NA_2"
  25. #define PROF_SVC "svc"
  26. #define PROF_SAVEPASSWORD "SavePassword"
  27. #define PROF_ALLOWEMAILINPROFILE "AllowEmailinProfile"
  28. #define PROF_ALLOWPASSPORTNETWORKEMAIL "AllowPassportNetworkEmail"
  29. #define PROF_WALLET "Wallet"
  30. #define PROF_DIRECTORY "Directory"
  31. #define PROF_GENERAL "General"
  32. // ALL available fields in bit mask
  33. #define PROFILE_BIT_BIRTHDATE 0x0000000000000001
  34. #define PROFILE_BIT_GENDER 0x0000000000000002
  35. #define PROFILE_BIT_LANGUAGE 0x0000000000000004
  36. #define PROFILE_BIT_ACCESSABILITY 0x0000000000000008
  37. #define PROFILE_BIT_EMAIL 0x0000000000000010
  38. #define PROFILE_BIT_CONGRAT 0x0000000000000020
  39. #define PROFILE_BIT_EMAIL_SHARE 0x0000000000000040
  40. #define PROFILE_BIT_EMAIL_SPAM 0x0000000000000080
  41. #define PROFILE_BIT_NICKNAME 0x0000000000000100
  42. #define PROFILE_BIT_MEMBERNAME 0x0000000000000200
  43. #define PROFILE_BIT_PASSWORD 0x0000000000000400
  44. #define PROFILE_BIT_SECRETQ 0x0000000000000800
  45. #define PROFILE_BIT_SECRETA 0x0000000000001000
  46. #define PROFILE_BIT_COUNTRY 0x0000000000002000
  47. #define PROFILE_BIT_REGION 0x0000000000004000
  48. #define PROFILE_BIT_POSTALCODE 0x0000000000008000
  49. #define PROFILE_BIT_FIRSTNAME 0x0000000000010000
  50. #define PROFILE_BIT_LASTNAME 0x0000000000020000
  51. #define PROFILE_BIT_TIMEZONE 0x0000000000040000
  52. #define PROFILE_BIT_OCCUPATION 0x0000000000080000
  53. #define PROFILE_BIT_SPACER 0x0000000000100000
  54. // TODO:
  55. // I am not sure of the bit masks (positions) of the following 4 fields.
  56. // Please modify them if necessary.
  57. #define PROFILE_BIT_SVC 0x0000000000200000
  58. #define PROFILE_BIT_SAVEPASSWORD 0x0000000000400000
  59. #define PROFILE_BIT_ALLOWEMAILINPROFILE 0x0000000000800000
  60. #define PROFILE_BIT_ALLOWPASSPORTNETWORKEMAIL 0x0000000001000000
  61. #define PROFILE_BIT_DOMAIN 0x0000000002000000
  62. //
  63. // customizaeble validation paramers
  64. //
  65. class CValidationParams
  66. {
  67. public:
  68. CValidationParams(LONG lMinPwd = 8,
  69. LONG lMaxPwd = 16,
  70. LONG lMinMemberName = 1,
  71. LONG lMaxMemberName = 64,
  72. LONG lEmailLeft = 32,
  73. LONG lEmailRight = 32,
  74. LONG lMaxNickname = 30) :
  75. // default values ....
  76. m_lMinPwd(lMinPwd), m_lMaxPwd(lMaxPwd),
  77. m_lMinMemberName(lMinMemberName), m_lMaxMemberName(lMaxMemberName),
  78. m_lEmailLeft(lEmailLeft), m_lEmailRight(lEmailRight),
  79. m_lMaxNickname(lMaxNickname)
  80. {
  81. }
  82. // this is how to change'em
  83. VOID SetNewValues(LONG lMinPwd = 8,
  84. LONG lMaxPwd = 16,
  85. LONG lMinMemberName = 1,
  86. LONG lMaxMemberName = 64,
  87. LONG lEmailLeft = 32,
  88. LONG lEmailRight = 32,
  89. LONG lMaxNickname = 30)
  90. {
  91. m_lMinPwd = lMinPwd, m_lMaxPwd=lMaxPwd,
  92. m_lMinMemberName = lMinMemberName, m_lMaxMemberName = lMaxMemberName,
  93. m_lEmailLeft = lEmailLeft, m_lEmailRight = lEmailRight;
  94. m_lMaxNickname = lMaxNickname;
  95. }
  96. void GetPwdParams(LONG& lmin, LONG& lmax) {
  97. lmin = m_lMinPwd, lmax = m_lMaxPwd;
  98. }
  99. void GetMemberNameParams(LONG& lmin, LONG& lmax){
  100. lmin = m_lMinMemberName, lmax = m_lMaxMemberName;
  101. }
  102. void GetEmailParams(LONG& lmailL, LONG& lmailR ){
  103. lmailL = m_lEmailLeft, lmailR = m_lEmailRight;
  104. }
  105. void GetNicknameParams(LONG& lmax){
  106. lmax = m_lMaxNickname;
  107. }
  108. private:
  109. LONG m_lMinPwd;
  110. LONG m_lMaxPwd;
  111. LONG m_lMinMemberName;
  112. LONG m_lMaxMemberName;
  113. LONG m_lEmailLeft;
  114. LONG m_lEmailRight;
  115. LONG m_lMaxNickname;
  116. };
  117. //
  118. // field description ...
  119. //
  120. typedef struct
  121. {
  122. LPCSTR pcszFieldName;
  123. BOOL fIsRequired;
  124. BOOL bInvalid;
  125. } FIELD_STATE, *PFIELD_STATE;
  126. typedef CAtlArray<PFIELD_STATE> FIELD_ARRAY;
  127. typedef struct
  128. {
  129. LPCSTR pcszUIFIELDID;
  130. BOOL bState;
  131. LPCSTR pcszUIDepends;
  132. } UIFIELD_STATE, *PUIFIELD_STATE;
  133. typedef CAtlArray<PUIFIELD_STATE> UIFIELD_ARRAY;
  134. //
  135. // user profile interface. An abstract class ...
  136. //
  137. class CUserProfile
  138. {
  139. public:
  140. // this need to be defined for the autoptr ....
  141. // all other functions are pure virtual
  142. virtual ~CUserProfile(){};
  143. // get field by index ....
  144. // index corresponds to the bit position in the bit mask ....
  145. virtual PCSTR GetFieldNameByIndex(ULONG ind) = 0;
  146. // validate profile
  147. virtual BOOL Validate() = 0;
  148. // regProfile <-> database
  149. virtual HRESULT InitFromDB( CStringW wszMemberName,
  150. FIELD_ARRAY& fields) = 0;
  151. virtual HRESULT Persist(CStringW *wszMemberName = NULL) = 0;
  152. virtual HRESULT DeleteMember(CStringW &wszMemberName) = 0;
  153. //
  154. // field initialization options
  155. //
  156. virtual HRESULT AddField(LPCSTR name, PCWSTR value) = 0;
  157. virtual HRESULT AddField(ULONG findex, PCWSTR value) = 0;
  158. virtual HRESULT UpdateField(LPCSTR name, PCWSTR value) = 0;
  159. virtual HRESULT UpdateField(ULONG findex, PCWSTR value) = 0;
  160. // regProfile <-> XML format
  161. virtual HRESULT InitFromXML(IXMLDOMDocument *pXMLDoc,
  162. FIELD_ARRAY &Fields) = 0;
  163. virtual HRESULT SaveToXML(CStringA &szProfileXML) = 0;
  164. //
  165. // html form init
  166. // process the fields in the Fields array
  167. //
  168. virtual HRESULT InitFromHTMLForm(CHttpRequest& request,
  169. FIELD_ARRAY& Fields) = 0;
  170. // html query string init
  171. virtual HRESULT InitFromQueryString(CHttpRequest& request,
  172. FIELD_ARRAY& Fields) = 0;
  173. //
  174. // get value, errcode or help text for field name ....
  175. //
  176. virtual HRESULT GetFieldValue(LPCSTR fname, CStringW& strVal) = 0;
  177. virtual HRESULT GetFieldValue(ULONG findex, CStringW& strVal) = 0;
  178. virtual HRESULT GetFieldError(LPCSTR fname) = 0;
  179. virtual HRESULT GetFieldError(ULONG fIndex) = 0;
  180. virtual HRESULT FieldHasError(LPCSTR fname) = 0;
  181. virtual HRESULT FieldHasError(ULONG fIndex) = 0;
  182. virtual void SetFieldError(LPCSTR fname) = 0;
  183. virtual void RemoveProfileKey(LPCSTR fname) = 0;
  184. virtual void GetFieldHelpText(LPCSTR fname, CStringW& strHelp) = 0;
  185. virtual BOOL IsField(LPCSTR fname) = 0;
  186. //
  187. // enum methods
  188. //
  189. virtual HRESULT StartEnumFields(POSITION& pos) = 0;
  190. virtual HRESULT GetNextField(POSITION& p, CStringW& fn, CStringW& fv) = 0;
  191. virtual HRESULT StartEnumErrors(POSITION& pos) = 0;
  192. virtual HRESULT GetNextError(POSITION& p, CStringW& fn, HRESULT& fhr) = 0;
  193. //
  194. // validation functions
  195. //
  196. virtual HRESULT ValidateMember(CStringW &value) = 0;
  197. virtual HRESULT ValidateEmail(CStringW &value) = 0;
  198. virtual HRESULT ValidateLocation(CStringW &country,
  199. CStringW &region,
  200. CStringW &pcode) = 0;
  201. virtual HRESULT ValidatePassword(CStringW &pwd, CStringW &mbrname) = 0;
  202. virtual HRESULT ValidateNickname(CStringW &value) = 0;
  203. // regional info for validation
  204. virtual void SetProfileRegionalInfo(
  205. LCID lc, IDictionaryEx *piDict = NULL) = 0;
  206. // set namespace
  207. virtual void SetProfileNamespace(PCWSTR cszNameSpace) = 0;
  208. // get namespace
  209. virtual HRESULT GetProfileNamespace(CStringW& strNameSpace) = 0;
  210. // flags to be determined ...
  211. virtual void SetProfileFlags(ULONG fFlags) = 0;
  212. virtual ULONG GetProfileFlags() = 0;
  213. virtual ULONG GetProfileMiscFlags() = 0;
  214. virtual ULONG GetProfileVersion() = 0;
  215. virtual void SetInsertFlags(ULONG fFlags) = 0;
  216. // passport cookies for login and member services ....
  217. // t&p stuff ....
  218. virtual HRESULT GenSecureTicket(CStringA* pSec) = 0;
  219. virtual HRESULT GenAuthTicket(CStringA* pAuth) = 0;
  220. virtual HRESULT GenProfileCookie(CStringA* pProf) = 0;
  221. // customizable validation
  222. virtual VOID SetValidationParams(CValidationParams&) = 0;
  223. // debug method
  224. virtual void Dump(CStringA& dump) = 0;
  225. virtual CPPCoreProfileStorage& GetRow() = 0;
  226. virtual HRESULT SetDictionaryObject(IDictionaryEx *ppiDict)=0;
  227. };
  228. //
  229. // wrapper for the abstract class. Use it to get
  230. // CUserProfile* interface
  231. //
  232. class CUserProfileWrapper : public CAutoPtr<CUserProfile>
  233. {
  234. public:
  235. CUserProfileWrapper();
  236. };