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.

313 lines
7.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxxp.h
  5. Abstract:
  6. Fax transport provider header file.
  7. Author:
  8. Wesley Witt (wesw) 13-Aug-1996
  9. --*/
  10. #include <windows.h>
  11. #include <winspool.h>
  12. #include <mapiwin.h>
  13. #include <mapispi.h>
  14. #include <mapiutil.h>
  15. #include <mapicode.h>
  16. #include <mapival.h>
  17. #include <mapiwz.h>
  18. #include <richedit.h>
  19. #include <shlobj.h>
  20. #include <shellapi.h>
  21. #include <commdlg.h>
  22. #include <tchar.h>
  23. #include <stdio.h>
  24. #ifndef WIN95
  25. #include "winfax.h"
  26. #endif
  27. #include "resource.h"
  28. #include "faxreg.h"
  29. #include "faxmapip.h"
  30. #include "faxutil.h"
  31. #include "devmode.h"
  32. #ifdef WIN95
  33. #define FAX_DRIVER_NAME "Microsoft Fax Client"
  34. #else
  35. #define FAX_DRIVER_NAME "Windows NT Fax Driver"
  36. #endif
  37. #define FAX_TRANSPORT_NAME "Microsoft Fax Transport Service"
  38. #define FAX_ADDRESS_TYPE "FAX"
  39. #define LNK_FILENAME_EXT ".lnk"
  40. #define CP_FILENAME_EXT ".cov"
  41. #define MAX_FILENAME_EXT 4
  42. #define CPFLAG_LINK 0x0100
  43. #define TRANSPORT_DISPLAY_NAME_STRING "Fax Mail Transport"
  44. #define TRANSPORT_DLL_NAME_STRING "FAXXP32.DLL"
  45. #define LEFT_MARGIN 1 // ---|
  46. #define RIGHT_MARGIN 1 // |
  47. #define TOP_MARGIN 1 // |---> in inches
  48. #define BOTTOM_MARGIN 1 // ---|
  49. #define InchesToCM(_x) (((_x) * 254L + 50) / 100)
  50. #define CMToInches(_x) (((_x) * 100L + 127) / 254)
  51. #define XPID_NAME 0
  52. #define XPID_EID 1
  53. #define XPID_SEARCH_KEY 2
  54. #define NUM_IDENTITY_PROPS 3
  55. #define RECIP_ROWID 0
  56. #define RECIP_NAME 1
  57. #define RECIP_EMAIL_ADR 2
  58. #define RECIP_TYPE 3
  59. #define RECIP_RESPONSIBILITY 4
  60. #define RECIP_DELIVER_TIME 5
  61. #define RECIP_REPORT_TIME 6
  62. #define RECIP_REPORT_TEXT 7
  63. #define RECIP_ADDR_TYPE 8
  64. #define TABLE_RECIP_PROPS 9
  65. #define MSG_DISP_TO 0
  66. #define MSG_SUBJECT 1
  67. #define MSG_CLASS 2
  68. #define MSG_BODY 3
  69. #define MSG_FLAGS 4
  70. #define MSG_SIZE 5
  71. #define MSG_PRIORITY 6
  72. #define MSG_IMPORTANCE 7
  73. #define MSG_SENSITIVITY 8
  74. #define MSG_DR_REPORT 9
  75. #define NUM_MSG_PROPS 10
  76. #define MSG_ATTACH_METHOD 0
  77. #define MSG_ATTACH_NUM 1
  78. #define MSG_ATTACH_EXTENSION 2
  79. #define MSG_ATTACH_FILENAME 3
  80. #define MSG_ATTACH_PATHNAME 4
  81. #define MSG_ATTACH_LFILENAME 5
  82. #define MSG_ATTACH_TAG 6
  83. #define NUM_ATTACH_PROPS 7
  84. #define NUM_ATTACH_TABLE_PROPS 2
  85. typedef struct _USER_INFO {
  86. TCHAR BillingCode[64];
  87. TCHAR Company[128];
  88. TCHAR Dept[128];
  89. } USER_INFO, *PUSER_INFO;
  90. const static SizedSPropTagArray ( NUM_ATTACH_TABLE_PROPS, sptAttachTableProps) =
  91. {
  92. NUM_ATTACH_TABLE_PROPS,
  93. {
  94. PR_ATTACH_METHOD,
  95. PR_ATTACH_NUM
  96. }
  97. };
  98. const static SizedSPropTagArray ( NUM_ATTACH_PROPS, sptAttachProps) =
  99. {
  100. NUM_ATTACH_PROPS,
  101. {
  102. PR_ATTACH_METHOD,
  103. PR_ATTACH_NUM,
  104. PR_ATTACH_EXTENSION,
  105. PR_ATTACH_FILENAME,
  106. PR_ATTACH_PATHNAME,
  107. PR_ATTACH_LONG_FILENAME,
  108. PR_ATTACH_TAG
  109. }
  110. };
  111. const static SizedSPropTagArray (TABLE_RECIP_PROPS, sptRecipTable) =
  112. {
  113. TABLE_RECIP_PROPS,
  114. {
  115. PR_ROWID,
  116. PR_DISPLAY_NAME,
  117. PR_EMAIL_ADDRESS,
  118. PR_RECIPIENT_TYPE,
  119. PR_RESPONSIBILITY,
  120. PR_DELIVER_TIME,
  121. PR_REPORT_TIME,
  122. PR_REPORT_TEXT,
  123. PR_ADDRTYPE
  124. }
  125. };
  126. static const SizedSPropTagArray(NUM_MSG_PROPS, sptPropsForHeader) =
  127. {
  128. NUM_MSG_PROPS,
  129. {
  130. PR_DISPLAY_TO,
  131. PR_SUBJECT,
  132. PR_BODY,
  133. PR_MESSAGE_CLASS,
  134. PR_MESSAGE_FLAGS,
  135. PR_MESSAGE_SIZE,
  136. PR_PRIORITY,
  137. PR_IMPORTANCE,
  138. PR_SENSITIVITY,
  139. PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED
  140. }
  141. };
  142. extern LPALLOCATEBUFFER gpfnAllocateBuffer; // MAPIAllocateBuffer function
  143. extern LPALLOCATEMORE gpfnAllocateMore; // MAPIAllocateMore function
  144. extern LPFREEBUFFER gpfnFreeBuffer; // MAPIFreeBuffer function
  145. extern HINSTANCE FaxXphInstance;
  146. extern MAPIUID FaxGuid;
  147. LPVOID
  148. MapiMemAlloc(
  149. DWORD Size
  150. );
  151. VOID
  152. MapiMemFree(
  153. LPVOID ptr
  154. );
  155. PVOID
  156. MyGetPrinter(
  157. LPSTR PrinterName,
  158. DWORD level
  159. );
  160. LPSTR
  161. GetServerName(
  162. LPSTR PrinterName
  163. );
  164. LPWSTR
  165. AnsiStringToUnicodeString(
  166. LPCSTR AnsiString
  167. );
  168. LPSTR
  169. UnicodeStringToAnsiString(
  170. LPCWSTR UnicodeString
  171. );
  172. HRESULT WINAPI
  173. OpenServiceProfileSection(
  174. LPMAPISUP pSupObj,
  175. LPPROFSECT * ppProfSectObj
  176. );
  177. INT_PTR CALLBACK
  178. ConfigDlgProc(
  179. HWND hDlg,
  180. UINT message,
  181. WPARAM wParam,
  182. LPARAM lParam
  183. );
  184. BOOL
  185. GetUserInfo(
  186. LPTSTR PrinterName,
  187. PUSER_INFO UserInfo
  188. );
  189. DWORD
  190. GetDwordProperty(
  191. LPSPropValue pProps,
  192. DWORD PropId
  193. );
  194. LPSTR
  195. GetStringProperty(
  196. LPSPropValue pProps,
  197. DWORD PropId
  198. );
  199. DWORD
  200. GetBinaryProperty(
  201. LPSPropValue pProps,
  202. DWORD PropId,
  203. LPVOID Buffer,
  204. DWORD SizeOfBuffer
  205. );
  206. class CXPProvider : public IXPProvider
  207. {
  208. public:
  209. STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppvObj );
  210. STDMETHODIMP_(ULONG) AddRef();
  211. STDMETHODIMP_(ULONG) Release();
  212. MAPI_IXPPROVIDER_METHODS(IMPL);
  213. public :
  214. CXPProvider( HINSTANCE hInst );
  215. ~CXPProvider();
  216. private :
  217. ULONG m_cRef;
  218. CRITICAL_SECTION m_csTransport;
  219. HINSTANCE m_hInstance;
  220. CHAR m_ProfileName[64];
  221. };
  222. class CXPLogon : public IXPLogon
  223. {
  224. public:
  225. STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppvObj );
  226. STDMETHODIMP_(ULONG) AddRef();
  227. STDMETHODIMP_(ULONG) Release();
  228. STDMETHODIMP InitializeStatusRow(ULONG ulFlags);
  229. STDMETHODIMP GrowAddressList(LPADRLIST *ppAdrList, ULONG ulResizeBy, ULONG *pulOldAndNewCount);
  230. MAPI_IXPLOGON_METHODS(IMPL);
  231. private:
  232. void WINAPI CheckSpoolerYield( BOOL fReset = FALSE );
  233. void WINAPI UpdateStatus( BOOL fAddValidate=FALSE, BOOL fValidateOkState=FALSE );
  234. BOOL WINAPI LoadStatusString( LPTSTR pString, UINT uStringSize );
  235. DWORD SendFaxDocument(LPMESSAGE pMsgObj,LPSTREAM lpstmT,BOOL UseRichText,LPSPropValue pMsgProps,LPSPropValue pRecipProps);
  236. PVOID MyGetPrinter(LPSTR PrinterName,DWORD Level);
  237. VOID PrintRichText(HWND hWndRichEdit,HDC hDC,PFAXXP_CONFIG FaxConfig);
  238. BOOL PrintText(HDC hDC,LPSTREAM lpstmT,PFAXXP_CONFIG FaxConfig);
  239. DWORD PrintAttachment(LPSTR FaxPrinterName,LPSTR DocName);
  240. public :
  241. CXPLogon( HINSTANCE hInstance, LPMAPISUP pSupObj, LPSTR ProfileName );
  242. ~CXPLogon();
  243. inline void WINAPI AddStatusBits
  244. (DWORD dwNewBits) { m_ulTransportStatus |= dwNewBits; }
  245. inline void WINAPI RemoveStatusBits
  246. (DWORD dwOldBits) { m_ulTransportStatus &= ~dwOldBits; }
  247. inline DWORD WINAPI GetTransportStatusCode
  248. () { return m_ulTransportStatus; }
  249. private :
  250. ULONG m_cRef;
  251. HINSTANCE m_hInstance;
  252. BOOL m_fABWDSInstalled;
  253. ULONG m_ulTransportStatus;
  254. LPWSTR m_CpBuffer;
  255. DWORD m_CpBufferSize;
  256. CHAR m_ProfileName[64];
  257. public :
  258. LPMAPISUP m_pSupObj;
  259. HANDLE m_hUIMutex;
  260. HRESULT m_hRemoteActionErr;
  261. BOOL m_fCancelPending;
  262. };