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.

1665 lines
47 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. Address.h
  5. Abstract:
  6. Declaration of the CAddress
  7. Author:
  8. mquinton - 06/12/97
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef __ADDRESS_H_
  13. #define __ADDRESS_H_
  14. #include "resource.h" // main symbols
  15. #ifdef USE_PHONEMSP
  16. #include "terminal.h"
  17. #endif USE_PHONEMSP
  18. #include "ObjectSafeImpl.h"
  19. #include <mspenum.h> // for CSafeComEnum
  20. class CAddress;
  21. class CTerminal;
  22. class CTAPI;
  23. extern CHashTable * gpLineHashTable;
  24. extern CHashTable * gpHandleHashTable;
  25. extern void RemoveHandleFromHashTable(ULONG_PTR Handle);
  26. // address flag defines
  27. #define ADDRESSFLAG_MSP 0x00000001
  28. #define ADDRESSFLAG_WAVEOUTDEVICE 0x00000002
  29. #define ADDRESSFLAG_WAVEINDEVICE 0x00000004
  30. #define ADDRESSFLAG_PHONEDEVICE 0x00000008
  31. #define ADDRESSFLAG_DATAMODEM 0x00000010
  32. #define ADDRESSFLAG_PRIVATEOBJECTS 0x00000020
  33. #define ADDRESSFLAG_CALLHUB 0x00000100
  34. #define ADDRESSFLAG_CALLHUBTRACKING 0x00000200
  35. #define ADDRESSFLAG_WAVEFULLDUPLEX 0x00000400
  36. #define ADDRESSFLAG_NOCALLHUB 0x00010000
  37. #define ADDRESSFLAG_DEVSTATECHANGE 0x00020000
  38. #define ADDRESSFLAG_ADDRESSSTATECHANGE 0x00040000
  39. #define ADDRESSFLAG_DEVCAPSCHANGE 0x00080000
  40. #define ADDRESSFLAG_ADDRESSCAPSCHANGE 0x00100000
  41. #define ADDRESSFLAG_AMREL (ADDRESSFLAG_MSP | ADDRESSFLAG_WAVEINDEVICE | ADDRESSFLAG_WAVEOUTDEVICE | ADDRESSFLAG_WAVEFULLDUPLEX)
  42. #define CALLHUBSUPPORT_FULL 1
  43. #define CALLHUBSUPPORT_NONE 3
  44. #define CALLHUBSUPPORT_UNKNOWN 4
  45. // Status message defines, set by LineSetStatusMessages( )
  46. #define ALL_LINEDEVSTATE_MESSAGES (LINEDEVSTATE_OTHER | \
  47. LINEDEVSTATE_RINGING | \
  48. LINEDEVSTATE_CONNECTED | \
  49. LINEDEVSTATE_DISCONNECTED | \
  50. LINEDEVSTATE_MSGWAITON | \
  51. LINEDEVSTATE_MSGWAITOFF | \
  52. LINEDEVSTATE_INSERVICE | \
  53. LINEDEVSTATE_OUTOFSERVICE | \
  54. LINEDEVSTATE_MAINTENANCE | \
  55. LINEDEVSTATE_OPEN | \
  56. LINEDEVSTATE_CLOSE | \
  57. LINEDEVSTATE_NUMCALLS | \
  58. LINEDEVSTATE_NUMCOMPLETIONS | \
  59. LINEDEVSTATE_TERMINALS | \
  60. LINEDEVSTATE_ROAMMODE | \
  61. LINEDEVSTATE_BATTERY | \
  62. LINEDEVSTATE_SIGNAL | \
  63. LINEDEVSTATE_DEVSPECIFIC | \
  64. LINEDEVSTATE_REINIT | \
  65. LINEDEVSTATE_LOCK | \
  66. LINEDEVSTATE_CAPSCHANGE | \
  67. LINEDEVSTATE_CONFIGCHANGE | \
  68. LINEDEVSTATE_TRANSLATECHANGE | \
  69. LINEDEVSTATE_COMPLCANCEL | \
  70. LINEDEVSTATE_REMOVED)
  71. #define ALL_LINEADDRESSSTATE_MESSAGES (LINEADDRESSSTATE_OTHER | \
  72. LINEADDRESSSTATE_DEVSPECIFIC | \
  73. LINEADDRESSSTATE_INUSEZERO | \
  74. LINEADDRESSSTATE_INUSEONE | \
  75. LINEADDRESSSTATE_INUSEMANY | \
  76. LINEADDRESSSTATE_NUMCALLS | \
  77. LINEADDRESSSTATE_FORWARD | \
  78. LINEADDRESSSTATE_TERMINALS | \
  79. LINEADDRESSSTATE_CAPSCHANGE)
  80. /////////////////////////////////////////////////////////////////
  81. // Intermediate classes used for DISPID encoding
  82. template <class T>
  83. class ITAddress2Vtbl : public ITAddress2
  84. {
  85. };
  86. template <class T>
  87. class ITAddressCapabilitiesVtbl : public ITAddressCapabilities
  88. {
  89. };
  90. template <class T>
  91. class ITMediaSupportVtbl : public ITMediaSupport
  92. {
  93. };
  94. template <class T>
  95. class ITAddressTranslationVtbl : public ITAddressTranslation
  96. {
  97. };
  98. template <class T>
  99. class ITLegacyAddressMediaControl2Vtbl : public ITLegacyAddressMediaControl2
  100. {
  101. };
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CEventMasks
  104. class CEventMasks
  105. {
  106. public:
  107. CEventMasks()
  108. {
  109. m_dwTapiObjectMask = EM_NOSUBEVENTS;
  110. m_dwAddressMask = EM_NOSUBEVENTS;
  111. m_dwCallNotificationMask = EM_NOSUBEVENTS;
  112. m_dwCallStateMask = EM_NOSUBEVENTS;
  113. m_dwCallMediaMask = EM_NOSUBEVENTS;
  114. m_dwCallHubMask = EM_NOSUBEVENTS;
  115. m_dwCallInfoChangeMask = EM_NOSUBEVENTS;
  116. m_dwQOSEventMask = EM_NOSUBEVENTS;
  117. m_dwFileTerminalMask = EM_NOSUBEVENTS;
  118. m_dwPrivateMask = EM_NOSUBEVENTS;
  119. m_dwAddressDevSpecificMask = EM_NOSUBEVENTS;
  120. m_dwPhoneDevSpecificMask = EM_NOSUBEVENTS;
  121. }
  122. ~CEventMasks()
  123. {
  124. }
  125. DECLARE_TRACELOG_CLASS(CEventMasks)
  126. private:
  127. //
  128. // Event masks
  129. // Some event come from MSP:
  130. // TE_ADDRESS, TE_CALLMEDIA, TE_FILETERMINAL
  131. //
  132. DWORD m_dwTapiObjectMask; // TE_TAPIOBJECT
  133. DWORD m_dwAddressMask; // TE_ADDRESS MSP
  134. DWORD m_dwCallNotificationMask; // TE_CALLNOTIFICATION
  135. DWORD m_dwCallStateMask; // TE_CALLSTATE
  136. DWORD m_dwCallMediaMask; // TE_CALLMEDIA MSP
  137. DWORD m_dwCallHubMask; // TE_CALLHUB
  138. DWORD m_dwCallInfoChangeMask; // TE_CALLINFOCHANGE
  139. DWORD m_dwQOSEventMask; // TE_QOSEVENT
  140. DWORD m_dwFileTerminalMask; // TE_FILETERMINAL MSP
  141. DWORD m_dwPrivateMask; // TE_PRIVATE MSP
  142. DWORD m_dwAddressDevSpecificMask; // TE_ADDRESSDEVSPECIFIC
  143. DWORD m_dwPhoneDevSpecificMask; // TE_PHONEDEVSPECIFIC
  144. public:
  145. // Constants
  146. static const DWORD EM_ALLSUBEVENTS = 0x0FFFFFFF;
  147. static const DWORD EM_NOSUBEVENTS = 0x00000000;
  148. static const DWORD EM_ALLEVENTS = (DWORD)(-1);
  149. public:
  150. // Public methods
  151. HRESULT SetSubEventFlag(
  152. DWORD dwEvent, // The event
  153. DWORD dwFlag, // The flag that should be setted
  154. BOOL bEnable
  155. );
  156. HRESULT GetSubEventFlag(
  157. DWORD dwEvent, // The event
  158. DWORD dwFlag, // The flag that should be setted
  159. BOOL* pEnable
  160. );
  161. DWORD GetSubEventMask(
  162. TAPI_EVENT TapiEvent
  163. );
  164. BOOL IsSubEventValid(
  165. TAPI_EVENT TapiEvent,
  166. DWORD dwSubEvent,
  167. BOOL bAcceptAllSubEvents,
  168. BOOL bCallLevel
  169. );
  170. HRESULT CopyEventMasks(
  171. CEventMasks* pEventMasks
  172. );
  173. HRESULT SetTapiSrvAddressEventMask(
  174. IN HLINE hLine
  175. );
  176. HRESULT SetTapiSrvCallEventMask(
  177. IN HCALL hCall
  178. );
  179. private:
  180. ULONG64 GetTapiSrvEventMask(
  181. IN BOOL bCallLevel);
  182. DWORD GetTapiSrvLineStateMask();
  183. DWORD GetTapiSrvAddrStateMask();
  184. };
  185. /////////////////////////////////////////////////////////////////////////////
  186. // CAddress
  187. class CAddress :
  188. public CTAPIComObjectRoot<CAddress>,
  189. public IDispatchImpl<ITAddress2Vtbl<CAddress>, &IID_ITAddress2, &LIBID_TAPI3Lib>,
  190. public IDispatchImpl<ITAddressCapabilitiesVtbl<CAddress>, &IID_ITAddressCapabilities, &LIBID_TAPI3Lib>,
  191. public IDispatchImpl<ITMediaSupportVtbl<CAddress>, &IID_ITMediaSupport, &LIBID_TAPI3Lib>,
  192. public IDispatchImpl<ITAddressTranslationVtbl<CAddress>, &IID_ITAddressTranslation, &LIBID_TAPI3Lib>,
  193. public IDispatchImpl<ITLegacyAddressMediaControl2Vtbl<CAddress>, &IID_ITLegacyAddressMediaControl2, &LIBID_TAPI3Lib>,
  194. public CObjectSafeImpl
  195. {
  196. public:
  197. CAddress() : m_pTAPI(NULL),
  198. m_hLineApp(NULL),
  199. m_hLine(NULL),
  200. #ifdef USE_PHONEMSP
  201. m_hPhoneApp(NULL),
  202. #endif USE_PHONEMSP
  203. m_dwAPIVersion(0),
  204. m_dwDeviceID(0),
  205. m_dwAddressID(0),
  206. m_dwMediaModesSupported(0),
  207. m_szAddress(NULL),
  208. m_szAddressName(NULL),
  209. m_szProviderName(NULL),
  210. m_pMSPAggAddress(NULL),
  211. m_pPrivate(NULL),
  212. m_hMSPEvent(NULL),
  213. m_hWaitEvent(NULL),
  214. m_MSPContext(0),
  215. m_dwAddressFlags(0),
  216. m_fEnableCallHubTrackingOnLineOpen(TRUE),
  217. m_bTapiSignaledShutdown(FALSE)
  218. {
  219. LOG((TL_TRACE, "CAddress[%p] - enter", this));
  220. LOG((TL_TRACE, "CAddress - exit"));
  221. }
  222. ~CAddress()
  223. {
  224. LOG((TL_TRACE, "~CAddress[%p] - enter", this));
  225. LOG((TL_TRACE, "~CAddress - exit"));
  226. }
  227. DECLARE_DEBUG_ADDREF_RELEASE(CAddress)
  228. DECLARE_QI()
  229. DECLARE_MARSHALQI(CAddress)
  230. DECLARE_TRACELOG_CLASS(CAddress)
  231. BEGIN_COM_MAP(CAddress)
  232. // COM_INTERFACE_ENTRY_FUNC(IID_IDispatch, 0, IDispatchQI)
  233. COM_INTERFACE_ENTRY2(IDispatch, ITAddress2)
  234. COM_INTERFACE_ENTRY(ITAddress)
  235. COM_INTERFACE_ENTRY(ITAddress2)
  236. COM_INTERFACE_ENTRY(ITMediaSupport)
  237. COM_INTERFACE_ENTRY(ITAddressCapabilities)
  238. COM_INTERFACE_ENTRY(ITAddressTranslation)
  239. COM_INTERFACE_ENTRY(ITLegacyAddressMediaControl)
  240. COM_INTERFACE_ENTRY(ITLegacyAddressMediaControl2)
  241. COM_INTERFACE_ENTRY(IObjectSafety)
  242. COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pMSPAggAddress)
  243. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  244. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  245. COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pPrivate)
  246. END_COM_MAP()
  247. void FinalRelease();
  248. private:
  249. // tapi info
  250. ITTAPI * m_pTAPI;
  251. HLINEAPP m_hLineApp;
  252. HLINE m_hLine;
  253. #ifdef USE_PHONEMSP
  254. HPHONEAPP m_hPhoneApp;
  255. #endif USE_PHONEMSP
  256. // caps/info that we keep around
  257. // because it is used often
  258. DWORD m_dwAPIVersion;
  259. DWORD m_dwDeviceID;
  260. DWORD m_dwAddressID;
  261. DWORD m_dwMediaModesSupported;
  262. DWORD m_dwProviderID;
  263. PWSTR m_szAddress;
  264. PWSTR m_szAddressName;
  265. PWSTR m_szProviderName;
  266. // m_dwAddressFlags keeps some info about the address
  267. // see ADDRESSFLAG_ constants above
  268. DWORD m_dwAddressFlags;
  269. // tapi structures - using caching scheme
  270. // so these can be NULL
  271. LPLINEADDRESSCAPS m_pAddressCaps;
  272. LPLINEDEVCAPS m_pDevCaps;
  273. // current address state
  274. ADDRESS_STATE m_AddressState;
  275. // msp for this address
  276. IUnknown * m_pMSPAggAddress;
  277. // event for msp to signal on event
  278. HANDLE m_hMSPEvent;
  279. HANDLE m_hWaitEvent;
  280. // Create a context handle for MSP Callback
  281. ULONG_PTR m_MSPContext;
  282. // IUnk for the private object
  283. IUnknown * m_pPrivate;
  284. // TAPI terminals owned by this address
  285. TerminalArray m_TerminalArray;
  286. // calls currently on this address
  287. CallInfoArrayNR m_CallArray;
  288. // list of "addresslines"
  289. PtrList m_AddressLinesPtrList;
  290. // list of call notification cookies
  291. LongList m_NotificationCookies;
  292. // addressline used for callhubtracking
  293. AddressLineStruct * m_pCallHubTrackingLine;
  294. // if true, we will do LineSetCallHubTracking in FindOrOpenALine
  295. // it is only false if the user has called SetCallHubTracking(FALSE)
  296. // on this address
  297. BOOL m_fEnableCallHubTrackingOnLineOpen;
  298. //
  299. // this flag, when set, signals that the tapi object has signaled shutdown
  300. // it is currently used to synchronize creation of new calls and call
  301. // cleanup performed on tapi shutdown
  302. //
  303. BOOL m_bTapiSignaledShutdown;
  304. HRESULT UpdateAddressCaps();
  305. HRESULT UpdateLineDevCaps();
  306. ITMSPAddress * GetMSPAddress();
  307. HRESULT GetPhoneArrayFromTapiAndPrune(
  308. PhoneArray *pPhoneArray,
  309. BOOL bPreferredOnly
  310. );
  311. public:
  312. BOOL IsValidAddressLine(AddressLineStruct *pAddressLine, BOOL bAddref = FALSE);
  313. HRESULT MSPEvent();
  314. #ifdef USE_PHONEMSP
  315. HRESULT CreatePhoneDeviceMSP(
  316. IUnknown * pUnk,
  317. HLINE hLine,
  318. IUnknown ** ppMSPAggAddress
  319. );
  320. #endif USE_PHONEMSP
  321. HRESULT CreateStaticTerminalArray( TerminalArray& StaticTermArray );
  322. HRESULT CreateDynamicTerminalClassesList( TerminalClassPtrList * pList );
  323. HRESULT CreateMSPCall(
  324. MSP_HANDLE hCall,
  325. DWORD dwReserved,
  326. long lMediaType,
  327. IUnknown * pOuterUnk,
  328. IUnknown ** ppStreamControl
  329. );
  330. DWORD GetDeviceID(){ return m_dwDeviceID; }
  331. DWORD GetAPIVersion(){ return m_dwAPIVersion; }
  332. DWORD GetAddressID(){ return m_dwAddressID; }
  333. HLINEAPP GetHLineApp(){ return m_hLineApp; }
  334. #ifdef USE_PHONEMSP
  335. HPHONEAPP GetHPhoneApp(){ return m_hPhoneApp; }
  336. #endif USE_PHONEMSP
  337. BOOL HasMSP(){ return (m_pMSPAggAddress?TRUE:FALSE); }
  338. BOOL HasWaveDevice(){ return m_dwAddressFlags & (ADDRESSFLAG_WAVEINDEVICE | ADDRESSFLAG_WAVEOUTDEVICE | ADDRESSFLAG_WAVEFULLDUPLEX); }
  339. BOOL HasFullDuplexWaveDevice(){ return m_dwAddressFlags & ADDRESSFLAG_WAVEFULLDUPLEX; }
  340. BOOL HasPhoneDevice(){ return m_dwAddressFlags & ADDRESSFLAG_PHONEDEVICE; }
  341. DWORD GetMediaModes(){ return m_dwMediaModesSupported; }
  342. PWSTR GetAddressName(){ return m_szAddressName; }
  343. BOOL IsSPCallHubTrackingAddress(){ return m_dwAddressFlags & ADDRESSFLAG_CALLHUBTRACKING; }
  344. BOOL IsSPCallHubAddress(){ return m_dwAddressFlags & ADDRESSFLAG_CALLHUB; }
  345. CTAPI * GetTapi(BOOL bAddRefTapi = FALSE);
  346. BOOL HasPrivateObjects(){return m_dwAddressFlags & ADDRESSFLAG_PRIVATEOBJECTS;}
  347. DWORD GetProviderID(){return m_dwProviderID;}
  348. BOOL GetMediaMode( long lMediaType, DWORD * pdwMediaMode );
  349. HRESULT ShutdownMSPCall( IUnknown * pStreamControl );
  350. HRESULT InitializeWaveDeviceIDs( HLINE hLine );
  351. HRESULT AddNotificationLine( AddressLineStruct * pLine )
  352. {
  353. HRESULT hr = S_OK;
  354. Lock();
  355. try
  356. {
  357. m_AddressLinesPtrList.push_back( (PVOID)pLine );
  358. }
  359. catch(...)
  360. {
  361. LOG((TL_ERROR, "AddNotificationLine - failed to add to m_AddressLinesPtrList list - alloc failure" ));
  362. hr = E_OUTOFMEMORY;
  363. }
  364. Unlock();
  365. return hr;
  366. }
  367. HRESULT RegisterNotificationCookie(long lCookie);
  368. HRESULT RemoveNotificationCookie(long lCookie);
  369. void UnregisterAllCookies();
  370. void AddressOnTapiShutdown();
  371. void AddTerminal( ITTerminal * pTerminal )
  372. {
  373. Lock();
  374. m_TerminalArray.Add( pTerminal );
  375. Unlock();
  376. }
  377. HRESULT
  378. AddCallNotification(
  379. DWORD dwPrivs,
  380. DWORD dwMediaModes,
  381. long lInstance,
  382. PVOID * ppRegister
  383. );
  384. HRESULT
  385. RemoveCallNotification(
  386. PVOID pRegister
  387. );
  388. HRESULT
  389. SetCallHubTracking(
  390. BOOL bSet
  391. );
  392. DWORD DoesThisAddressSupportCallHubs( CCall * pCall );
  393. HRESULT
  394. FindOrOpenALine(
  395. DWORD dwMediaModes,
  396. AddressLineStruct ** ppAddressLine
  397. );
  398. HRESULT
  399. MaybeCloseALine(
  400. AddressLineStruct ** ppAddressLine
  401. );
  402. HRESULT
  403. InternalCreateCall(
  404. PWSTR pszDestAddress,
  405. long lAddressType,
  406. long lMediaType,
  407. CALL_PRIVILEGE cp,
  408. BOOL bNeedToNotify,
  409. HCALL hCall,
  410. BOOL bExpose,
  411. CCall ** ppCall
  412. );
  413. HRESULT Initialize(
  414. ITTAPI * pTAPI,
  415. HLINEAPP hLineApp,
  416. #ifdef USE_PHONEMSP
  417. HPHONEAPP hPhoneApp,
  418. #endif USE_PHONEMSP
  419. DWORD dwAPIVersion,
  420. DWORD dwDeviceID,
  421. DWORD dwAddressID,
  422. DWORD dwProviderID,
  423. LPLINEDEVCAPS pDevCaps,
  424. DWORD dwEventFilterMask
  425. );
  426. HRESULT
  427. AddCall(
  428. ITCallInfo * pCallInfo
  429. );
  430. HRESULT
  431. RemoveCall(
  432. ITCallInfo * pCallInfo
  433. );
  434. void InService( DWORD dwType );
  435. void OutOfService( DWORD dwType );
  436. void CapsChange( BOOL );
  437. HRESULT SaveAddressName(LPLINEDEVCAPS);
  438. void SetAddrCapBuffer( LPVOID pBuf );
  439. void SetLineDevCapBuffer( LPVOID pBuf );
  440. HRESULT ReceiveTSPData(
  441. IUnknown * pCall,
  442. LPBYTE pBuffer,
  443. DWORD dwSize
  444. );
  445. HRESULT HandleSendTSPData( MSP_EVENT_INFO * pEvent );
  446. HRESULT HandleMSPAddressEvent( MSP_EVENT_INFO * pEvent );
  447. HRESULT HandleMSPCallEvent( MSP_EVENT_INFO * pEvent );
  448. HRESULT HandleMSPFileTerminalEvent( MSP_EVENT_INFO * pEvent);
  449. HRESULT HandleMSPTTSTerminalEvent( MSP_EVENT_INFO * pEvent);
  450. HRESULT HandleMSPASRTerminalEvent( MSP_EVENT_INFO * pEvent);
  451. HRESULT HandleMSPToneTerminalEvent( MSP_EVENT_INFO * pEvent);
  452. HRESULT HandleMSPPrivateEvent( MSP_EVENT_INFO * pEvent );
  453. HRESULT ReleaseEvent( MSP_EVENT_INFO * pEvent );
  454. // ITMediaSupport methods
  455. STDMETHOD(get_MediaTypes)(long * plMediaTypes);
  456. STDMETHOD(QueryMediaType)(
  457. long lMediaType,
  458. VARIANT_BOOL * pbSupport
  459. );
  460. // ITAddress methods
  461. STDMETHOD(get_State)(ADDRESS_STATE * pAddressState);
  462. STDMETHOD(get_AddressName)(BSTR * ppName);
  463. STDMETHOD(get_ServiceProviderName)(BSTR * ppName);
  464. STDMETHOD(get_TAPIObject)(ITTAPI ** ppTapiObject);
  465. STDMETHOD(CreateCall)(
  466. BSTR lpszDestAddress,
  467. long lAddressType,
  468. long lMediaType,
  469. ITBasicCallControl ** ppCall
  470. );
  471. STDMETHOD(get_Calls)(VARIANT * pVariant);
  472. STDMETHOD(EnumerateCalls)(IEnumCall ** ppCallEnum);
  473. STDMETHOD(CreateForwardInfoObject)(ITForwardInformation ** ppForwardInfo);
  474. STDMETHOD(Forward)(
  475. ITForwardInformation * pForwardInfo,
  476. ITBasicCallControl * pCall
  477. );
  478. STDMETHOD(get_CurrentForwardInfo)(
  479. ITForwardInformation ** ppForwardInfo
  480. );
  481. STDMETHOD(get_DialableAddress)(BSTR * pDialableAddress);
  482. STDMETHOD(put_MessageWaiting)(VARIANT_BOOL fMessageWaiting);
  483. STDMETHOD(get_MessageWaiting)(VARIANT_BOOL * pfMessageWaiting);
  484. STDMETHOD(put_DoNotDisturb)(VARIANT_BOOL fDoNotDisturb);
  485. STDMETHOD(get_DoNotDisturb)(VARIANT_BOOL * pfDoNotDisturb);
  486. STDMETHOD(get_LineID)(long * plLineID);
  487. STDMETHOD(get_AddressID)(long * plAddressID);
  488. // ITAddress2 methods
  489. STDMETHOD(get_Phones)(VARIANT * pPhones);
  490. STDMETHOD(EnumeratePhones)(IEnumPhone ** ppEnumPhone);
  491. STDMETHOD(get_PreferredPhones)(VARIANT * pPhones);
  492. STDMETHOD(EnumeratePreferredPhones)(IEnumPhone ** ppEnumPhone);
  493. STDMETHOD(GetPhoneFromTerminal)(
  494. ITTerminal * pTerminal,
  495. ITPhone ** ppPhone
  496. );
  497. STDMETHOD(get_EventFilter)(
  498. TAPI_EVENT TapiEvent,
  499. long lSubEvent,
  500. VARIANT_BOOL* pEnable
  501. );
  502. STDMETHOD(put_EventFilter)(
  503. TAPI_EVENT TapiEvent,
  504. long lSubEvent,
  505. VARIANT_BOOL bEnable
  506. );
  507. STDMETHOD(DeviceSpecific)(
  508. IN ITCallInfo *pCall,
  509. IN BYTE *pParams,
  510. IN DWORD dwSize
  511. );
  512. STDMETHOD(DeviceSpecificVariant)(
  513. IN ITCallInfo *pCall,
  514. IN VARIANT varDevSpecificByteArray
  515. );
  516. STDMETHOD(NegotiateExtVersion)(
  517. IN long lLowVersion,
  518. IN long lHighVersion,
  519. IN long *plExtVersion
  520. );
  521. // itaddresscapabilities
  522. STDMETHOD(get_AddressCapability)(ADDRESS_CAPABILITY AddressCap, long * plCapability);
  523. STDMETHOD(get_AddressCapabilityString)(ADDRESS_CAPABILITY_STRING AddressCapString, BSTR * ppCapabilityString);
  524. STDMETHOD(get_CallTreatments)(VARIANT * pVariant );
  525. STDMETHOD(EnumerateCallTreatments)(IEnumBstr ** ppEnumCallTreatment );
  526. STDMETHOD(get_CompletionMessages)(VARIANT * pVariant );
  527. STDMETHOD(EnumerateCompletionMessages)(IEnumBstr ** ppEnumCompletionMessage );
  528. STDMETHOD(get_DeviceClasses)(VARIANT * pVariant );
  529. STDMETHOD(EnumerateDeviceClasses)(IEnumBstr ** ppEnumDeviceClass );
  530. // ITAddressTranslation
  531. STDMETHOD(TranslateAddress)(
  532. BSTR pAddressToTranslate,
  533. long ulCard,
  534. long ulTranslateOptions,
  535. ITAddressTranslationInfo ** ppTranslated
  536. );
  537. STDMETHOD(TranslateDialog)(
  538. TAPIHWND hwndOwner,
  539. BSTR pAddressIn
  540. );
  541. STDMETHOD(EnumerateLocations)(IEnumLocation ** ppEnumLocation );
  542. STDMETHOD(get_Locations)(VARIANT * pVariant);
  543. STDMETHOD(EnumerateCallingCards)(IEnumCallingCard ** ppEnumLocations );
  544. STDMETHOD(get_CallingCards)(VARIANT * pVariant);
  545. // ITLegacyAddressMediaControl
  546. STDMETHOD(GetID)(
  547. BSTR pDeviceClass,
  548. DWORD * pdwSize,
  549. BYTE ** ppDeviceID
  550. );
  551. STDMETHOD(GetDevConfig)(
  552. BSTR pDeviceClass,
  553. DWORD * pdwSize,
  554. BYTE ** ppDeviceConfig
  555. );
  556. STDMETHOD(SetDevConfig)(
  557. BSTR pDeviceClass,
  558. DWORD dwSize,
  559. BYTE * pDeviceConfig
  560. );
  561. // ITLegacyAddressMediaControl2
  562. STDMETHOD(ConfigDialog)(
  563. HWND hwndOwner,
  564. BSTR pDeviceClass
  565. );
  566. STDMETHOD(ConfigDialogEdit)(
  567. HWND hwndOwner,
  568. BSTR pDeviceClass,
  569. DWORD dwSizeIn,
  570. BYTE * pDeviceConfigIn,
  571. DWORD * pdwSizeOut,
  572. BYTE ** ppDeviceConfigOut
  573. );
  574. // IDispatch Methods
  575. STDMETHOD(GetIDsOfNames)(REFIID riid,
  576. LPOLESTR* rgszNames,
  577. UINT cNames,
  578. LCID lcid,
  579. DISPID* rgdispid
  580. );
  581. STDMETHOD(Invoke)(DISPID dispidMember,
  582. REFIID riid,
  583. LCID lcid,
  584. WORD wFlags,
  585. DISPPARAMS* pdispparams,
  586. VARIANT* pvarResult,
  587. EXCEPINFO* pexcepinfo,
  588. UINT* puArgErr
  589. );
  590. STDMETHOD_(ULONG, InternalAddRef)()
  591. {
  592. DWORD dwR;
  593. dwR = InterlockedIncrement(&m_dwRef);;
  594. #if DBG
  595. LogDebugAddRef(m_dwRef);
  596. #endif
  597. return dwR;
  598. }
  599. STDMETHOD_(ULONG, InternalRelease)()
  600. {
  601. DWORD dwR;
  602. PtrList::iterator iter, end;
  603. AddressLineStruct * pLine;
  604. T3LINE * pt3Line;
  605. LOG((TL_INFO, "InternalRelease - m_dwRef %d",m_dwRef ));
  606. Lock();
  607. gpLineHashTable->Lock();
  608. gpHandleHashTable->Lock();
  609. dwR = InterlockedDecrement(&m_dwRef);
  610. // if ref count is 0 (means we entered function with 1) then we final release
  611. if (0 == dwR)
  612. {
  613. // remove from the hash table, so any more messages
  614. // from tapisrv are ignored
  615. //
  616. //
  617. // release addresslines
  618. //
  619. LOG((TL_TRACE, "InternalRelease - final" ));
  620. iter = m_AddressLinesPtrList.begin();
  621. end = m_AddressLinesPtrList.end();
  622. LOG((TL_INFO, "InternalRelease - m_AddressLinesPtrList size %d ", m_AddressLinesPtrList.size() ));
  623. for ( ; iter != end; iter++ )
  624. {
  625. pLine = (AddressLineStruct *)(*iter);
  626. pt3Line = &(pLine->t3Line);
  627. if(FAILED(gpLineHashTable->Remove( (ULONG_PTR)(pt3Line->hLine) ) ))
  628. {
  629. LOG((TL_INFO, "InternalRelease - pLineHashTable->Remove failed" ));
  630. }
  631. }
  632. gpLineHashTable->Unlock();
  633. // remove from the handle hash table, so any more messages
  634. // from msp are ignored
  635. //
  636. RemoveHandleFromHashTable(m_MSPContext);
  637. // unregister all the cookies, so CTAPI::UnregisterNotifications
  638. // does nothing if called later
  639. UnregisterAllCookies();
  640. gpHandleHashTable->Unlock();
  641. // ExternalFinalRelease();
  642. dwR = m_dwRef = 0;
  643. Unlock();
  644. LOG((TL_INFO, "InternalRelease - final OK dwR %d",dwR ));
  645. }
  646. else
  647. {
  648. gpLineHashTable->Unlock();
  649. gpHandleHashTable->Unlock();
  650. Unlock();
  651. LOG((TL_INFO, "InternalRelease - not final dwR %d",dwR ));
  652. }
  653. #if DBG
  654. LogDebugRelease( dwR );
  655. #endif
  656. return dwR;
  657. }
  658. //
  659. // (implementing method from CObjectSafeImpl)
  660. // check the aggregated objects to see if they support the interface requested.
  661. // if they do, return the non-delegating IUnknown of the first object that
  662. // supports the interface.
  663. //
  664. // it needs to be released by the caller.
  665. //
  666. HRESULT QIOnAggregates(REFIID riid, IUnknown **ppNonDelegatingUnknown);
  667. public:
  668. //
  669. // Event filtering methods
  670. //
  671. HRESULT SetEventFilterMask(
  672. IN DWORD dwEventFilterMask
  673. );
  674. // Get subevents mask
  675. /*DWORD GetSubEventsMask(
  676. IN int nEvent
  677. );*/
  678. // Get subevents mask
  679. DWORD GetSubEventsMask(
  680. IN TAPI_EVENT TapiEvent
  681. );
  682. private:
  683. //
  684. // Helper methods for event filtering
  685. //
  686. HRESULT SetSubEventFlag(
  687. TAPI_EVENT TapiEvent,
  688. DWORD dwSubEvent,
  689. BOOL bEnable
  690. );
  691. HRESULT GetSubEventFlag(
  692. TAPI_EVENT TapiEvent,
  693. DWORD dwSubEvent,
  694. BOOL* pEnable
  695. );
  696. HRESULT SetSubEventFlagToCalls(
  697. TAPI_EVENT TapiEvent,
  698. DWORD dwFlag,
  699. BOOL bEnable
  700. );
  701. public:
  702. CEventMasks m_EventMasks; // Event filtering masks
  703. HRESULT GetEventMasks(
  704. OUT CEventMasks* pEventMasks
  705. );
  706. };
  707. ////////////////////////////////////////////////////////////////////////
  708. // CAddressTypeCollection
  709. //
  710. ////////////////////////////////////////////////////////////////////////
  711. class CAddressTypeCollection :
  712. public CTAPIComObjectRoot<CAddressTypeCollection>,
  713. public CComDualImpl<ITCollection, &IID_ITCollection, &LIBID_TAPI3Lib>,
  714. public CObjectSafeImpl
  715. {
  716. public:
  717. DECLARE_MARSHALQI(CAddressTypeCollection)
  718. DECLARE_TRACELOG_CLASS(CAddressTypeCollection)
  719. BEGIN_COM_MAP(CAddressTypeCollection)
  720. COM_INTERFACE_ENTRY(IDispatch)
  721. COM_INTERFACE_ENTRY(ITCollection)
  722. COM_INTERFACE_ENTRY(IObjectSafety)
  723. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  724. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  725. END_COM_MAP()
  726. private:
  727. DWORD m_dwSize;
  728. CComVariant * m_Var;
  729. public:
  730. // initialize
  731. HRESULT STDMETHODCALLTYPE Initialize(
  732. PDWORD pdwAddressTypes,
  733. DWORD dwElements
  734. )
  735. {
  736. DWORD dw;
  737. HRESULT hr = S_OK;
  738. LOG((TL_TRACE, "Initialize - enter"));
  739. // create variant array
  740. m_dwSize = dwElements;
  741. m_Var = new CComVariant[m_dwSize];
  742. if (NULL == m_Var)
  743. {
  744. LOG((TL_ERROR, "Could not alloc for CComVariant array"));
  745. hr = E_OUTOFMEMORY;
  746. }
  747. else
  748. {
  749. for (dw = 0; dw < m_dwSize; dw++)
  750. {
  751. // create a variant and add it to the collection
  752. CComVariant& var = m_Var[dw];
  753. var.vt = VT_I4;
  754. var.lVal = pdwAddressTypes[dw];
  755. }
  756. }
  757. LOG((TL_TRACE, "Initialize - exit"));
  758. return hr;
  759. }
  760. STDMETHOD(get_Count)(
  761. long* retval
  762. )
  763. {
  764. HRESULT hr = S_OK;
  765. LOG((TL_TRACE, "get_Count - enter"));
  766. try
  767. {
  768. *retval = m_dwSize;
  769. }
  770. catch(...)
  771. {
  772. hr = E_INVALIDARG;
  773. }
  774. LOG((TL_TRACE, "get_Count - exit"));
  775. return hr;
  776. }
  777. STDMETHOD(get_Item)(
  778. long Index,
  779. VARIANT* retval
  780. )
  781. {
  782. HRESULT hr = S_OK;
  783. LOG((TL_TRACE, "get_Item - enter"));
  784. if (retval == NULL)
  785. {
  786. return E_POINTER;
  787. }
  788. try
  789. {
  790. VariantInit(retval);
  791. }
  792. catch(...)
  793. {
  794. hr = E_INVALIDARG;
  795. }
  796. if (S_OK != hr)
  797. {
  798. return hr;
  799. }
  800. retval->vt = VT_I4;
  801. retval->lVal = 0;
  802. // use 1-based index, VB like
  803. if ((Index < 1) || (Index > m_dwSize))
  804. {
  805. return E_INVALIDARG;
  806. }
  807. VariantCopy(retval, &m_Var[Index-1]);
  808. LOG((TL_TRACE, "get_Item - exit"));
  809. return S_OK;
  810. }
  811. HRESULT STDMETHODCALLTYPE get__NewEnum(
  812. IUnknown** retval
  813. )
  814. {
  815. HRESULT hr = S_OK;
  816. LOG((TL_TRACE, "get__NumEnum - enter"));
  817. if (NULL == retval)
  818. {
  819. return E_POINTER;
  820. }
  821. *retval = NULL;
  822. typedef CComObject<CSafeComEnum<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT> > > enumvar;
  823. enumvar* p = new enumvar;
  824. if (NULL == p)
  825. {
  826. LOG((TL_ERROR, "Could not alloc for enumvar"));
  827. hr = E_OUTOFMEMORY;
  828. }
  829. else
  830. {
  831. hr = p->Init(&m_Var[0], &m_Var[m_dwSize], NULL, AtlFlagCopy);
  832. if (SUCCEEDED(hr))
  833. {
  834. hr = p->QueryInterface(IID_IEnumVARIANT, (void**)retval);
  835. }
  836. if (FAILED(hr))
  837. {
  838. delete p;
  839. }
  840. }
  841. LOG((TL_TRACE, "get__NewEnum - exit"));
  842. return hr;
  843. }
  844. void FinalRelease()
  845. {
  846. LOG((TL_TRACE, "FinalRelease()"));
  847. }
  848. };
  849. ////////////////////////////////////////////////////////////////////////
  850. // CTerminalClassCollection
  851. //
  852. ////////////////////////////////////////////////////////////////////////
  853. class CTerminalClassCollection :
  854. public CTAPIComObjectRoot<CTerminalClassCollection>,
  855. public CComDualImpl<ITCollection, &IID_ITCollection, &LIBID_TAPI3Lib>,
  856. public CObjectSafeImpl
  857. {
  858. public:
  859. DECLARE_MARSHALQI(CTerminalClassCollection)
  860. DECLARE_TRACELOG_CLASS(CTerminalClassCollection)
  861. BEGIN_COM_MAP(CTerminalClassCollection)
  862. COM_INTERFACE_ENTRY(IDispatch)
  863. COM_INTERFACE_ENTRY(ITCollection)
  864. COM_INTERFACE_ENTRY(IObjectSafety)
  865. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  866. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  867. END_COM_MAP()
  868. private:
  869. DWORD m_dwSize;
  870. CComVariant * m_Var;
  871. public:
  872. // initialize
  873. HRESULT STDMETHODCALLTYPE Initialize(
  874. TerminalClassPtrList classlist
  875. )
  876. {
  877. TerminalClassPtrList::iterator i;
  878. HRESULT hr = S_OK;
  879. DWORD dw = 0;
  880. LOG((TL_TRACE, "Initialize - enter"));
  881. // create variant array
  882. m_dwSize = classlist.size();
  883. m_Var = new CComVariant[m_dwSize];
  884. if (NULL == m_Var)
  885. {
  886. LOG((TL_ERROR, "Could not alloc for CComVariant array"));
  887. hr = E_OUTOFMEMORY;
  888. }
  889. else
  890. {
  891. for (i = classlist.begin(); i != classlist.end(); i++)
  892. {
  893. // create a variant and add it to the collection
  894. CComVariant& var = m_Var[dw];
  895. var.vt = VT_BSTR;
  896. var.bstrVal = *i;
  897. dw++;
  898. }
  899. }
  900. LOG((TL_TRACE, "Initialize - exit"));
  901. return hr;
  902. }
  903. STDMETHOD(get_Count)(
  904. long* retval
  905. )
  906. {
  907. HRESULT hr = S_OK;
  908. LOG((TL_TRACE, "get_Count - enter"));
  909. try
  910. {
  911. *retval = m_dwSize;
  912. }
  913. catch(...)
  914. {
  915. hr = E_INVALIDARG;
  916. }
  917. LOG((TL_TRACE, "get_Count - exit"));
  918. return hr;
  919. }
  920. STDMETHOD(get_Item)(
  921. long Index,
  922. VARIANT* retval
  923. )
  924. {
  925. HRESULT hr = S_OK;
  926. LOG((TL_TRACE, "get_Item - enter"));
  927. if (retval == NULL)
  928. {
  929. return E_POINTER;
  930. }
  931. try
  932. {
  933. VariantInit(retval);
  934. }
  935. catch(...)
  936. {
  937. hr = E_INVALIDARG;
  938. }
  939. if (S_OK != hr)
  940. {
  941. return hr;
  942. }
  943. retval->vt = VT_BSTR;
  944. retval->bstrVal = NULL;
  945. // use 1-based index, VB like
  946. if ((Index < 1) || (Index > m_dwSize))
  947. {
  948. return E_INVALIDARG;
  949. }
  950. VariantCopy(retval, &m_Var[Index-1]);
  951. LOG((TL_TRACE, "get_Item - exit"));
  952. return S_OK;
  953. }
  954. HRESULT STDMETHODCALLTYPE get__NewEnum(
  955. IUnknown** retval
  956. )
  957. {
  958. HRESULT hr;
  959. LOG((TL_TRACE, "get__NumEnum - enter"));
  960. if (NULL == retval)
  961. {
  962. return E_POINTER;
  963. }
  964. *retval = NULL;
  965. typedef CComObject<CSafeComEnum<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT> > > enumvar;
  966. enumvar* p = new enumvar;
  967. if ( NULL == m_Var )
  968. {
  969. LOG((TL_ERROR, "Internal variant is NULL"));
  970. hr = E_FAIL;
  971. }
  972. else if ( NULL == p )
  973. {
  974. LOG((TL_ERROR, "Could not alloc for enumvar"));
  975. hr = E_OUTOFMEMORY;
  976. }
  977. else
  978. {
  979. hr = p->Init(&m_Var[0], &m_Var[m_dwSize], NULL, AtlFlagCopy);
  980. if (SUCCEEDED(hr))
  981. {
  982. hr = p->QueryInterface(IID_IEnumVARIANT, (void**)retval);
  983. }
  984. if (FAILED(hr))
  985. {
  986. delete p;
  987. }
  988. }
  989. LOG((TL_TRACE, "get__NewEnum - exit"));
  990. return hr;
  991. }
  992. void FinalRelease()
  993. {
  994. LOG((TL_INFO, "FinalRelease()"));
  995. }
  996. };
  997. class CAddressEvent :
  998. public CTAPIComObjectRoot<CAddressEvent>,
  999. public CComDualImpl<ITAddressEvent, &IID_ITAddressEvent, &LIBID_TAPI3Lib>,
  1000. public CObjectSafeImpl
  1001. {
  1002. public:
  1003. DECLARE_MARSHALQI(CAddressEvent)
  1004. DECLARE_TRACELOG_CLASS(CAddressEvent)
  1005. BEGIN_COM_MAP(CAddressEvent)
  1006. COM_INTERFACE_ENTRY(IDispatch)
  1007. COM_INTERFACE_ENTRY(ITAddressEvent)
  1008. COM_INTERFACE_ENTRY(IObjectSafety)
  1009. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  1010. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  1011. END_COM_MAP()
  1012. static HRESULT FireEvent(
  1013. CAddress * pAddress,
  1014. ADDRESS_EVENT Event,
  1015. ITTerminal * pTerminal
  1016. );
  1017. void FinalRelease();
  1018. protected:
  1019. ITAddress * m_pAddress;
  1020. ADDRESS_EVENT m_Event;
  1021. ITTerminal * m_pTerminal;
  1022. #if DBG
  1023. PWSTR m_pDebug;
  1024. #endif
  1025. public:
  1026. //
  1027. // itaddressstateevent
  1028. //
  1029. STDMETHOD(get_Address)( ITAddress ** ppAddress );
  1030. STDMETHOD(get_Event)( ADDRESS_EVENT * pEvent );
  1031. STDMETHOD(get_Terminal)( ITTerminal ** ppTerminal );
  1032. };
  1033. class CAddressDevSpecificEvent :
  1034. public CTAPIComObjectRoot<CAddressDevSpecificEvent, CComMultiThreadModelNoCS>,
  1035. public CComDualImpl<ITAddressDeviceSpecificEvent, &IID_ITAddressDeviceSpecificEvent, &LIBID_TAPI3Lib>,
  1036. public CObjectSafeImpl
  1037. {
  1038. public:
  1039. DECLARE_MARSHALQI(CAddressDevSpecificEvent)
  1040. DECLARE_TRACELOG_CLASS(CAddressDevSpecificEvent)
  1041. BEGIN_COM_MAP(CAddressDevSpecificEvent)
  1042. COM_INTERFACE_ENTRY(IDispatch)
  1043. COM_INTERFACE_ENTRY(ITAddressDeviceSpecificEvent)
  1044. COM_INTERFACE_ENTRY(IObjectSafety)
  1045. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  1046. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  1047. END_COM_MAP()
  1048. static HRESULT FireEvent(
  1049. CAddress * pAddress,
  1050. CCall * pCall,
  1051. long lParam1,
  1052. long lParam2,
  1053. long lParam3
  1054. );
  1055. ~CAddressDevSpecificEvent();
  1056. protected:
  1057. CAddressDevSpecificEvent();
  1058. //
  1059. // properties
  1060. //
  1061. ITAddress *m_pAddress;
  1062. ITCallInfo *m_pCall;
  1063. long m_l1;
  1064. long m_l2;
  1065. long m_l3;
  1066. #if DBG
  1067. PWSTR m_pDebug;
  1068. #endif
  1069. public:
  1070. STDMETHOD(get_Address)( ITAddress ** ppAddress );
  1071. STDMETHOD(get_Call) ( ITCallInfo ** ppCall );
  1072. STDMETHOD(get_lParam1)( long *plParam1 );
  1073. STDMETHOD(get_lParam2)( long *plParam2 );
  1074. STDMETHOD(get_lParam3)( long *plParam3 );
  1075. };
  1076. #define NUMFORWARDTYPES 18
  1077. typedef struct
  1078. {
  1079. DWORD dwForwardType;
  1080. BSTR bstrDestination;
  1081. BSTR bstrCaller;
  1082. DWORD dwCallerAddressType;
  1083. DWORD dwDestAddressType;
  1084. } MYFORWARDSTRUCT;
  1085. class CForwardInfo :
  1086. public CTAPIComObjectRoot<CForwardInfo>,
  1087. public CComDualImpl<ITForwardInformation2, &IID_ITForwardInformation2, &LIBID_TAPI3Lib>,
  1088. public CObjectSafeImpl
  1089. {
  1090. public:
  1091. DECLARE_MARSHALQI(CForwardInfo)
  1092. DECLARE_TRACELOG_CLASS(CForwardInfo)
  1093. BEGIN_COM_MAP(CForwardInfo)
  1094. COM_INTERFACE_ENTRY2(IDispatch, ITForwardInformation2)
  1095. COM_INTERFACE_ENTRY(ITForwardInformation)
  1096. COM_INTERFACE_ENTRY(ITForwardInformation2)
  1097. COM_INTERFACE_ENTRY(IObjectSafety)
  1098. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  1099. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  1100. END_COM_MAP()
  1101. HRESULT Initialize();
  1102. HRESULT CreateForwardList( LINEFORWARDLIST ** ppForwardList );
  1103. void FinalRelease();
  1104. protected:
  1105. MYFORWARDSTRUCT m_ForwardStructs[NUMFORWARDTYPES];
  1106. long m_lNumRings;
  1107. public:
  1108. STDMETHOD(put_NumRingsNoAnswer)(long lNumRings);
  1109. STDMETHOD(get_NumRingsNoAnswer)(long * plNumRings);
  1110. STDMETHOD(SetForwardType)(
  1111. long ForwardType,
  1112. BSTR pDestAddress,
  1113. BSTR pCallerAddress
  1114. );
  1115. STDMETHOD(get_ForwardTypeDestination)(
  1116. long ForwardType,
  1117. BSTR * ppDestAddress
  1118. );
  1119. STDMETHOD(get_ForwardTypeCaller)(
  1120. long Forwardtype,
  1121. BSTR * ppCallerAddress
  1122. );
  1123. STDMETHOD(GetForwardType)(
  1124. long ForwardType,
  1125. BSTR * ppDestinationAddress,
  1126. BSTR * ppCallerAddress
  1127. );
  1128. STDMETHOD(Clear)();
  1129. STDMETHOD(SetForwardType2)(
  1130. long ForwardType,
  1131. BSTR pDestAddress,
  1132. long DestAddressType,
  1133. BSTR pCallerAddress,
  1134. long CallerAddressType
  1135. );
  1136. STDMETHOD(GetForwardType2)(
  1137. long ForwardType,
  1138. BSTR * ppDestinationAddress,
  1139. long * pDestAddressType,
  1140. BSTR * ppCallerAddress,
  1141. long * pCallerAddressType
  1142. );
  1143. STDMETHOD(get_ForwardTypeDestinationAddressType)(
  1144. long ForwardType,
  1145. long * pDestAddressType
  1146. );
  1147. STDMETHOD(get_ForwardTypeCallerAddressType)(
  1148. long Forwardtype,
  1149. long * pCallerAddressType
  1150. );
  1151. };
  1152. #define FORWARDMODENEEDSCALLER(__dwMode__) \
  1153. ( ( LINEFORWARDMODE_UNCONDSPECIFIC | LINEFORWARDMODE_BUSYSPECIFIC | \
  1154. LINEFORWARDMODE_NOANSWSPECIFIC | LINEFORWARDMODE_BUSYNASPECIFIC ) & \
  1155. (__dwMode__) )
  1156. ////////////////////////////////////////////////////////////////////////
  1157. // CAddressTranslationInfo
  1158. //
  1159. ////////////////////////////////////////////////////////////////////////
  1160. class CAddressTranslationInfo :
  1161. public CTAPIComObjectRoot<CAddressTranslationInfo>,
  1162. public CComDualImpl<ITAddressTranslationInfo, &IID_ITAddressTranslationInfo, &LIBID_TAPI3Lib>,
  1163. public CObjectSafeImpl
  1164. {
  1165. public:
  1166. CAddressTranslationInfo() : m_szDialableString(NULL),
  1167. m_szDisplayableString(NULL),
  1168. m_dwCurrentCountryCode(0),
  1169. m_dwDestinationCountryCode(0),
  1170. m_dwTranslationResults(0)
  1171. {}
  1172. DECLARE_MARSHALQI(CAddressTranslationInfo)
  1173. DECLARE_TRACELOG_CLASS(CAddressTranslationInfo)
  1174. BEGIN_COM_MAP(CAddressTranslationInfo)
  1175. COM_INTERFACE_ENTRY(IDispatch)
  1176. COM_INTERFACE_ENTRY(ITAddressTranslationInfo)
  1177. COM_INTERFACE_ENTRY(IObjectSafety)
  1178. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  1179. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  1180. END_COM_MAP()
  1181. HRESULT Initialize(
  1182. PWSTR pszDialableString,
  1183. PWSTR pszDisplayableString,
  1184. DWORD dwCurrentCountry,
  1185. DWORD dwDestCountry,
  1186. DWORD dwTranslateResults
  1187. );
  1188. void FinalRelease();
  1189. private:
  1190. DWORD m_dwCurrentCountryCode;
  1191. DWORD m_dwDestinationCountryCode;
  1192. DWORD m_dwTranslationResults;
  1193. PWSTR m_szDialableString;
  1194. PWSTR m_szDisplayableString;
  1195. public:
  1196. STDMETHOD(get_DialableString)(BSTR * ppDialableString );
  1197. STDMETHOD(get_DisplayableString)(BSTR * ppDisplayableString );
  1198. STDMETHOD(get_CurrentCountryCode)(long * CountryCode );
  1199. STDMETHOD(get_DestinationCountryCode)(long * CountryCode );
  1200. STDMETHOD(get_TranslationResults)(long * Results );
  1201. };
  1202. ////////////////////////////////////////////////////////////////////////
  1203. // CLocationInfo
  1204. //
  1205. ////////////////////////////////////////////////////////////////////////
  1206. class CLocationInfo:
  1207. public CTAPIComObjectRoot<CLocationInfo>,
  1208. public CComDualImpl<ITLocationInfo, &IID_ITLocationInfo, &LIBID_TAPI3Lib>,
  1209. public CObjectSafeImpl
  1210. {
  1211. public:
  1212. DECLARE_MARSHALQI(CLocationInfo)
  1213. DECLARE_TRACELOG_CLASS(CLocationInfo)
  1214. BEGIN_COM_MAP(CLocationInfo)
  1215. COM_INTERFACE_ENTRY(IDispatch)
  1216. COM_INTERFACE_ENTRY(ITLocationInfo)
  1217. COM_INTERFACE_ENTRY(IObjectSafety)
  1218. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  1219. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  1220. END_COM_MAP()
  1221. HRESULT Initialize(
  1222. PWSTR pszLocationName,
  1223. PWSTR pszCityCode,
  1224. PWSTR pszLocalAccessCode,
  1225. PWSTR pszLongDistanceAccessCode,
  1226. PWSTR pszTollPrefixList,
  1227. PWSTR pszCancelCallWaitingCode ,
  1228. DWORD dwPermanentLocationID,
  1229. DWORD dwCountryCode,
  1230. DWORD dwPreferredCardID,
  1231. DWORD dwCountryID,
  1232. DWORD dwOptions
  1233. );
  1234. void FinalRelease();
  1235. private:
  1236. DWORD m_dwPermanentLocationID;
  1237. DWORD m_dwCountryCode;
  1238. DWORD m_dwCountryID;
  1239. DWORD m_dwOptions;
  1240. DWORD m_dwPreferredCardID;
  1241. PWSTR m_szLocationName;
  1242. PWSTR m_szCityCode;
  1243. PWSTR m_szLocalAccessCode;
  1244. PWSTR m_szLongDistanceAccessCode;
  1245. PWSTR m_szTollPrefixList;
  1246. PWSTR m_szCancelCallWaitingCode;
  1247. public:
  1248. // ITLocationInfo
  1249. STDMETHOD(get_PermanentLocationID)(long * ulLocationID );
  1250. STDMETHOD(get_CountryCode)(long * ulCountryCode);
  1251. STDMETHOD(get_CountryID)(long * ulCountryID);
  1252. STDMETHOD(get_Options)(long * Options);
  1253. STDMETHOD(get_PreferredCardID)( long * ulCardID);
  1254. STDMETHOD(get_LocationName)(BSTR * ppLocationName );
  1255. STDMETHOD(get_CityCode)(BSTR * ppCode );
  1256. STDMETHOD(get_LocalAccessCode)(BSTR * ppCode );
  1257. STDMETHOD(get_LongDistanceAccessCode)(BSTR * ppCode );
  1258. STDMETHOD(get_TollPrefixList)(BSTR * ppTollList);
  1259. STDMETHOD(get_CancelCallWaitingCode)(BSTR * ppCode );
  1260. };
  1261. ////////////////////////////////////////////////////////////////////////
  1262. // CCallingCard
  1263. //
  1264. ////////////////////////////////////////////////////////////////////////
  1265. class CCallingCard:
  1266. public CTAPIComObjectRoot<CCallingCard>,
  1267. public CComDualImpl<ITCallingCard, &IID_ITCallingCard, &LIBID_TAPI3Lib>,
  1268. public CObjectSafeImpl
  1269. {
  1270. public:
  1271. DECLARE_MARSHALQI(CCallingCard)
  1272. DECLARE_TRACELOG_CLASS(CCallingCard)
  1273. BEGIN_COM_MAP(CCallingCard)
  1274. COM_INTERFACE_ENTRY(IDispatch)
  1275. COM_INTERFACE_ENTRY(ITCallingCard)
  1276. COM_INTERFACE_ENTRY(IObjectSafety)
  1277. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  1278. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  1279. END_COM_MAP()
  1280. HRESULT Initialize(
  1281. PWSTR pszCardName,
  1282. PWSTR pszSameAreaDialingRule,
  1283. PWSTR pszLongDistanceDialingRule,
  1284. PWSTR pszInternationalDialingRule,
  1285. DWORD dwPermanentCardID,
  1286. DWORD dwNumberOfDigits,
  1287. DWORD dwOptions
  1288. );
  1289. void FinalRelease();
  1290. private:
  1291. DWORD m_dwPermanentCardID;
  1292. DWORD m_dwNumberOfDigits;
  1293. DWORD m_dwOptions;
  1294. PWSTR m_szCardName;
  1295. PWSTR m_szSameAreaDialingRule;
  1296. PWSTR m_szLongDistanceDialingRule;
  1297. PWSTR m_szInternationalDialingRule;
  1298. public:
  1299. // ITCallingCard
  1300. STDMETHOD(get_PermanentCardID)(long * ulCardID);
  1301. STDMETHOD(get_NumberOfDigits)(long * ulDigits);
  1302. STDMETHOD(get_Options)(long * ulOptions);
  1303. STDMETHOD(get_CardName)(BSTR * ppCardName );
  1304. STDMETHOD(get_SameAreaDialingRule)(BSTR * ppRule );
  1305. STDMETHOD(get_LongDistanceDialingRule)(BSTR * ppRule );
  1306. STDMETHOD(get_InternationalDialingRule)(BSTR * ppRule );
  1307. };
  1308. /////////////////////////////////////////////////////////////////////////////
  1309. // _CopyBSTR is used in creating BSTR enumerators.
  1310. /////////////////////////////////////////////////////////////////////////////
  1311. class _CopyBSTR
  1312. {
  1313. public:
  1314. static void copy(BSTR *p1, BSTR *p2)
  1315. {
  1316. (*p1) = SysAllocString(*p2);
  1317. }
  1318. static void init(BSTR* p) {*p = NULL;}
  1319. static void destroy(BSTR* p) { SysFreeString(*p);}
  1320. };
  1321. #endif //__ADDRESS_H_