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.

374 lines
13 KiB

  1. // ===============================================================================
  2. // I P A B . H
  3. // ===============================================================================
  4. #ifndef __IPAB_H
  5. #define __IPAB_H
  6. // ===============================================================================
  7. // Dependencies
  8. // ===============================================================================
  9. #include <wabp.h>
  10. typedef BLOB THUMBBLOB;
  11. // ===============================================================================
  12. // D E F I N E S
  13. // ===============================================================================
  14. #define GROW_SIZE 5
  15. // ===============================================================================
  16. // W A B Property structs
  17. // ===============================================================================
  18. enum
  19. {
  20. AE_colEMailAddress = 0,
  21. AE_colAddrType,
  22. AE_colRecipType,
  23. AE_colDisplayName,
  24. AE_colSurName,
  25. AE_colGivenName,
  26. AE_colEntryID,
  27. AE_colObjectType,
  28. AE_colInternetEncoding,
  29. AE_colLast
  30. };
  31. static const SizedSPropTagArray(AE_colLast, AE_props)=
  32. {
  33. AE_colLast,
  34. {
  35. PR_EMAIL_ADDRESS_W,
  36. PR_ADDRTYPE_W,
  37. PR_RECIPIENT_TYPE,
  38. PR_DISPLAY_NAME_W,
  39. PR_SURNAME_W,
  40. PR_GIVEN_NAME_W,
  41. PR_ENTRYID,
  42. PR_OBJECT_TYPE,
  43. PR_SEND_INTERNET_ENCODING
  44. }
  45. };
  46. /**** Dont mess with the order of these arrays (especially the address components street,city,zip etc ****/
  47. // The code that uses this structure is commented out. If and when that is used again, we will uncomment
  48. // this again. Also, might need to convert the PR_DISPLAY_NAME to PR_DISPLAY_NAME_W along with a few others.
  49. /*static const SizedSPropTagArray(24, ToolTipProps)=
  50. {
  51. 24,
  52. {
  53. PR_DISPLAY_NAME,
  54. PR_EMAIL_ADDRESS,
  55. PR_HOME_ADDRESS_STREET,
  56. PR_HOME_ADDRESS_CITY,
  57. PR_HOME_ADDRESS_STATE_OR_PROVINCE,
  58. PR_HOME_ADDRESS_POSTAL_CODE,
  59. PR_HOME_ADDRESS_COUNTRY,
  60. PR_HOME_TELEPHONE_NUMBER,
  61. PR_HOME_FAX_NUMBER,
  62. PR_CELLULAR_TELEPHONE_NUMBER,
  63. PR_PERSONAL_HOME_PAGE,
  64. PR_TITLE,
  65. PR_DEPARTMENT_NAME,
  66. PR_OFFICE_LOCATION,
  67. PR_COMPANY_NAME,
  68. PR_BUSINESS_ADDRESS_STREET,
  69. PR_BUSINESS_ADDRESS_CITY,
  70. PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE,
  71. PR_BUSINESS_ADDRESS_POSTAL_CODE,
  72. PR_BUSINESS_ADDRESS_COUNTRY,
  73. PR_BUSINESS_TELEPHONE_NUMBER,
  74. PR_BUSINESS_FAX_NUMBER,
  75. PR_PAGER_TELEPHONE_NUMBER,
  76. PR_BUSINESS_HOME_PAGE
  77. }
  78. };*/
  79. // ToolTipProps mask
  80. #define SET_PERINFO 0x0001
  81. #define SET_PERADDRESS 0x0002
  82. #define SET_BUSINFO 0x0004
  83. #define SET_BUSTITLE 0x0008
  84. #define SET_BUSDEPT 0x0016
  85. #define SET_BUSOFF 0x0032
  86. #define SET_BUSCOMP 0x0064
  87. #define SET_BUSADDRESS 0x0128
  88. #define SET_NOTES 0x0256
  89. // ADRINFO mask
  90. #define AIM_ADDRESS 0x0001
  91. #define AIM_DISPLAY 0x0002
  92. #define AIM_ADDRTYPE 0x0004
  93. #define AIM_SURNAME 0x0008
  94. #define AIM_GIVENNAME 0x0010
  95. #define AIM_RECIPTYPE 0x0020
  96. #define AIM_CERTIFICATE 0x0040
  97. #define AIM_OBJECTTYPE 0x0080 // fDistList
  98. #define AIM_EID 0x0100
  99. #define AIM_INTERNETENCODING 0x0200
  100. typedef struct tagADRINFO // WARNING: if you change this
  101. { // be sure to change DupeAdrInfo!
  102. DWORD dwReserved;
  103. LPWSTR lpwszAddress; // Addresses must be in US printable ascii.
  104. LPWSTR lpwszDisplay;
  105. LPWSTR lpwszAddrType;
  106. LPWSTR lpwszSurName;
  107. LPWSTR lpwszGivenName;
  108. LONG lRecipType;
  109. THUMBBLOB tbCertificate;
  110. BLOB blSymCaps;
  111. FILETIME ftSigningTime;
  112. LPMIMEMESSAGE pMsg; // used for cert store, signing cert, etc.
  113. BOOL fResolved :1,
  114. fDistList :1,
  115. fDefCertificate :1,
  116. fPlainText :1;
  117. // unique ID, if there is one
  118. BYTE *lpbEID;
  119. ULONG cbEID;
  120. } ADRINFO, *LPADRINFO;
  121. // AddrInfo list used for drag-drop of multiple AddrInfo's
  122. typedef struct ADRINFOLIST_tag
  123. {
  124. ULONG cValues;
  125. LPADRINFO rgAdrInfo;
  126. } ADRINFOLIST,
  127. FAR *LPADRINFOLIST;
  128. typedef struct tagDLSEARCHINFO
  129. {
  130. ULONG cValues, // count and list of distribution lists
  131. cAlloc;
  132. LPSBinary rgEid; // involved in this search...
  133. } DLSEARCHINFO,
  134. *PDLSEARCHINFO;
  135. // ===============================================================================
  136. // CWabal - WAB Address List class
  137. // ===============================================================================
  138. class CWabal;
  139. typedef CWabal *LPWABAL;
  140. class CWabal
  141. {
  142. private:
  143. ULONG m_cRef;
  144. ULONG m_cActualEntries;
  145. LPWABOBJECT m_lpWabObject;
  146. LPADRBOOK m_lpAdrBook;
  147. LPADRLIST m_lpAdrList;
  148. ULONG m_cMemberEnum,
  149. m_cMembers;
  150. LPSRowSet m_lprwsMembers;
  151. LPMIMEMESSAGE m_pMsg;
  152. private:
  153. BOOL FVerifyState (VOID);
  154. HRESULT HrGrowAdrlist (LPADRLIST *lppalCurr, ULONG caeToAdd);
  155. void AdrEntryToAdrInfo(LPADRENTRY lpAdrEntry, LPADRINFO lpAdrInfo);
  156. HRESULT HrAdrInfoFromRow(LPSRow lpsrw, LPADRINFO lpAdrInfo, LONG lRecipType);
  157. void PropValToAdrInfo(LPSPropValue ppv, LPADRINFO lpAdrInfo);
  158. HRESULT HrAddDistributionList(LPWABAL lpWabal, LPSRowSet lprws, LONG lRecipType, PDLSEARCHINFO pDLSearch);
  159. BOOL FDLVisted(SBinary eidDL, PDLSEARCHINFO pDLSearch);
  160. HRESULT HrAddToSearchList(SBinary eidDL, PDLSEARCHINFO pDLSearch);
  161. HRESULT FreeSearchList(PDLSEARCHINFO pDLSearch);
  162. HRESULT HrGetDistListRows(SBinary eidDL, LPSRowSet *psrws);
  163. public:
  164. // Construct and Destruct
  165. CWabal ();
  166. ~CWabal ();
  167. // Ref counting
  168. ULONG AddRef (VOID);
  169. ULONG Release (VOID);
  170. // Adding an address
  171. HRESULT HrAddEntry (LPWSTR lpszDisplay, LPWSTR lpszAddress, LONG lRecipType);
  172. HRESULT HrAddEntryA(LPTSTR lpszDisplay, LPTSTR lpszAddress, LONG lRecipType);
  173. HRESULT HrAddEntry (LPADRINFO lpAdrInfo, BOOL fCheckDupes=FALSE);
  174. HRESULT HrAddUnresolved(LPWSTR lpszDisplayName, LONG lRecipType);
  175. ULONG DeleteRecipType(LONG lRecipType);
  176. // Copy to a new wabal
  177. HRESULT HrCopyTo (LPWABAL lpWabal);
  178. HRESULT HrExpandTo(LPWABAL lpWabal);
  179. // Getting the lpadrlist
  180. LPADRLIST LpGetList (VOID);
  181. // Wab Object Accessors
  182. SCODE FreeBuffer(void *pv) { return m_lpWabObject->FreeBuffer(pv); }
  183. SCODE AllocateBuffer(ULONG ulSize, LPVOID FAR * lppv)
  184. { return m_lpWabObject->AllocateBuffer(ulSize, lppv); }
  185. SCODE AllocateMore(ULONG ulSize, LPVOID lpv, LPVOID FAR * lppv)
  186. { return m_lpWabObject->AllocateMore(ulSize, lpv, lppv); }
  187. // Give access to the IAdrBook object
  188. LPADRBOOK GetAdrBook(void) { return(m_lpAdrBook); }
  189. LPWABOBJECT GetWABObject(void) { return(m_lpWabObject); }
  190. // Set and Get the message object associated with this Wabal
  191. VOID SetAssociatedMessage(LPMIMEMESSAGE pMsg)
  192. { m_pMsg = pMsg; }
  193. LPMIMEMESSAGE GetAssociatedMessage(void)
  194. { return (m_pMsg); }
  195. HRESULT IsValidForSending();
  196. __inline ULONG CEntries (VOID) { return m_cActualEntries; }
  197. // Reset address list
  198. VOID Reset (VOID);
  199. // Iterating through the list - LPADRINFO == NULL WHEN NO MORE
  200. // using dDupe, a new copy is returned, the caller must free this
  201. // using MemFree.
  202. BOOL FGetFirst (LPADRINFO lpAdrInfo);
  203. BOOL FGetNext (LPADRINFO lpAdrInfo);
  204. BOOL FFindFirst(LPADRINFO lpAdrInfo, LONG lRecipType);
  205. // Resolve Names
  206. HRESULT HrResolveNames (HWND hwndParent, BOOL fShowDialog);
  207. // builds a drag drop serialised HGLOBAL for a Wabal
  208. HRESULT HrBuildHGlobal(HGLOBAL *phGlobal);
  209. HRESULT HrPickNames (HWND hwndParent, ULONG *rgulTypes, int cWells, int iFocus, BOOL fNews);
  210. HRESULT HrRulePickNames(HWND hwndParent, LONG lRecipType, UINT uidsTitle, UINT uidsWell, UINT uidsWellButton);
  211. HRESULT HrGetPMP(ULONG cbEntryID, LPENTRYID lpEntryID, ULONG *lpul, LPMAPIPROP *lppmp);
  212. HRESULT HrSmartFind(HWND hwnd, LPSPropValue lpProps, ULONG cProps, LPENTRYID * lppEIDWAB,
  213. LPULONG lpcbEIDWAB);
  214. void UnresolveOneOffs();
  215. };
  216. // ===============================================================================
  217. // CWab - Internet Personal Address Book
  218. // ===============================================================================
  219. class CWab
  220. {
  221. private:
  222. ULONG m_cRef;
  223. LPWABOBJECT m_lpWabObject;
  224. LPADRBOOK m_lpAdrBook;
  225. ADRPARM m_adrParm;
  226. HWND m_hwnd;
  227. WNDPROC m_pfnWabWndProc;
  228. BOOL m_fInternal;
  229. HWNDLIST m_hlDisabled;
  230. private:
  231. BOOL FVerifyState (VOID);
  232. public:
  233. // Construct and Destruct
  234. CWab ();
  235. ~CWab ();
  236. // Ref counting
  237. ULONG AddRef(VOID);
  238. ULONG Release(VOID);
  239. // Init the pab
  240. HRESULT HrInit(VOID);
  241. // Browse the address book
  242. HRESULT HrBrowse(HWND hwndParent, BOOL fModal=FALSE);
  243. HRESULT OnClose();
  244. // Pick names from the address book
  245. HRESULT HrPickNames (HWND hwndParent, ULONG *rgulTypes, int cWells, int iFocus, BOOL fNews, LPADRLIST *lppal);
  246. HRESULT HrGeneralPickNames(HWND hwndParent, ADRPARM *pAdrParms, LPADRLIST *lppal);
  247. // Add Entry
  248. HRESULT HrAddNewEntry(LPWSTR lpszDisplay, LPWSTR lpszAddress);
  249. HRESULT HrAddNewEntryA(LPTSTR lpszDisplay, LPTSTR lpszAddress);
  250. // Show details on a recipient
  251. HRESULT HrDetails(HWND hwndOwner, LPADRINFO *lplpAdrInfo);
  252. // add entry to the wab
  253. HRESULT HrAddToWAB(HWND hwndOwner, LPADRINFO lpAdrInfo, LPMAPIPROP * lppMailUser);
  254. HRESULT HrAddToWAB(HWND hwndOwner, LPADRINFO lpAdrInfo) {
  255. return HrAddToWAB(hwndOwner, lpAdrInfo, NULL);
  256. }
  257. // update a set of fields on an entry
  258. HRESULT HrUpdateWABEntryNoEID(HWND hwndParent, LPADRINFO lpAdrInfo, DWORD mask);
  259. // EID must be valid for this one
  260. HRESULT HrUpdateWABEntry(LPADRINFO lpAdrInfo, DWORD mask);
  261. HRESULT HrFind(HWND hwnd, LPWSTR lpwszAddress);
  262. HRESULT HrFillComboWithPABNames(HWND hwnd, int* pcRows);
  263. HRESULT HrCreateVCardFile(LPCTSTR szVCardName, LPCTSTR szFileName);
  264. HRESULT HrFromNameToIDs(LPCTSTR lpszVCardName, ULONG* pcbEID, LPENTRYID* lppEID);
  265. HRESULT HrFromIDToName(LPTSTR pszName, DWORD cchSize, ULONG cbEID, LPENTRYID lpEID);
  266. HRESULT HrNewEntry(HWND hwnd, LPTSTR pszName, DWORD cchSize);
  267. HRESULT HrEditEntry(HWND hwnd, LPTSTR pszName, DWORD cchSize);
  268. HRESULT HrGetAdrBook(LPADRBOOK* lppAdrBook);
  269. HRESULT HrGetWabObject(LPWABOBJECT* lppWabObject);
  270. BOOL FTranslateAccelerator(LPMSG lpmsg);
  271. VOID FreeLPSRowSet(LPSRowSet lpsrs);
  272. VOID FreePadrlist(LPADRLIST lpAdrList);
  273. VOID BrowseWindowClosed() {m_hwnd = NULL;}
  274. HRESULT HrGetPABTable(LPMAPITABLE* ppTable);
  275. HRESULT SearchPABTable(LPMAPITABLE lpTable, LPWSTR pszValue, LPWSTR pszFound, INT cch);
  276. static LRESULT WabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  277. // Added for ToolTip in the Preview Header pane
  278. HRESULT ResolveName(LPWSTR lpszName, LPWSTR *lppszResolvedText);
  279. };
  280. typedef CWab * LPWAB;
  281. // ===============================================================================
  282. // P R O T O T Y P E S
  283. // ===============================================================================
  284. HRESULT HrInitWab (BOOL fInit);
  285. HRESULT HrCreateWabObject (LPWAB *lppWab);
  286. HRESULT HrCreateWabalObject (LPWABAL *lppWabal);
  287. HRESULT HrCreateWabalObjectFromHGlobal(HGLOBAL hGlobal, LPWABAL *lppWabal);
  288. HRESULT HrCloseWabWindow();
  289. HRESULT HrLoadPathWABEXE(LPTSTR szPath, ULONG cbPath);
  290. BOOL FWABTranslateAccelerator(LPMSG lpmsg);
  291. // utility functions
  292. HRESULT HrDupeAddrInfo(LPADRINFO lpAdrInfo, LPADRINFO *lplpAdrInfo);
  293. HRESULT HrInitWab (BOOL fInit);
  294. HRESULT HrBuildCertSBinaryData(
  295. BOOL bIsDefault,
  296. THUMBBLOB* pPrint,
  297. BLOB * pSymCaps,
  298. FILETIME ftSigningTime,
  299. LPBYTE UNALIGNED FAR* lplpbData,
  300. ULONG UNALIGNED FAR* lpcbData);
  301. LPBYTE FindX509CertTag(LPSBinary lpsb, ULONG ulTag, ULONG * pcbReturn);
  302. HRESULT GetX509CertTags(LPSBinary lpsb, THUMBBLOB * ptbCertificate, BLOB * pblSymCaps, LPFILETIME pftSigningTime, BOOL * pfDefault);
  303. HRESULT HrWABCreateEntry(LPADRBOOK lpAdrBook, LPWABOBJECT lpWabObject,
  304. LPWSTR lpwszDisplay, LPWSTR lpszAddress, ULONG ulFlags, LPMAILUSER * lppMailUser, ULONG ulSaveFlags=KEEP_OPEN_READONLY);
  305. HRESULT ThumbprintToPropValue(LPSPropValue ppv, THUMBBLOB *pPrint, BLOB *pSymCaps, FILETIME ftSigningTime, BOOL fDefPrint);
  306. void ImportWAB(HWND hwnd);
  307. void Wab_CoDecrement();
  308. #endif // __IPAB_H