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.

247 lines
8.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. tapidb.h
  7. FILE HISTORY:
  8. */
  9. #ifndef _TAPIDB_H
  10. #define _TAPIDB_H
  11. #ifndef TAPI_H
  12. #include "tapi.h"
  13. #endif
  14. #ifndef _TAPIMMC_H
  15. #define _TAPIMMC_H
  16. #include "tapimmc.h"
  17. #endif
  18. #ifndef __DYNAMLNK_H_INCLUDED__
  19. #include "dynamlnk.h"
  20. #endif
  21. #ifndef _HARRAY_H
  22. #include "harray.h"
  23. #endif
  24. interface ITapiInfo;
  25. // we allocate a bigger line info size so that users can be added
  26. #define DEVICEINFO_GROW_SIZE 10240
  27. #define TAPI_DEFAULT_DEVICE_BUFF_SIZE 204800
  28. // hash table for status strings
  29. typedef CMap<CString, LPCTSTR, CString, CString&> CTapiStatusMap;
  30. typedef enum _TapiApiIndex
  31. {
  32. TAPI_ADD_PROVIDER = 0,
  33. TAPI_CONFIG_PROVIDER,
  34. TAPI_GET_AVAILABLE_PROVIDERS,
  35. TAPI_GET_LINE_INFO,
  36. TAPI_GET_LINE_STATUS,
  37. TAPI_GET_PHONE_INFO,
  38. TAPI_GET_PHONE_STATUS,
  39. TAPI_GET_PROVIDER_LIST,
  40. TAPI_GET_SERVER_CONFIG,
  41. TAPI_INITIALIZE,
  42. TAPI_REMOVE_PROVIDER,
  43. TAPI_SET_LINE_INFO,
  44. TAPI_SET_PHONE_INFO,
  45. TAPI_SET_SERVER_CONFIG,
  46. TAPI_GET_DEVICE_FLAGS,
  47. TAPI_SHUTDOWN
  48. };
  49. // not subject to localization
  50. static LPCSTR g_apchFunctionNames[] = {
  51. "MMCAddProvider",
  52. "MMCConfigProvider",
  53. "MMCGetAvailableProviders",
  54. "MMCGetLineInfo",
  55. "MMCGetLineStatus",
  56. "MMCGetPhoneInfo",
  57. "MMCGetPhoneStatus",
  58. "MMCGetProviderList",
  59. "MMCGetServerConfig",
  60. "MMCInitialize",
  61. "MMCRemoveProvider",
  62. "MMCSetLineInfo",
  63. "MMCSetPhoneInfo",
  64. "MMCSetServerConfig",
  65. "MMCGetDeviceFlags",
  66. "MMCShutdown",
  67. NULL
  68. };
  69. // not subject to localization
  70. extern DynamicDLL g_TapiDLL;
  71. typedef LONG (*ADDPROVIDER) (HMMCAPP, HWND, LPCWSTR, LPDWORD);
  72. typedef LONG (*CONFIGPROVIDER) (HMMCAPP, HWND, DWORD);
  73. typedef LONG (*GETAVAILABLEPROVIDERS) (HMMCAPP, LPAVAILABLEPROVIDERLIST);
  74. typedef LONG (*GETLINEINFO) (HMMCAPP, LPVOID);
  75. typedef LONG (*GETLINESTATUS) (HMMCAPP, HWND, DWORD, DWORD, DWORD, LPVARSTRING);
  76. typedef LONG (*GETPHONEINFO) (HMMCAPP, LPVOID);
  77. typedef LONG (*GETPHONESTATUS) (HMMCAPP, HWND, DWORD, DWORD, DWORD, LPVARSTRING);
  78. typedef LONG (*GETPROVIDERLIST) (HMMCAPP, LPLINEPROVIDERLIST);
  79. typedef LONG (*GETSERVERCONFIG) (HMMCAPP, LPTAPISERVERCONFIG);
  80. typedef LONG (*INITIALIZE) (LPCWSTR, LPHMMCAPP, LPDWORD, HANDLE);
  81. typedef LONG (*REMOVEPROVIDER) (HMMCAPP, HWND, DWORD);
  82. typedef LONG (*SETLINEINFO) (HMMCAPP, LPVOID);
  83. typedef LONG (*SETPHONEINFO) (HMMCAPP, LPVOID);
  84. typedef LONG (*SETSERVERCONFIG) (HMMCAPP, LPTAPISERVERCONFIG);
  85. typedef LONG (*GETDEVICEFLAGS) (HMMCAPP, BOOL, DWORD, DWORD, LPDWORD, LPDWORD);
  86. typedef LONG (*SHUTDOWN) (HMMCAPP);
  87. class CTapiConfigInfo
  88. {
  89. public:
  90. CString m_strDomainName;
  91. CString m_strUserName;
  92. CString m_strPassword;
  93. CUserInfoArray m_arrayAdministrators;
  94. DWORD m_dwFlags;
  95. };
  96. class CTapiProvider
  97. {
  98. public:
  99. DWORD m_dwProviderID;
  100. DWORD m_dwFlags;
  101. CString m_strName;
  102. CString m_strFilename;
  103. };
  104. class CTapiDevice
  105. {
  106. public:
  107. DWORD m_dwPermanentID;
  108. DWORD m_dwProviderID;
  109. CString m_strName;
  110. CStringArray m_arrayAddresses;
  111. CUserInfoArray m_arrayUsers;
  112. };
  113. typedef enum _DEVICE_TYPE
  114. {
  115. DEVICE_LINE = 0,
  116. DEVICE_PHONE,
  117. DEVICE_TYPE_MAX
  118. } DEVICE_TYPE, * LPDEVICE_TYPE;
  119. // for our interface
  120. #define DeclareITapiInfoMembers(IPURE) \
  121. STDMETHOD(Initialize) (THIS) IPURE; \
  122. STDMETHOD(Reset) (THIS) IPURE; \
  123. STDMETHOD(Destroy) (THIS) IPURE; \
  124. STDMETHOD(EnumConfigInfo) (THIS) IPURE; \
  125. STDMETHOD(GetConfigInfo) (THIS_ CTapiConfigInfo * ptapiConfigInfo) IPURE; \
  126. STDMETHOD(SetConfigInfo) (THIS_ CTapiConfigInfo * ptapiConfigInfo) IPURE; \
  127. STDMETHOD_(BOOL, IsServer) (THIS) IPURE; \
  128. STDMETHOD_(BOOL, IsTapiServer) (THIS) IPURE; \
  129. STDMETHOD(SetComputerName) (THIS_ LPCTSTR pComputer) IPURE; \
  130. STDMETHOD_(LPCTSTR, GetComputerName) (THIS) IPURE; \
  131. STDMETHOD_(int, GetProviderCount) (THIS) IPURE; \
  132. STDMETHOD(EnumProviders) (THIS) IPURE; \
  133. STDMETHOD(GetProviderInfo) (THIS_ CTapiProvider * pproviderInfo, int nIndex) IPURE; \
  134. STDMETHOD(GetProviderInfo) (THIS_ CTapiProvider * pproviderInfo, DWORD dwProviderID) IPURE; \
  135. STDMETHOD(AddProvider) (THIS_ LPCTSTR pProviderFilename, LPDWORD pdwProviderID, HWND hWnd) IPURE; \
  136. STDMETHOD(ConfigureProvider) (THIS_ DWORD dwProviderID, HWND hWnd) IPURE; \
  137. STDMETHOD(RemoveProvider) (THIS_ DWORD dwProviderID, HWND hWnd) IPURE; \
  138. STDMETHOD(EnumDevices) (THIS_ DEVICE_TYPE deviceType) IPURE; \
  139. STDMETHOD_(int, GetTotalDeviceCount) (THIS_ DEVICE_TYPE deviceType) IPURE; \
  140. STDMETHOD_(int, GetDeviceCount) (THIS_ DEVICE_TYPE deviceType, DWORD dwProviderID) IPURE; \
  141. STDMETHOD(GetDeviceInfo) (THIS_ DEVICE_TYPE deviceType, CTapiDevice * ptapiDevice, DWORD dwProviderID, int nIndex) IPURE; \
  142. STDMETHOD(SetDeviceInfo) (THIS_ DEVICE_TYPE deviceType, CTapiDevice * ptapiDevice) IPURE; \
  143. STDMETHOD(SortDeviceInfo) (THIS_ DEVICE_TYPE deviceType, DWORD dwProviderID, INDEX_TYPE indexType, DWORD dwSortOptions) IPURE; \
  144. STDMETHOD(GetDeviceStatus) (THIS_ DEVICE_TYPE deviceType, CString * pstrStatus, DWORD dwProviderID, int nIndex, HWND hWnd) IPURE; \
  145. STDMETHOD_(int, GetAvailableProviderCount) (THIS) IPURE; \
  146. STDMETHOD(EnumAvailableProviders) (THIS) IPURE; \
  147. STDMETHOD(GetAvailableProviderInfo) (THIS_ CTapiProvider * pproviderInfo, int nIndex) IPURE; \
  148. STDMETHOD_(BOOL,IsAdmin) (THIS) IPURE; \
  149. STDMETHOD_(BOOL,IsLocalMachine) (THIS) IPURE; \
  150. STDMETHOD_(BOOL,FHasServiceControl) (THIS) IPURE; \
  151. STDMETHOD(SetCachedLineBuffSize) (THIS_ DWORD dwLineSize) IPURE; \
  152. STDMETHOD(SetCachedPhoneBuffSize) (THIS_ DWORD dwPhoneSize) IPURE; \
  153. STDMETHOD_(DWORD,GetCachedLineBuffSize) (THIS) IPURE; \
  154. STDMETHOD_(DWORD,GetCachedPhoneBuffSize) (THIS) IPURE; \
  155. STDMETHOD_(BOOL,IsCacheDirty) (THIS) IPURE; \
  156. STDMETHOD(GetDeviceFlags) (THIS_ DWORD dwProviderID, DWORD dwPermanentID, LPDWORD pdwFlags) IPURE; \
  157. #undef INTERFACE
  158. #define INTERFACE ITapiInfo
  159. DECLARE_INTERFACE_(ITapiInfo, IUnknown)
  160. {
  161. DeclareIUnknownMembers(PURE)
  162. DeclareITapiInfoMembers(PURE)
  163. };
  164. typedef ComSmartPointer<ITapiInfo, &IID_ITapiInfo> SPITapiInfo;
  165. // now the object that implements ITapiInfo
  166. class CTapiInfo : public ITapiInfo
  167. {
  168. public:
  169. CTapiInfo();
  170. ~CTapiInfo();
  171. DeclareIUnknownMembers(IMPL);
  172. DeclareITapiInfoMembers(IMPL);
  173. private:
  174. void TapiConfigToInternal(LPTAPISERVERCONFIG pTapiConfig, CTapiConfigInfo & tapiConfigInfo);
  175. void InternalToTapiConfig(CTapiConfigInfo & tapiConfigInfo, LPTAPISERVERCONFIG * pTapiConfig);
  176. void TapiDeviceToInternal(DEVICE_TYPE deviceType, LPDEVICEINFO pTapiDeviceInfo, CTapiDevice & tapiDevice);
  177. void InternalToTapiDevice(CTapiDevice & tapiDevice, LPDEVICEINFOLIST * pTapiDeviceInfoList);
  178. int CalcHashValue(LPCTSTR pString);
  179. LPCTSTR GetProviderName(DWORD dwProviderID, LPCTSTR pszFilename, LPDWORD pdwFlags);
  180. DWORD GetCurrentUser();
  181. private:
  182. HMMCAPP m_hServer; // handle to server
  183. LPTAPISERVERCONFIG m_pTapiConfig;
  184. LPLINEPROVIDERLIST m_pProviderList;
  185. LPAVAILABLEPROVIDERLIST m_pAvailProviderList;
  186. LPDEVICEINFOLIST m_paDeviceInfo[DEVICE_TYPE_MAX];
  187. CString m_strComputerName;
  188. DWORD m_dwApiVersion;
  189. HANDLE m_hReinit;
  190. CIndexMgr m_IndexMgr[DEVICE_TYPE_MAX];
  191. CCriticalSection m_csData;
  192. CTapiStatusMap m_mapStatusStrings;
  193. HANDLE m_hResetEvent;
  194. LONG m_cRef;
  195. BOOL m_fIsAdmin;
  196. CString m_strCurrentUser;
  197. BOOL m_fIsLocalMachine;
  198. DWORD m_dwCachedLineSize;
  199. DWORD m_dwCachedPhoneSize;
  200. BOOL m_fCacheDirty;
  201. };
  202. HRESULT CreateTapiInfo(ITapiInfo ** ppTapiInfo);
  203. void UnloadTapiDll();
  204. DWORD IsAdmin(LPCTSTR szMachineName, LPCTSTR szAccount, LPCTSTR szPassword, BOOL * pfIsAdmin);
  205. #endif _TAPIDB_H