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.

398 lines
10 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. Revision History:
  10. 20/10/99 -danl-
  11. Change GetServerName to GetServerNameFromPrinterName.
  12. Add GetServerNameFromPrinterInfo.
  13. dd/mm/yy -author-
  14. description
  15. --*/
  16. #include <windows.h>
  17. #include <winspool.h>
  18. #include <mapiwin.h>
  19. #include <mapispi.h>
  20. #include <mapiutil.h>
  21. #include <mapicode.h>
  22. #include <mapival.h>
  23. #include <mapiwz.h>
  24. #include <richedit.h>
  25. #include <shlobj.h>
  26. #include <shellapi.h>
  27. #include <commdlg.h>
  28. #include <tchar.h>
  29. #include <stdio.h>
  30. #include <fxsapip.h>
  31. #include "resource.h"
  32. #include "faxreg.h"
  33. #include "faxmapip.h"
  34. #include "faxutil.h"
  35. #include "devmode.h"
  36. #define MAX_FILENAME_EXT 4
  37. #define SERVER_COVER_PAGE 1
  38. #define TRANSPORT_DLL_NAME_STRING FAX_MAIL_TRANSPORT_MODULE_NAME
  39. #define LEFT_MARGIN 1 // ---|
  40. #define RIGHT_MARGIN 1 // |
  41. #define TOP_MARGIN 1 // |---> in inches
  42. #define BOTTOM_MARGIN 1 // ---|
  43. #define InchesToCM(_x) (((_x) * 254L + 50) / 100)
  44. #define CMToInches(_x) (((_x) * 100L + 127) / 254)
  45. #define XPID_NAME 0
  46. #define XPID_EID 1
  47. #define XPID_SEARCH_KEY 2
  48. #define NUM_IDENTITY_PROPS 3
  49. #define RECIP_ROWID 0
  50. #define RECIP_NAME 1
  51. #define RECIP_EMAIL_ADR 2
  52. #define RECIP_TYPE 3
  53. #define RECIP_RESPONSIBILITY 4
  54. #define RECIP_DELIVER_TIME 5
  55. #define RECIP_REPORT_TIME 6
  56. #define RECIP_REPORT_TEXT 7
  57. #define RECIP_ADDR_TYPE 8
  58. #define TABLE_RECIP_PROPS 9
  59. #define MSG_DISP_TO 0
  60. #define MSG_SUBJECT 1
  61. #define MSG_CLASS 2
  62. #define MSG_BODY 3
  63. #define MSG_FLAGS 4
  64. #define MSG_SIZE 5
  65. #define MSG_PRIORITY 6
  66. #define MSG_IMPORTANCE 7
  67. #define MSG_SENSITIVITY 8
  68. #define MSG_DR_REPORT 9
  69. #define MSG_SENDER_ENTRYID 10
  70. #define NUM_MSG_PROPS 11
  71. #define MSG_ATTACH_METHOD 0
  72. #define MSG_ATTACH_NUM 1
  73. #define MSG_ATTACH_EXTENSION 2
  74. #define MSG_ATTACH_FILENAME 3
  75. #define MSG_ATTACH_PATHNAME 4
  76. #define MSG_ATTACH_LFILENAME 5
  77. #define MSG_ATTACH_TAG 6
  78. #define NUM_ATTACH_PROPS 7
  79. #define NUM_ATTACH_TABLE_PROPS 2
  80. typedef struct _USER_INFO {
  81. TCHAR BillingCode[64];
  82. TCHAR Company[128];
  83. TCHAR Dept[128];
  84. } USER_INFO, *PUSER_INFO;
  85. const static SizedSPropTagArray ( NUM_ATTACH_TABLE_PROPS, sptAttachTableProps) =
  86. {
  87. NUM_ATTACH_TABLE_PROPS,
  88. {
  89. PR_ATTACH_METHOD,
  90. PR_ATTACH_NUM
  91. }
  92. };
  93. const static SizedSPropTagArray ( NUM_ATTACH_PROPS, sptAttachProps) =
  94. {
  95. NUM_ATTACH_PROPS,
  96. {
  97. PR_ATTACH_METHOD,
  98. PR_ATTACH_NUM,
  99. PR_ATTACH_EXTENSION_A,
  100. PR_ATTACH_FILENAME_A,
  101. PR_ATTACH_PATHNAME_A,
  102. PR_ATTACH_LONG_FILENAME_A,
  103. PR_ATTACH_TAG
  104. }
  105. };
  106. const static SizedSPropTagArray (TABLE_RECIP_PROPS, sptRecipTable) =
  107. {
  108. TABLE_RECIP_PROPS,
  109. {
  110. PR_ROWID,
  111. PR_DISPLAY_NAME_A,
  112. PR_EMAIL_ADDRESS_A,
  113. PR_RECIPIENT_TYPE,
  114. PR_RESPONSIBILITY,
  115. PR_DELIVER_TIME,
  116. PR_REPORT_TIME,
  117. PR_REPORT_TEXT_A,
  118. PR_ADDRTYPE_A
  119. }
  120. };
  121. static const SizedSPropTagArray(NUM_MSG_PROPS, sptPropsForHeader) =
  122. {
  123. NUM_MSG_PROPS,
  124. {
  125. PR_DISPLAY_TO_A,
  126. PR_SUBJECT_A,
  127. PR_BODY_A,
  128. PR_MESSAGE_CLASS_A,
  129. PR_MESSAGE_FLAGS,
  130. PR_MESSAGE_SIZE,
  131. PR_PRIORITY,
  132. PR_IMPORTANCE,
  133. PR_SENSITIVITY,
  134. PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED,
  135. PR_SENDER_ENTRYID
  136. }
  137. };
  138. extern LPALLOCATEBUFFER gpfnAllocateBuffer; // MAPIAllocateBuffer function
  139. extern LPALLOCATEMORE gpfnAllocateMore; // MAPIAllocateMore function
  140. extern LPFREEBUFFER gpfnFreeBuffer; // MAPIFreeBuffer function
  141. extern HINSTANCE g_hModule; // DLL handle
  142. extern HINSTANCE g_hResource; // Resource DLL handle
  143. extern MAPIUID g_FaxGuid;
  144. LPVOID
  145. MapiMemAlloc(
  146. SIZE_T Size
  147. );
  148. LPVOID
  149. MapiMemReAlloc(
  150. LPVOID ptr,
  151. SIZE_T Size
  152. );
  153. VOID
  154. MapiMemFree(
  155. LPVOID ptr
  156. );
  157. PVOID
  158. MyEnumPrinters(
  159. LPTSTR pServerName,
  160. DWORD level,
  161. PDWORD pcPrinters
  162. );
  163. PVOID
  164. MyGetPrinter(
  165. LPTSTR PrinterName,
  166. DWORD level
  167. );
  168. void
  169. ErrorMsgBox(
  170. HINSTANCE hInstance,
  171. DWORD dwMsgId
  172. );
  173. /*
  174. - GetServerNameFromPrinterInfo
  175. -
  176. * Purpose:
  177. * Get the Server name, given a PRINTER_INFO_2 structure
  178. *
  179. * Arguments:
  180. * [in] ppi2 - Address of PRINTER_INFO_2 structure
  181. * [out] lpptszServerName - Address of string pointer for returned name.
  182. *
  183. * Returns:
  184. * BOOL - TRUE: sucess , FALSE: failure.
  185. *
  186. * Remarks:
  187. * This inline function retrieves the server from a printer info structure
  188. * in the appropriate way for win9x and NT.
  189. */
  190. inline BOOL
  191. GetServerNameFromPrinterInfo(PPRINTER_INFO_2 ppi2,LPTSTR *lpptszServerName)
  192. {
  193. if (!ppi2)
  194. {
  195. return FALSE;
  196. }
  197. #ifndef WIN95
  198. *lpptszServerName = NULL;
  199. if (ppi2->pServerName)
  200. {
  201. if (!(*lpptszServerName = StringDup(_tcsninc(ppi2->pServerName,2))))
  202. {
  203. return FALSE;
  204. }
  205. }
  206. return TRUE;
  207. #else //WIN95
  208. //
  209. // Formatted: \\Server\port
  210. //
  211. if (!(ppi2->pPortName))
  212. {
  213. return FALSE;
  214. }
  215. if (!(*lpptszServerName = StringDup(_tcsninc(ppi2->pPortName,2))))
  216. {
  217. return FALSE;
  218. }
  219. _tcstok(*lpptszServerName,TEXT("\\"));
  220. #endif //WIN95
  221. return TRUE;
  222. }
  223. BOOL
  224. GetServerNameFromPrinterName(
  225. LPTSTR PrinterName,
  226. LPTSTR *ppszServerName
  227. );
  228. LPWSTR
  229. AnsiStringToUnicodeString(
  230. LPCSTR AnsiString
  231. );
  232. LPSTR
  233. UnicodeStringToAnsiString(
  234. LPCWSTR UnicodeString
  235. );
  236. HRESULT WINAPI
  237. OpenServiceProfileSection(
  238. LPMAPISUP pSupObj,
  239. LPPROFSECT * ppProfSectObj
  240. );
  241. INT_PTR CALLBACK
  242. ConfigDlgProc(
  243. HWND hDlg,
  244. UINT message,
  245. WPARAM wParam,
  246. LPARAM lParam
  247. );
  248. DWORD
  249. GetDwordProperty(
  250. LPSPropValue pProps,
  251. DWORD PropId
  252. );
  253. DWORD
  254. GetBinaryProperty(
  255. LPSPropValue pProps,
  256. DWORD PropId,
  257. LPVOID Buffer,
  258. DWORD SizeOfBuffer
  259. );
  260. class CXPProvider : public IXPProvider
  261. {
  262. public:
  263. STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppvObj );
  264. STDMETHODIMP_(ULONG) AddRef();
  265. STDMETHODIMP_(ULONG) Release();
  266. MAPI_IXPPROVIDER_METHODS(IMPL);
  267. public :
  268. CXPProvider( HINSTANCE hInst );
  269. ~CXPProvider();
  270. private :
  271. ULONG m_cRef;
  272. CRITICAL_SECTION m_csTransport;
  273. HINSTANCE m_hInstance;
  274. };
  275. class CXPLogon : public IXPLogon
  276. {
  277. public:
  278. STDMETHODIMP QueryInterface( REFIID riid, LPVOID *ppvObj );
  279. STDMETHODIMP_(ULONG) AddRef();
  280. STDMETHODIMP_(ULONG) Release();
  281. STDMETHODIMP InitializeStatusRow(ULONG ulFlags);
  282. STDMETHODIMP GrowAddressList(LPADRLIST *ppAdrList, ULONG ulResizeBy, ULONG *pulOldAndNewCount);
  283. MAPI_IXPLOGON_METHODS(IMPL);
  284. private:
  285. void WINAPI CheckSpoolerYield( BOOL fReset = FALSE );
  286. void WINAPI UpdateStatus( BOOL fAddValidate=FALSE, BOOL fValidateOkState=FALSE );
  287. BOOL WINAPI LoadStatusString( LPTSTR pString, UINT uStringSize );
  288. DWORD SendFaxDocument(LPMESSAGE pMsgObj,LPSTREAM lpstmT,BOOL UseRichText,LPSPropValue pMsgProps,LPSRowSet pRecipRows, LPDWORD lpdwRecipientsLimit);
  289. PVOID MyGetPrinter(LPTSTR PrinterName,DWORD Level);
  290. DWORD PrintAttachmentToFile(IN LPMESSAGE pMsgObj,
  291. IN PFAXXP_CONFIG pFaxConfig,
  292. OUT LPTSTR* lpptstrOutAttachments);
  293. BOOL PrintRichText(HWND hWndRichEdit,HDC hDC);
  294. DWORD PrintPlainText(HDC hDC,LPSTREAM lpstmT,LPTSTR tszSubject, PFAXXP_CONFIG FaxConfig);
  295. DWORD PrintFaxDocumentToFile(
  296. IN LPMESSAGE pMsgObj,
  297. IN LPSTREAM lpstmT,
  298. IN BOOL UseRichText,
  299. IN PFAXXP_CONFIG pFaxConfig,
  300. IN LPTSTR tszSubject,
  301. OUT LPTSTR* lpptstrMessageFileName
  302. );
  303. DWORD PrintMessageToFile(IN LPSTREAM lpstmT,
  304. IN BOOL UseRichText,
  305. IN PFAXXP_CONFIG pFaxConfig,
  306. IN LPTSTR tszSubject,
  307. OUT LPTSTR* lpptstrOutDocument);
  308. public :
  309. CXPLogon( HINSTANCE hInstance, LPMAPISUP pSupObj, LPTSTR ProfileName );
  310. ~CXPLogon();
  311. inline void WINAPI AddStatusBits
  312. (DWORD dwNewBits) { m_ulTransportStatus |= dwNewBits; }
  313. inline void WINAPI RemoveStatusBits
  314. (DWORD dwOldBits) { m_ulTransportStatus &= ~dwOldBits; }
  315. inline DWORD WINAPI GetTransportStatusCode
  316. () { return m_ulTransportStatus; }
  317. private :
  318. ULONG m_cRef;
  319. HINSTANCE m_hInstance;
  320. BOOL m_fABWDSInstalled;
  321. ULONG m_ulTransportStatus;
  322. LPWSTR m_CpBuffer;
  323. DWORD m_CpBufferSize;
  324. public :
  325. LPMAPISUP m_pSupObj;
  326. HANDLE m_hUIMutex;
  327. HRESULT m_hRemoteActionErr;
  328. BOOL m_fCancelPending;
  329. };