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.

419 lines
12 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ISAPIprovider.cpp
  5. Abstract:
  6. This file contains the implementation of the CISAPIprovider class,
  7. the support class for accessing and modifying the configuration of the
  8. ISAPI extension used by the Upload Library.
  9. Revision History:
  10. Davide Massarenti (Dmassare) 04/28/99
  11. created
  12. ******************************************************************************/
  13. #include "stdafx.h"
  14. static const WCHAR text_FINAL_DESTINATIONS[] = L"FINAL_DESTINATIONS";
  15. static const WCHAR text_MAX_JOBS_PER_DAY [] = L"MAX_JOBS_PER_DAY" ;
  16. static const WCHAR text_MAX_BYTES_PER_DAY [] = L"MAX_BYTES_PER_DAY" ;
  17. static const WCHAR text_MAX_JOB_SIZE [] = L"MAX_JOB_SIZE" ;
  18. static const WCHAR text_AUTHENTICATED [] = L"AUTHENTICATED" ;
  19. static const WCHAR text_PROCESSING_MODE [] = L"PROCESSING_MODE" ;
  20. static const WCHAR text_LOGON_URL [] = L"LOGON_URL" ;
  21. static const WCHAR text_PROVIDER_CLASS [] = L"PROVIDER_CLASS" ;
  22. CISAPIprovider::CISAPIprovider()
  23. {
  24. __ULT_FUNC_ENTRY( "CISAPIprovider::CISAPIprovider" );
  25. // MPC::wstring m_szName;
  26. //
  27. // PathList m_lstFinalDestinations;
  28. //
  29. m_dwMaxJobsPerDay = 100; // DWORD m_dwMaxJobsPerDay;
  30. m_dwMaxBytesPerDay = 10*1024*1024; // DWORD m_dwMaxBytesPerDay;
  31. m_dwMaxJobSize = 2*1024*1024; // DWORD m_dwMaxJobSize;
  32. //
  33. m_fAuthenticated = FALSE; // BOOL m_fAuthenticated;
  34. m_fProcessingMode = 0; // DWORD m_fProcessingMode;
  35. //
  36. // MPC::wstring m_szLogonURL;
  37. // MPC::wstring m_szProviderGUID;
  38. }
  39. CISAPIprovider::CISAPIprovider( /*[in]*/ MPC::wstring szName )
  40. {
  41. __ULT_FUNC_ENTRY( "CISAPIprovider::CISAPIprovider" );
  42. m_szName = szName; // MPC::wstring m_szName;
  43. //
  44. // PathList m_lstFinalDestinations;
  45. //
  46. m_dwMaxJobsPerDay = 100; // DWORD m_dwMaxJobsPerDay;
  47. m_dwMaxBytesPerDay = 10*1024*1024; // DWORD m_dwMaxBytesPerDay;
  48. m_dwMaxJobSize = 2*1024*1024; // DWORD m_dwMaxJobSize;
  49. //
  50. m_fAuthenticated = FALSE; // BOOL m_fAuthenticated;
  51. m_fProcessingMode = 0; // DWORD m_fProcessingMode;
  52. //
  53. // MPC::wstring m_szLogonURL;
  54. // MPC::wstring m_szProviderGUID;
  55. }
  56. bool CISAPIprovider::operator==( /*[in]*/ const MPC::wstring& rhs )
  57. {
  58. __ULT_FUNC_ENTRY("CISAPIprovider::operator==");
  59. MPC::NocaseCompare cmp;
  60. bool fRes;
  61. fRes = cmp( m_szName, rhs );
  62. __ULT_FUNC_EXIT(fRes);
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. HRESULT CISAPIprovider::Load( /*[in]*/ MPC::RegKey& rkBase )
  66. {
  67. __ULT_FUNC_ENTRY( "CISAPIprovider::Load" );
  68. HRESULT hr;
  69. MPC::RegKey rkRoot;
  70. CComVariant vValue;
  71. bool fFound;
  72. m_lstFinalDestinations.clear();
  73. //
  74. // If the registry key doesn't exist, simply exit.
  75. //
  76. __MPC_EXIT_IF_METHOD_FAILS(hr, rkBase.SubKey( m_szName.c_str(), rkRoot ));
  77. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.Exists( fFound ));
  78. if(fFound == false)
  79. {
  80. __MPC_SET_ERROR_AND_EXIT(hr, S_OK);
  81. }
  82. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_MAX_JOBS_PER_DAY ));
  83. if(fFound && vValue.vt == VT_I4) m_dwMaxJobsPerDay = vValue.lVal;
  84. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_MAX_BYTES_PER_DAY ));
  85. if(fFound && vValue.vt == VT_I4) m_dwMaxBytesPerDay = vValue.lVal;
  86. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_MAX_JOB_SIZE ));
  87. if(fFound && vValue.vt == VT_I4) m_dwMaxJobSize = vValue.lVal;
  88. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_AUTHENTICATED ));
  89. if(fFound && vValue.vt == VT_I4) m_fAuthenticated = vValue.lVal;
  90. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_PROCESSING_MODE ));
  91. if(fFound && vValue.vt == VT_I4) m_fProcessingMode = vValue.lVal;
  92. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_LOGON_URL ));
  93. if(fFound && vValue.vt == VT_BSTR) m_szLogonURL = SAFEBSTR( vValue.bstrVal );
  94. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_PROVIDER_CLASS ));
  95. if(fFound && vValue.vt == VT_BSTR) m_szProviderGUID = SAFEBSTR( vValue.bstrVal );
  96. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.get_Value( vValue, fFound, text_FINAL_DESTINATIONS ));
  97. if(fFound && vValue.vt == VT_BSTR)
  98. {
  99. //
  100. // Split the registry value, a semicolon-separated list of paths, into individual paths.
  101. //
  102. MPC::wstring szFinalDestinations = SAFEBSTR( vValue.bstrVal );
  103. MPC::wstring::size_type iPos = 0;
  104. MPC::wstring::size_type iEnd;
  105. while(1)
  106. {
  107. iEnd = szFinalDestinations.find( L";", iPos );
  108. if(iEnd == MPC::string::npos) // Last component.
  109. {
  110. m_lstFinalDestinations.push_back( MPC::wstring( &szFinalDestinations[iPos] ) );
  111. break;
  112. }
  113. else
  114. {
  115. m_lstFinalDestinations.push_back( MPC::wstring( &szFinalDestinations[iPos], &szFinalDestinations[iEnd] ) );
  116. iPos = iEnd+1;
  117. }
  118. }
  119. }
  120. hr = S_OK;
  121. __ULT_FUNC_CLEANUP;
  122. __ULT_FUNC_EXIT(hr);
  123. }
  124. HRESULT CISAPIprovider::Save( /*[in]*/ MPC::RegKey& rkBase )
  125. {
  126. __ULT_FUNC_ENTRY( "CISAPIProvider::Save" );
  127. HRESULT hr;
  128. MPC::RegKey rkRoot;
  129. CComVariant vValue;
  130. __MPC_EXIT_IF_METHOD_FAILS(hr, rkBase.SubKey( m_szName.c_str(), rkRoot ));
  131. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.Create( ));
  132. vValue = (long)m_dwMaxJobsPerDay;
  133. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_MAX_JOBS_PER_DAY ));
  134. vValue = (long)m_dwMaxBytesPerDay;
  135. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_MAX_BYTES_PER_DAY ));
  136. vValue = (long)m_dwMaxJobSize;
  137. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_MAX_JOB_SIZE ));
  138. vValue = (long)m_fAuthenticated;
  139. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_AUTHENTICATED ));
  140. vValue = (long)m_fProcessingMode;
  141. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_PROCESSING_MODE ));
  142. vValue = m_szLogonURL.c_str();
  143. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_LOGON_URL ));
  144. vValue = m_szProviderGUID.c_str();
  145. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_PROVIDER_CLASS ));
  146. {
  147. MPC::wstring szFinalDestinations;
  148. PathIter it = m_lstFinalDestinations.begin();
  149. while(it != m_lstFinalDestinations.end())
  150. {
  151. szFinalDestinations.append( *it++ );
  152. if(it != m_lstFinalDestinations.end()) szFinalDestinations.append( L";" );
  153. }
  154. if(szFinalDestinations.length() != 0)
  155. {
  156. vValue = szFinalDestinations.c_str();
  157. __MPC_EXIT_IF_METHOD_FAILS(hr, rkRoot.put_Value( vValue, text_FINAL_DESTINATIONS ));
  158. }
  159. }
  160. hr = S_OK;
  161. __ULT_FUNC_CLEANUP;
  162. __ULT_FUNC_EXIT(hr);
  163. }
  164. /////////////////////////////////////////////////////////////////////////////
  165. HRESULT CISAPIprovider::GetLocations( /*[out]*/ PathIter& itBegin ,
  166. /*[out]*/ PathIter& itEnd )
  167. {
  168. __ULT_FUNC_ENTRY( "CISAPIprovider::GetLocations" );
  169. HRESULT hr;
  170. itBegin = m_lstFinalDestinations.begin();
  171. itEnd = m_lstFinalDestinations.end ();
  172. hr = S_OK;
  173. __ULT_FUNC_EXIT(hr);
  174. }
  175. HRESULT CISAPIprovider::NewLocation( /*[out]*/ PathIter& itNew ,
  176. /*[in] */ const MPC::wstring& szPath )
  177. {
  178. __ULT_FUNC_ENTRY( "CISAPIprovider::NewLocation" );
  179. HRESULT hr;
  180. bool fFound;
  181. __MPC_EXIT_IF_METHOD_FAILS(hr, GetLocation( itNew, fFound, szPath ));
  182. if(fFound == false)
  183. {
  184. itNew = m_lstFinalDestinations.insert( m_lstFinalDestinations.end(), szPath );
  185. }
  186. hr = S_OK;
  187. __ULT_FUNC_CLEANUP;
  188. __ULT_FUNC_EXIT(hr);
  189. }
  190. HRESULT CISAPIprovider::GetLocation( /*[out]*/ PathIter& itOld ,
  191. /*[out]*/ bool& fFound ,
  192. /*[in] */ const MPC::wstring& szPath )
  193. {
  194. __ULT_FUNC_ENTRY( "CISAPIprovider::GetLocation" );
  195. HRESULT hr;
  196. itOld = std::find( m_lstFinalDestinations.begin(), m_lstFinalDestinations.end(), szPath );
  197. if(itOld == m_lstFinalDestinations.end())
  198. {
  199. fFound = false;
  200. }
  201. else
  202. {
  203. fFound = true;
  204. }
  205. hr = S_OK;
  206. __ULT_FUNC_EXIT(hr);
  207. }
  208. HRESULT CISAPIprovider::DelLocation( /*[in]*/ PathIter& itOld )
  209. {
  210. __ULT_FUNC_ENTRY( "CISAPIprovider::DelLocation" );
  211. HRESULT hr;
  212. m_lstFinalDestinations.erase( itOld );
  213. hr = S_OK;
  214. __ULT_FUNC_EXIT(hr);
  215. }
  216. /////////////////////////////////////////////////////////////////////////////
  217. HRESULT CISAPIprovider::get_Name( /*[out]*/ MPC::wstring& szName )
  218. {
  219. szName = m_szName;
  220. return S_OK;
  221. }
  222. HRESULT CISAPIprovider::get_MaxJobsPerDay( /*[out]*/ DWORD& dwMaxJobsPerDay )
  223. {
  224. dwMaxJobsPerDay = m_dwMaxJobsPerDay;
  225. return S_OK;
  226. }
  227. HRESULT CISAPIprovider::get_MaxBytesPerDay( /*[out]*/ DWORD& dwMaxBytesPerDay )
  228. {
  229. dwMaxBytesPerDay = m_dwMaxBytesPerDay;
  230. return S_OK;
  231. }
  232. HRESULT CISAPIprovider::get_MaxJobSize( /*[out]*/ DWORD& dwMaxJobSize )
  233. {
  234. dwMaxJobSize = m_dwMaxJobSize;
  235. return S_OK;
  236. }
  237. HRESULT CISAPIprovider::get_Authenticated( /*[out]*/ BOOL& fAuthenticated )
  238. {
  239. fAuthenticated = m_fAuthenticated;
  240. return S_OK;
  241. }
  242. HRESULT CISAPIprovider::get_ProcessingMode( /*[out]*/ DWORD& fProcessingMode )
  243. {
  244. fProcessingMode = m_fProcessingMode;
  245. return S_OK;
  246. }
  247. HRESULT CISAPIprovider::get_LogonURL( /*[out]*/ MPC::wstring& szLogonURL )
  248. {
  249. szLogonURL = m_szLogonURL;
  250. return S_OK;
  251. }
  252. HRESULT CISAPIprovider::get_ProviderGUID( /*[out]*/ MPC::wstring& szProviderGUID )
  253. {
  254. szProviderGUID = m_szProviderGUID;
  255. return S_OK;
  256. }
  257. ////////////////////////////////////////
  258. HRESULT CISAPIprovider::put_MaxJobsPerDay( /*[in]*/ DWORD dwMaxJobsPerDay )
  259. {
  260. m_dwMaxJobsPerDay = dwMaxJobsPerDay;
  261. return S_OK;
  262. }
  263. HRESULT CISAPIprovider::put_MaxBytesPerDay( /*[in]*/ DWORD dwMaxBytesPerDay )
  264. {
  265. m_dwMaxBytesPerDay = dwMaxBytesPerDay;
  266. return S_OK;
  267. }
  268. HRESULT CISAPIprovider::put_MaxJobSize( /*[in]*/ DWORD dwMaxJobSize )
  269. {
  270. m_dwMaxJobSize = dwMaxJobSize;
  271. return S_OK;
  272. }
  273. HRESULT CISAPIprovider::put_Authenticated( /*[in]*/ BOOL fAuthenticated )
  274. {
  275. m_fAuthenticated = fAuthenticated;
  276. return S_OK;
  277. }
  278. HRESULT CISAPIprovider::put_ProcessingMode( /*[in]*/ DWORD fProcessingMode )
  279. {
  280. m_fProcessingMode = fProcessingMode;
  281. return S_OK;
  282. }
  283. HRESULT CISAPIprovider::put_LogonURL( /*[in]*/ const MPC::wstring& szLogonURL )
  284. {
  285. m_szLogonURL = szLogonURL;
  286. return S_OK;
  287. }
  288. HRESULT CISAPIprovider::put_ProviderGUID( /*[in]*/ const MPC::wstring& szProviderGUID )
  289. {
  290. m_szProviderGUID = szProviderGUID;
  291. return S_OK;
  292. }