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.

526 lines
19 KiB

  1. /*
  2. - FAXAB . H
  3. -
  4. * Purpose:
  5. * Header file for the Microsoft At Work Fax Address Book.
  6. *
  7. * Yoram Yaacovi, 1/94
  8. */
  9. /*
  10. * Windows headers
  11. */
  12. #ifdef WIN95
  13. #undef TAPI_CURRENT_VERSION
  14. #define TAPI_CURRENT_VERSION 0x00010004
  15. #endif
  16. #ifdef WIN32
  17. #define INC_OLE2 /* Get the OLE2 stuff */
  18. #define INC_RPC /* harmless on Daytona; Chicago needs it */
  19. #endif
  20. #include <windows.h>
  21. #include <windowsx.h>
  22. #include <limits.h>
  23. #include <memory.h>
  24. #include <commdlg.h>
  25. #include <string.h>
  26. #include <mbstring.h>
  27. #define itoa _itoa // MSVCNT libs export _itoa, not itoa.
  28. /*
  29. * MAPI headers
  30. */
  31. #include <mapiwin.h>
  32. #include <mapidefs.h>
  33. #include <mapicode.h>
  34. #include <mapitags.h>
  35. #include <mapiguid.h>
  36. #include <mapispi.h>
  37. #include <mapiutil.h>
  38. #include <mapival.h>
  39. /*
  40. * TAPI headers
  41. */
  42. #include <tapi.h>
  43. /*
  44. * At Work Fax common headers
  45. */
  46. #include <awfaxab.rh>
  47. #include <awrc32.h>
  48. #include <property.h> // At Work Fax MAPI properties
  49. //#include <uiutil.h> // At Work Fax UI (awfxcg32.dll) exports
  50. //#include <mem.h> // At Work Fax UI (awfxcg32.dll) memory handling
  51. #include <debug.h> // At Work Fax UI (awfxcg32.dll) debug macros and functions
  52. #include <entryid.h> // At Work Fax various entry IDs
  53. /*
  54. * Macros
  55. */
  56. #define SIZEOF(x) sizeof(x)
  57. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  58. /*********************************************
  59. **** Common address book objects members ****
  60. *********************************************/
  61. /*
  62. * IUnknown base members
  63. */
  64. #define FAB_IUnknown \
  65. LONG lcInit; \
  66. HRESULT hResult; \
  67. UINT idsLastError; \
  68. HINSTANCE hLibrary; \
  69. LPALLOCATEBUFFER lpAllocBuff; \
  70. LPALLOCATEMORE lpAllocMore; \
  71. LPFREEBUFFER lpFreeBuff; \
  72. LPMALLOC lpMalloc; \
  73. CRITICAL_SECTION cs
  74. #define FAB_IUnkWithLogon \
  75. FAB_IUnknown; \
  76. LPABLOGON lpABLogon
  77. #define FAB_Wrapped \
  78. FAB_IUnkWithLogon; \
  79. LPMAPIPROP lpPropData
  80. /*
  81. * At Work Fax AB headers
  82. */
  83. #include "wrap.h"
  84. #include "tblwrap.h"
  85. #include "abp.h"
  86. #include "abeid.h"
  87. #include "abcont.h"
  88. #include "abctbl.h"
  89. #include "root.h"
  90. #include "status.h"
  91. #include "abuser.h"
  92. #include "oouser.h"
  93. #include "tid.h"
  94. #include "ootid.h"
  95. /**** Constants ***/
  96. #define STRING_MAX 256 // Maximum size of string in the
  97. // resource file string table or in the .ini file
  98. #define SEL_STRING_MAX 50 // Maximum size of string for drop-down box selections
  99. // Maximum sizes for various properties
  100. #define MAX_DISPLAY_NAME 150 // Maximum size of display names (??)
  101. #define MAX_ADDRTYPE 25 // Maximum size of address type (??)
  102. #define MAX_EMAIL_ADDRESS MAX_PATH // Maximum size of an email addr (fax #)
  103. #define MAX_MACHINE_CAPS 30 // Maximum size for fax capability string
  104. #define MAX_SEARCH_NAME 50
  105. // Display Table stuff
  106. #define GROUPBOX_TEXT_SIZE 40
  107. #define LABEL_TEXT_SIZE 40
  108. #define BUTTON_TEXT_SIZE 25
  109. #define TAB_TEXT_SIZE 15
  110. // TAPI-ish defines
  111. #define COUNTRY_CODE_SIZE 10
  112. #define AREA_CODE_SIZE 10
  113. #define TELEPHONE_NUMBER_SIZE 50
  114. #define ROUTING_NAME_SIZE 150
  115. #define CANONICAL_NUMBER_SIZE (10+COUNTRY_CODE_SIZE+AREA_CODE_SIZE+TELEPHONE_NUMBER_SIZE+ROUTING_NAME_SIZE)
  116. typedef struct tagPARSEDTELNUMBER
  117. {
  118. TCHAR szCountryCode[COUNTRY_CODE_SIZE+1]; // country code
  119. TCHAR szAreaCode[AREA_CODE_SIZE+1]; // area code
  120. TCHAR szTelNumber[TELEPHONE_NUMBER_SIZE+1]; // telephone number
  121. TCHAR szRoutingName[ROUTING_NAME_SIZE+1]; // routing name within the tel number destination
  122. } PARSEDTELNUMBER, *LPPARSEDTELNUMBER;
  123. BOOL EncodeFaxAddress(LPTSTR lpszFaxAddr, LPPARSEDTELNUMBER lpParsedFaxAddr);
  124. BOOL DecodeFaxAddress(LPTSTR lpszFaxAddr, LPPARSEDTELNUMBER lpParsedFaxAddr);
  125. /*
  126. * Function pointer prototypes for fax config functions
  127. */
  128. typedef BOOL (* PFN_DECODE_FAX_ADDRESS)(LPTSTR lpszFaxAddr, LPPARSEDTELNUMBER lpParsedFaxAddr);
  129. typedef BOOL (* PFN_ENCODE_FAX_ADDRESS)(LPTSTR lpszFaxAddr, LPPARSEDTELNUMBER lpParsedFaxAddr);
  130. #ifdef RADIO_BUTTON
  131. #define RADIO_BUTTON_1_RETURN_VALUE 1
  132. #define RADIO_BUTTON_2_RETURN_VALUE 2
  133. #define RADIO_BUTTON_3_RETURN_VALUE 3
  134. #define RADIO_BUTTON_4_RETURN_VALUE 4
  135. #endif
  136. /****************************************
  137. ********* Properties **************
  138. ****************************************/
  139. // CHECK: Move to property.h ?
  140. // #define EFAX_PR_OPTIONS_BASE 0x6600
  141. /*
  142. * Prop Tag associated with my szFileName in the profile
  143. */
  144. #define PR_FAB_FILE_A PROP_TAG(PT_STRING8,0x6600)
  145. #define PR_FAB_UID PROP_TAG(PT_BINARY,0x6601)
  146. /****** Display table related properties ******/
  147. // Drop Down list box for country codes
  148. #define PR_DDLBX_COUNTRIES_TABLE PROP_TAG(PT_OBJECT,0x6603)
  149. // Template Buttons
  150. #define PR_DIAL_HELPER_BUTTON PROP_TAG(PT_OBJECT,0x6604)
  151. #define PR_ADVANCED_BUTTON PROP_TAG(PT_OBJECT,0x6605)
  152. #define PR_DIAL_LONG_DISTANCE PROP_TAG(PT_BOOLEAN,0x6606)
  153. // Address components properties moved to property.h. They are
  154. // now used by chicago\security\chicago.c
  155. // 0x6607-0x660a
  156. // PR_COUNTRY_ID
  157. // PR_AREA_CODE
  158. // PR_TEL_NUMBER
  159. #define PR_PREVIOUS_CP_NAME_A PROP_TAG(PT_STRING8,0x660b)
  160. /******
  161. ****** Cross program Globals
  162. ******/
  163. #ifdef _FAXAB_ABP
  164. LCID lcidUser; // The Local Identifier
  165. MAPIUID muidABMAWF = MUIDABMAWF; // This provider's MAPIUID
  166. // HINSTANCE hInst; // This provider instance
  167. LPTSTR lpszEMT = TEXT("FAX"); // This provider's Email Type
  168. BOOL fDebugTrap = FALSE; // Deubg trap flag
  169. BOOL fExposeFaxAB = FALSE; // Whether or not to expose the Fax AB
  170. /*
  171. * structures and filters defined for display tables
  172. */
  173. DTBLLABEL dtbllabel = { sizeof(DTBLLABEL), 0 };
  174. DTBLPAGE dtblpage = { sizeof(DTBLPAGE), 0, 0, 0 };
  175. DTBLGROUPBOX dtblgroupbox = { sizeof(DTBLGROUPBOX), 0 };
  176. CHAR szNoFilter[] = "*";
  177. CHAR szDigitsOnlyFilter[] = "[0-9]";
  178. CHAR szTelephoneNumberFilter[] = "[0-9\\-\\. ,\\|AaBbCcDdPpTtWw\\*#!@\\$\\?;]";
  179. CHAR szAddrTypeFilter[] = "[~:]";
  180. CHAR szFileNameFilter[] = "[~ \\\\]"; /* ends up [~<space><tab>\\] */
  181. /*
  182. * Standard column set is straight from the spec of required columns
  183. * for Display Tables
  184. */
  185. static const SizedSPropTagArray(8, DetInitColSet) =
  186. {
  187. 8,
  188. {
  189. PR_ROWID,
  190. PR_XPOS,
  191. PR_DELTAX,
  192. PR_YPOS,
  193. PR_DELTAY,
  194. PR_CONTROL_TYPE,
  195. PR_CONTROL_FLAGS,
  196. PR_CONTROL_STRUCTURE
  197. }
  198. };
  199. #else
  200. extern LCID lcidUser;
  201. extern MAPIUID muidABMAWF;
  202. // extern HINSTANCE hInst;
  203. extern LPTSTR lpszEMT;
  204. extern BOOL fDebugTrap;
  205. extern BOOL fExposeFaxAB;
  206. extern DTBLLABEL dtbllabel;
  207. extern DTBLPAGE dtblpage;
  208. extern DTBLGROUPBOX dtblgroupbox;
  209. extern CHAR szNoFilter[];
  210. extern CHAR szDigitsOnlyFilter[];
  211. extern CHAR szTelephoneNumberFilter[];
  212. extern CHAR szAddrTypeFilter[];
  213. extern CHAR szFileNameFilter[]; // ends up [~\\]
  214. extern SPropTagArray DetInitColSet;
  215. #endif // _FAXAB_ABP
  216. /****************************************
  217. ****** Common functions prototypes ******
  218. ****************************************/
  219. /*
  220. * Creates a new contents table object
  221. */
  222. HRESULT
  223. HrNewIVTAbc (LPMAPITABLE * lppIVTAbc,
  224. LPABLOGON lpABLogon,
  225. LPABCONT lpABC,
  226. HINSTANCE hLibrary,
  227. LPALLOCATEBUFFER lpAllocBuff,
  228. LPALLOCATEMORE lpAllocMore,
  229. LPFREEBUFFER lpFreeBuff,
  230. LPMALLOC lpMalloc );
  231. /*
  232. * Creates/Updates the SAB's root hierarchy
  233. */
  234. HRESULT
  235. HrBuildRootHier(LPABLOGON lpABLogon, LPMAPITABLE * lppMAPITable);
  236. /*
  237. * Sets an error string associated with a particular hResult on an object.
  238. * It's used in conjunction with the method GetLastError.
  239. */
  240. VOID SetErrorIDS (LPVOID lpObject, HRESULT hResult, UINT ids);
  241. /*
  242. * Loads a string from a resource. Optionally allocates room for the string
  243. * if lpAllocBuff is not NULL. See ABP.C.
  244. */
  245. SCODE ScLoadString( UINT ids,
  246. ULONG ulcch,
  247. LPALLOCATEBUFFER lpAllocBuff,
  248. HINSTANCE hLibrary,
  249. LPTSTR * lppsz);
  250. /*
  251. * Calls TAPI to get current location area code and returns a pointer
  252. * to a string for it.
  253. */
  254. LPTSTR
  255. GetCurrentLocationAreaCode( void );
  256. /*
  257. * Calls TAPI to get current location country id
  258. */
  259. DWORD
  260. GetCurrentLocationCountryID( void );
  261. /* ***************************************************************************
  262. * GetCountry
  263. *
  264. * - gets the a country or a country list from TAPI
  265. *
  266. * Parameters: dwReqCountryID - a TAPI country ID. 0 for all countries
  267. *
  268. * Returns: TRUE on success, FALSE on failure. *lppLineCountryList must
  269. * be freed with LocalFree.
  270. */
  271. BOOL
  272. GetCountry( DWORD dwReqCountryID,
  273. LPLINECOUNTRYLIST *lppLineCountryList
  274. );
  275. /* ***************************************************************************
  276. * GetCountryCode
  277. *
  278. * - gets a country code when given a country ID
  279. *
  280. * Parameters: dwReqCountryID - a TAPI country ID
  281. * lpdwCountryCode - an address of a DWORD in which to store the country code
  282. *
  283. * Returns: TRUE on success, FALSE on failure.
  284. */
  285. BOOL
  286. GetCountryCode( DWORD dwReqCountryID,
  287. DWORD *lpdwCountryCode
  288. );
  289. /****************************************************************************
  290. FUNCTION: MakeMessageBox
  291. PURPOSE: Gets resource string and displays an error message box.
  292. PARAMETERS: hInst - Instnace of the caller (for getting strings)
  293. hWnd - Handle to parent window
  294. ulResult - Result/Status code
  295. 0: information message
  296. 100-499: warning message
  297. 500 and up: error message
  298. idString - Resource ID of message in StringTable
  299. fStyle - style of the message box
  300. RETURNS: the return value from MessageBox() function
  301. ****************************************************************************/
  302. int
  303. MakeMessageBox( HINSTANCE hInst,
  304. HWND hWnd,
  305. DWORD ulResult,
  306. UINT idString,
  307. UINT fStyle,
  308. ...
  309. );
  310. /* ***************************************************************************
  311. * EncodeFaxAddress
  312. *
  313. * - encodes fax address components into the format name@+country-code (area-code) fax-number
  314. *
  315. * Parameters: lpszFaxAddr - address of a buffer in which to fill the encoded fax number
  316. * lpParsedFaxAddr - an address of a PARSEDTELNUMBER structure which contains
  317. * the components of the address that need to be encoded
  318. *
  319. * Returns: TRUE on success, FALSE on failure.
  320. *
  321. * CHECK: will need localization
  322. */
  323. BOOL EncodeFaxAddress( LPTSTR lpszFaxAddr,
  324. LPPARSEDTELNUMBER lpParsedFaxAddr
  325. );
  326. /* ***************************************************************************
  327. * DecodeFaxAddress
  328. *
  329. * - parses a fax address of the format name@+country-code (area-code) fax-number
  330. *
  331. * Parameters: lpszFaxAddr - a Fax address in the above format
  332. * lpParsedFaxAddr - an address of a PARSEDTELNUMBER structure in which to
  333. * fill the parsed information
  334. *
  335. * Returns: TRUE on success, FALSE on failure.
  336. * success: full address
  337. * no routing name
  338. * no area code
  339. * failure: no '+country-code '
  340. * no telephone number
  341. *
  342. * CHECK: will need localization
  343. */
  344. BOOL DecodeFaxAddress( LPTSTR lpszFaxAddr,
  345. LPPARSEDTELNUMBER lpParsedFaxAddr
  346. );
  347. #ifdef DO_WE_REALLY_NEED_TAPI
  348. /* ***************************************************************************
  349. * InitTAPI
  350. *
  351. * initializes TAPI by calling lineInitialize. enumerates all the available
  352. * lines to set up pt_lpVdts->lprgLineInfo. also opens up each available line for
  353. * monitoring. sets up pt_lpVdts->iLineCur and pt_lpVdts->iAddrCur by checking the
  354. * preferred line/address name stored in the ini file against the available
  355. * line/address names.
  356. *
  357. * Parameters: hInst - the instance of the calling module
  358. * hWnd - window handle for UI
  359. * lpszAppName - the name of the calling module
  360. *
  361. * returns NO_ERROR if success and the corresponding error code otherwise.
  362. */
  363. DWORD
  364. InitTAPI( HINSTANCE hInst,
  365. HWND hWnd,
  366. LPTSTR lpszAppName
  367. );
  368. /****************************************************************************
  369. * DeinitTAPI
  370. *
  371. * frees up the memory allocated, closes all the lines we have opened for
  372. * monitoring and calls lineShutDown to disconnect from TAPI.
  373. */
  374. BOOL DeinitTAPI();
  375. //
  376. typedef struct _TagPTGData
  377. {
  378. CRITICAL_SECTION csInstance; // Critical section ro control access to hInst
  379. WORD wInvocationFlags; // MAWFSettingsDialog invocation flags
  380. HINSTANCE hInst; // DLL instance
  381. HWND hWnd; // Application main window
  382. LPPROPSTORAGE lpPropStorage; // Profile Section pointer
  383. tThreadParam threadParam; // parameter passed to the wait-for-app thread
  384. TCHAR szDefCoverPage[MAX_PATH]; // the default cover page file name
  385. MEMALLOCATIONS *lpMemAllocations; // pointer to the allocations array
  386. DEVICETYPE aDeviceTypes[NUMBER_OF_DEVICE_TYPES]; // the device types array
  387. WORD cDeviceTypes; // number of device types
  388. PARSEDMODEM aDevices[NUMBER_OF_DEVICES]; // The devices array
  389. WORD iDeviceIndex; // index (in the aDevices) of the active fax device
  390. WORD cDevices; // number of devices in the aDevices array
  391. NONTAPIDEVICE aNonTAPIDevices[NUMBER_OF_DEVICES]; // the non-TAPI devices array
  392. WORD iLastDeviceAdded; // type of the last device added
  393. HWND hAddModemDlg; // handle of the DeviceAdd dialog
  394. HWND hDeviceListDlg; // handle of the dialog that contains the device list
  395. LPDTS lpVdts; // TAPI info structure
  396. LPMALLOC lpMalloc; // IMalloc memory allocator
  397. } PTGDATA, *LPPTGDATA;
  398. /*********************************
  399. ****** Constants *************
  400. *********************************/
  401. #define NOT_SIGNED FALSE // for SetDlgItemInt()
  402. #define MAPI_ERROR_MAX 30
  403. #define MAX_SENDER_NAME_SIZE 255 // maximum size fo the sender name
  404. #define MAX_BILLING_CODE_SIZE 8 // Maximum size of billing code
  405. #define MAX_NUMBER_OF_BILLING_CODES 10 // Maximum number of billing codes in prev list
  406. #define NUMBER_OF_MV_STRINGS 20 // Maximum number of strings in a multi value property
  407. #define NUMBER_OF_DEVICES 20 // Maximum # of devices I can handle
  408. #define NUMBER_OF_DEVICE_TYPES 20 // Maximum # of devices types I can handle
  409. #define NUM_OF_PROPERTIES 70 // Number of properties
  410. #define SIZE_OF_PROP_STRINGS 1000 // Size of buffer allocated for ALL string properties
  411. #define SIZE_OF_PROP_SAVE_NAMES 400 // Size of buffer allocated for the property save names
  412. #define NUM_OF_MAWF_PROPERTY_PAGES 4 // Number of At Work Fax Property Sheet pages
  413. #define MAWF_SHORT 1 // Display one page MAWF property sheet
  414. #define MAWF_FULL NUM_OF_MAWF_PROPERTY_PAGES // Display all pages MAWF property sheet
  415. #define INIT_BUF_SIZE 1024
  416. #define szAWKey "Software\\Microsoft\\At Work Fax"
  417. // this should only happen if the thread did not have private storage, and
  418. // an attempt to allocate one failed
  419. #define CHECK_THREAD_STORAGE_POINTER(ptr,func,result) \
  420. if (!(ptr)) \
  421. { \
  422. Assert((ptr)); \
  423. DEBUG_TRACE("%s: bad thread storage pointer. thread %x\n", (func), GetCurrentThreadId()); \
  424. return ((result)); \
  425. }
  426. #define pt_csInstance lpPTGData->csInstance // per-thread critical section (for hInst)
  427. #define pt_wInvocationFlags lpPTGData->wInvocationFlags // per-thread invocation flags
  428. #define pt_hInst lpPTGData->hInst // per-thread instance handle
  429. #define pt_hWnd lpPTGData->hWnd // per-thread main window handle
  430. #define pt_lpPropStorage lpPTGData->lpPropStorage // per-thread property storage object
  431. #define pt_threadParam lpPTGData->threadParam // per-thread CPE thread parameters
  432. #define pt_szDefCoverPage lpPTGData->szDefCoverPage // per-thread default cover page
  433. #define pt_lpMemAllocations lpPTGData->lpMemAllocations // per-thread memory allocations tracker
  434. #define pt_aDeviceTypes lpPTGData->aDeviceTypes // per-thread device types list
  435. #define pt_cDeviceTypes lpPTGData->cDeviceTypes // per-thread # of device types
  436. #define pt_aDevices lpPTGData->aDevices // per-thread fax devices list
  437. #define pt_cDevices lpPTGData->cDevices // per-thread # of fax devices
  438. #define pt_iDeviceIndex lpPTGData->iDeviceIndex // per-thread current fax device index
  439. #define pt_aNonTAPIDevices lpPTGData->aNonTAPIDevices // per-thread non-TAPI devices array
  440. #define pt_iLastDeviceAdded lpPTGData->iLastDeviceAdded // per-thread type of last device added
  441. #define pt_hAddModemDlg lpPTGData->hAddModemDlg // per-thread AddModem dlg handle
  442. #define pt_hDeviceListDlg lpPTGData->hDeviceListDlg // per-thread device list dlg handle
  443. #define pt_lpVdts lpPTGData->lpVdts // per-thread TAPI state
  444. #define pt_lpMalloc lpPTGData->lpMalloc
  445. #endif // DO_WE_REALLY_NEED_TAPI