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.

190 lines
7.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: cnetapi.h
  7. //
  8. // Contents: Network/SENS API wrappers
  9. //
  10. // Classes:
  11. //
  12. // Notes:
  13. //
  14. // History: 08-Dec-97 rogerg Created.
  15. //
  16. //--------------------------------------------------------------------------
  17. #ifndef _MOBSYNC_NETAPIIMPL
  18. #define _MOBSYNC_NETAPIIMPL
  19. // not defined until 401 but need to include header as 40 so rasconn
  20. // structure is valid on 40
  21. #ifndef RASADP_LoginSessionDisable
  22. #define RASADP_LoginSessionDisable 1
  23. #endif // RASADP_LoginSessionDisable
  24. // Sens definitions
  25. typedef BOOL (WINAPI *ISNETWORKALIVE)(LPDWORD);
  26. // Ras definitions
  27. typedef DWORD (APIENTRY *RASENUMCONNECTIONSW)( LPRASCONNW, LPDWORD, LPDWORD );
  28. typedef DWORD (APIENTRY *RASENUMCONNECTIONSA)( LPRASCONNA, LPDWORD, LPDWORD );
  29. typedef DWORD (APIENTRY *RASDIAL)(LPRASDIALEXTENSIONS, LPTSTR, LPRASDIALPARAMS, DWORD,
  30. LPVOID, LPHRASCONN );
  31. typedef DWORD (APIENTRY *RASHANGUP)( HRASCONN );
  32. typedef DWORD (APIENTRY *RASGETCONNECTSTATUSPROC)( HRASCONN, LPRASCONNSTATUS );
  33. typedef DWORD (APIENTRY *RASGETERRORSTRINGPROCW)( UINT, LPWSTR, DWORD );
  34. typedef DWORD (APIENTRY *RASGETERRORSTRINGPROCA)( UINT, LPSTR, DWORD );
  35. typedef DWORD (APIENTRY *RASGETAUTODIALPARAM)(DWORD, LPVOID, LPDWORD );
  36. typedef DWORD (APIENTRY *RASSETAUTODIALPARAM)(DWORD, LPVOID, DWORD );
  37. typedef DWORD (APIENTRY *RASENUMENTRIESPROCA)( LPSTR, LPSTR, LPRASENTRYNAMEA, LPDWORD,
  38. LPDWORD );
  39. typedef DWORD (APIENTRY *RASENUMENTRIESPROCW)( LPWSTR, LPWSTR, LPRASENTRYNAMEW, LPDWORD,
  40. LPDWORD );
  41. typedef DWORD (APIENTRY *RASGETENTRYPROPERTIESPROC)(LPTSTR, LPTSTR, LPBYTE, LPDWORD,
  42. LPBYTE, LPDWORD );
  43. #ifndef RASDEFINED
  44. #define RASDEFINED
  45. #endif //RASDEFINED
  46. // wininet definitions
  47. typedef DWORD (WINAPI *INTERNETDIAL)(HWND hwndParent,char* lpszConnectoid,DWORD dwFlags,
  48. LPDWORD lpdwConnection, DWORD dwReserved);
  49. typedef DWORD (WINAPI *INTERNETDIALW)(HWND hwndParent,WCHAR* lpszConnectoid,DWORD dwFlags,
  50. LPDWORD lpdwConnection, DWORD dwReserved);
  51. typedef DWORD (WINAPI *INTERNETHANGUP)(DWORD dwConnection,DWORD dwReserved);
  52. typedef BOOL (WINAPI *INTERNETAUTODIAL)(DWORD dwFlags,DWORD dwReserved);
  53. typedef BOOL (WINAPI *INTERNETAUTODIALHANGUP)(DWORD dwReserved);
  54. typedef BOOL (WINAPI *INTERNETGETLASTRESPONSEINFO)(LPDWORD lpdwError,
  55. LPSTR lpszBuffer,LPDWORD lpdwBufferLength);
  56. typedef BOOL (WINAPI *INTERNETQUERYOPTION)( HINTERNET hInternet,
  57. DWORD dwOption,
  58. LPVOID lpBuffer,
  59. LPDWORD lpdwBufferLength );
  60. typedef BOOL (WINAPI *INTERNETSETOPTION)( HINTERNET hInternet,
  61. DWORD dwOption,
  62. LPVOID lpBuffer,
  63. DWORD dwBufferLength );
  64. BOOL IsRasInstalled(void);
  65. // declaration of our internal class
  66. class CNetApi : public INetApi, public CLockHandler
  67. {
  68. public:
  69. CNetApi();
  70. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  71. STDMETHODIMP_(ULONG) AddRef();
  72. STDMETHODIMP_(ULONG) Release();
  73. STDMETHODIMP_(BOOL) IsSensInstalled(void);
  74. STDMETHODIMP_(BOOL) IsNetworkAlive(LPDWORD lpdwFlags);
  75. STDMETHODIMP GetWanConnections(DWORD *cbNumEntries,RASCONN **pWanConnections);
  76. STDMETHODIMP FreeWanConnections(RASCONN *pWanConnections);
  77. STDMETHODIMP GetConnectionStatus(LPCTSTR pszConnectionName,DWORD ConnectionType,BOOL *fConnected,BOOL *fCanEstablishConnection);
  78. STDMETHODIMP RasGetAutodial( BOOL& fEnabled );
  79. STDMETHODIMP RasSetAutodial( BOOL fEnabled );
  80. STDMETHODIMP_(DWORD) RasGetErrorStringProc( UINT uErrorValue, LPTSTR lpszErrorString,DWORD cBufSize);
  81. STDMETHODIMP_(DWORD) RasEnumEntries(LPWSTR reserved,LPWSTR lpszPhoneBook,
  82. LPRASENTRYNAME lprasEntryName,LPDWORD lpcb,LPDWORD lpcEntries);
  83. STDMETHODIMP_(DWORD) RasEnumConnections(LPRASCONNW lprasconn,LPDWORD lpcb,LPDWORD lpcConnections);
  84. // ConvertGuid is only supported on NT 5.0
  85. STDMETHODIMP RasConvertGuidToEntry(GUID *pGuid,LPWSTR lpszEntry,RASENTRY *pRasEntry);
  86. // methods for calling wininet
  87. STDMETHODIMP_(DWORD) InternetDialA(HWND hwndParent,char* lpszConnectoid,DWORD dwFlags,
  88. LPDWORD lpdwConnection, DWORD dwReserved);
  89. STDMETHODIMP_(DWORD)InternetDialW(HWND hwndParent,WCHAR* lpszConnectoid,DWORD dwFlags,
  90. LPDWORD lpdwConnection, DWORD dwReserved);
  91. STDMETHODIMP_(DWORD)InternetHangUp(DWORD dwConnection,DWORD dwReserved);
  92. STDMETHODIMP_(BOOL) InternetAutodial(DWORD dwFlags,DWORD dwReserved);
  93. STDMETHODIMP_(BOOL) InternetAutodialHangup(DWORD dwReserved);
  94. STDMETHODIMP InternetGetAutodial( BOOL& fEnabled );
  95. STDMETHODIMP InternetSetAutodial( BOOL fEnabled );
  96. STDMETHODIMP_(BOOL) IsGlobalOffline(void);
  97. STDMETHODIMP_(BOOL) SetOffline(BOOL fOffline);
  98. // methods that aren't unicode wrapped
  99. #if 0
  100. STDMETHODIMP_(DWORD) RasDial(TCHAR *pszConnectionName,HRASCONN *hRasConn);
  101. STDMETHODIMP_(DWORD) RasDialDlg(TCHAR *pszConnectionName,HRASCONN *phRasConn);
  102. STDMETHODIMP RasHangup(HRASCONN hRasConn);
  103. STDMETHODIMP_(DWORD) RasDialProc(LPRASDIALEXTENSIONS lpRasDialExtensions,
  104. LPTSTR lpszPhonebook, LPRASDIALPARAMS lpRasDialParams,
  105. DWORD dwNotifierType, LPVOID lpvNotifier,
  106. LPHRASCONN phRasConn);
  107. STDMETHODIMP_(DWORD) RasHangUpProc( HRASCONN hrasconn);
  108. STDMETHODIMP_(DWORD) RasGetConnectStatusProc(HRASCONN hrasconn,LPRASCONNSTATUS lprasconnstatus);
  109. STDMETHODIMP_(DWORD) RasGetEntryDialParamsProc(LPCTSTR lpszPhonebook,LPRASDIALPARAMS lprasdialparams,LPBOOL lpfPassword);
  110. #endif // 0
  111. private:
  112. ~CNetApi();
  113. DWORD RasEnumEntriesNT50(LPWSTR reserved,LPWSTR lpszPhoneBook,
  114. LPRASENTRYNAME lprasEntryName,LPDWORD lpcb,LPDWORD lpcEntries);
  115. HRESULT LoadRasApiDll();
  116. HRESULT LoadWinInetDll();
  117. STDMETHODIMP LoadSensDll();
  118. // Sens Dll imports
  119. BOOL m_fTriedToLoadSens;
  120. HINSTANCE m_hInstSensApiDll;
  121. ISNETWORKALIVE m_pIsNetworkAlive;
  122. // Ras Dll Imports
  123. BOOL m_fTriedToLoadRas;
  124. HINSTANCE m_hInstRasApiDll;
  125. RASENUMCONNECTIONSW m_pRasEnumConnectionsW;
  126. RASENUMCONNECTIONSA m_pRasEnumConnectionsA;
  127. RASENUMENTRIESPROCA m_pRasEnumEntriesA;
  128. RASENUMENTRIESPROCW m_pRasEnumEntriesW;
  129. RASGETENTRYPROPERTIESPROC m_pRasGetEntryPropertiesW;
  130. RASGETERRORSTRINGPROCW m_pRasGetErrorStringW;
  131. RASGETERRORSTRINGPROCA m_pRasGetErrorStringA;
  132. // Ras dll imports of NT 4 or 5
  133. RASGETAUTODIALPARAM m_pRasGetAutodialParam;
  134. RASSETAUTODIALPARAM m_pRasSetAutodialParam;
  135. #if 0
  136. RASDIAL m_pRasDial;
  137. RASHANGUP m_pRasHangup;
  138. RASGETCONNECTSTATUSPROC m_pRasConnectStatus;
  139. RASGETENTRYDIALPARAMSPROC m_pRasEntryGetDialParams;
  140. #endif // 0
  141. // wininet Dll Imports
  142. BOOL m_fTriedToLoadWinInet;
  143. HINSTANCE m_hInstWinInetDll;
  144. INTERNETDIAL m_pInternetDial;
  145. INTERNETDIALW m_pInternetDialW;
  146. INTERNETHANGUP m_pInternetHangUp;
  147. INTERNETAUTODIAL m_pInternetAutodial;
  148. INTERNETAUTODIALHANGUP m_pInternetAutodialHangup;
  149. INTERNETQUERYOPTION m_pInternetQueryOption;
  150. INTERNETSETOPTION m_pInternetSetOption;
  151. BOOL m_fIsUnicode; // Is base OS Unicode enabled ?
  152. ULONG m_cRefs; // Reference count for this global object
  153. };
  154. #endif // _MOBSYNC_NETAPIIMPL