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.

2592 lines
62 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2000.
  5. //
  6. // File: CatAdm.cxx
  7. //
  8. // Contents: CI Catalog Administration Interface methods
  9. //
  10. // Classes: CCatAdm
  11. //
  12. // History: 12-10-97 mohamedn created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.cxx"
  16. #pragma hdrstop
  17. #include "stdafx.h"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CCatAdm::InterfaceSupportsErrorInfo, public
  21. //
  22. // Arguments: [riid] -- interface iid
  23. //
  24. // Returns: TRUE if interface supports IErrorInfo
  25. //
  26. // History: 12-10-97 mohamedn created
  27. //
  28. //----------------------------------------------------------------------------
  29. STDMETHODIMP CCatAdm::InterfaceSupportsErrorInfo(REFIID riid)
  30. {
  31. return ( riid == IID_ICatAdm );
  32. }
  33. //+---------------------------------------------------------------------------
  34. //
  35. // Member: CCatAdm::SetErrorInfo, public
  36. //
  37. // Synopsis: Creates & sets the error object
  38. //
  39. // Arguments: [hRes] -- HRESULT error code to set
  40. // [pwszDesc] -- error description
  41. //
  42. // Returns: none
  43. //
  44. // History: 12-10-97 mohamedn created
  45. //
  46. //----------------------------------------------------------------------------
  47. void CCatAdm::SetErrorInfo( HRESULT hRes )
  48. {
  49. CiodmError err(hRes);
  50. AtlSetErrorInfo(CLSID_CatAdm, err.GetErrorMessage(), 0 , 0, IID_ICatAdm, hRes, 0 );
  51. }
  52. //+---------------------------------------------------------------------------
  53. //
  54. // Member: CCatAdm::CCatAdm, public
  55. //
  56. // Synopsis: Constructor
  57. //
  58. // History: 12-10-97 mohamedn created
  59. //
  60. //----------------------------------------------------------------------------
  61. CCatAdm::CCatAdm()
  62. :_eCurrentState(CIODM_NOT_INITIALIZED),
  63. _cMinRefCountToDestroy(1),
  64. _cEnumIndex(0),
  65. _pIMacAdm(0),
  66. _dwTickCount(0)
  67. {
  68. //
  69. // empty
  70. //
  71. }
  72. //+---------------------------------------------------------------------------
  73. //
  74. // Member: CCatAdm::Initialize, public
  75. //
  76. // Synopsis: Initializes CCatAdm object, populates scopes list
  77. //
  78. // Arguments: [xCatAdmin] -- contained catAdmin
  79. //
  80. // History: 12-10-97 mohamedn created
  81. //
  82. //----------------------------------------------------------------------------
  83. void CCatAdm::Initialize( XPtr<CCatalogAdmin> & xCatAdmin )
  84. {
  85. Win4Assert( 0 == _aIScopeAdmin.Count() );
  86. Win4Assert( !xCatAdmin.IsNull() );
  87. CTranslateSystemExceptions xlate;
  88. TRY
  89. {
  90. _xCatAdmin.Set( xCatAdmin.Acquire() );
  91. XPtr<CScopeEnum> xScopeEnum(_xCatAdmin->QueryScopeEnum());
  92. for ( ; xScopeEnum->Next(); )
  93. {
  94. XPtr<CScopeAdmin> xScopeAdmin( xScopeEnum->QueryScopeAdmin() );
  95. XInterface<ScopeAdmObject> xIScopeAdm;
  96. GetScopeAutomationObject( xScopeAdmin, xIScopeAdm );
  97. _aIScopeAdmin.Add ( xIScopeAdm.GetPointer() , _aIScopeAdmin.Count() );
  98. xIScopeAdm.Acquire();
  99. }
  100. _eCurrentState = CIODM_INITIALIZED;
  101. }
  102. CATCH( CException,e )
  103. {
  104. _eCurrentState = CIODM_NOT_INITIALIZED;
  105. _cEnumIndex = 0;
  106. _xCatAdmin.Free();
  107. _aIScopeAdmin.Free();
  108. RETHROW();
  109. }
  110. END_CATCH
  111. }
  112. //+---------------------------------------------------------------------------
  113. //
  114. // Member: CCatAdm::InternalAddRef, public
  115. //
  116. // Synopsis: overrides CComObjectRootEx<Base>::InternalAddRef, to AddRef parent too
  117. //
  118. // Arguments: none
  119. //
  120. // History: 12-10-97 mohamedn created
  121. //
  122. //----------------------------------------------------------------------------
  123. ULONG CCatAdm::InternalAddRef()
  124. {
  125. CLock lock(_mtx);
  126. //
  127. // AddRef self
  128. //
  129. unsigned cRef = CComObjectRootEx<CComMultiThreadModel>::InternalAddRef();
  130. odmDebugOut(( DEB_TRACE,"CCatAdm(%ws) AddRef returned: %d\n",
  131. _xCatAdmin.IsNull() ? L"" : _xCatAdmin->GetName(), cRef ));
  132. //
  133. // AddRef parent if it exists (it won't if catadmin was created in bogus context)
  134. //
  135. if ( 0 != _pIMacAdm )
  136. _pIMacAdm->AddRef();
  137. odmDebugOut(( DEB_TRACE,"=========================== CCatAdm(%ws) object count: %d\n",
  138. _xCatAdmin.IsNull() ? L"" : _xCatAdmin->GetName(), _cMinRefCountToDestroy ));
  139. return cRef;
  140. }
  141. //+---------------------------------------------------------------------------
  142. //
  143. // Member: CCatAdm::InternalRelease, public
  144. //
  145. // Synopsis: overrides CComObjectRootEx<Base>::InternalRelease, to release parent too.
  146. //
  147. // Arguments: none
  148. //
  149. // History: 12-10-97 mohamedn created
  150. //
  151. //----------------------------------------------------------------------------
  152. ULONG CCatAdm::InternalRelease()
  153. {
  154. CLock lock(_mtx);
  155. //
  156. // Delete contained objects if we're being destoryed.
  157. // m_dwRef is an internal ATL public refcount member.
  158. //
  159. if ( _eCurrentState != CIODM_DESTROY && m_dwRef == _cMinRefCountToDestroy )
  160. {
  161. _eCurrentState = CIODM_DESTROY;
  162. _aIScopeAdmin.Free();
  163. //
  164. // Assert we're the only object left to be destroyed.
  165. //
  166. Win4Assert( 1 == m_dwRef );
  167. Win4Assert( _cMinRefCountToDestroy == 1 );
  168. if ( 0 != _pIMacAdm )
  169. _pIMacAdm->DecObjectCount();
  170. }
  171. else
  172. {
  173. Win4Assert( 1 < m_dwRef );
  174. Win4Assert( 1 <= _cMinRefCountToDestroy );
  175. }
  176. //
  177. // Release parent
  178. //
  179. unsigned cRef = CComObjectRootEx<CComMultiThreadModel>::InternalRelease();
  180. odmDebugOut(( DEB_TRACE,"CCatAdm(%ws) Release returned: %d\n",
  181. _xCatAdmin.IsNull() ? L"" : _xCatAdmin->GetName(), cRef ));
  182. if ( 0 != _pIMacAdm )
  183. _pIMacAdm->Release();
  184. return cRef;
  185. }
  186. //+---------------------------------------------------------------------------
  187. //
  188. // Member: CCatAdm::GetScopeAutomationObject, public
  189. //
  190. // Synopsis: Wraps a CScopeAdmin pointer in an IDispatch interface.
  191. //
  192. // Arguments: [xScopeAdmin] -- Scope admin object
  193. // [xIScopeAdm] -- xInterface to contain created ScopeAdmObject
  194. //
  195. // Returns: none, throws upon failure.
  196. //
  197. // History: 12-10-97 mohamedn created
  198. //
  199. //----------------------------------------------------------------------------
  200. void CCatAdm::GetScopeAutomationObject( XPtr<CScopeAdmin> & xScopeAdmin,
  201. XInterface<ScopeAdmObject> & xIScopeAdm )
  202. {
  203. Win4Assert( !xScopeAdmin.IsNull() );
  204. SCODE sc = ScopeAdmObject::CreateInstance( xIScopeAdm.GetPPointer() );
  205. if ( FAILED(sc) )
  206. {
  207. odmDebugOut(( DEB_ERROR, "CoCreateInstance(CLSID_ScopeAdm) Failed: %x\n",sc ));
  208. THROW(CException(sc) );
  209. }
  210. else
  211. {
  212. Win4Assert( !xIScopeAdm.IsNull() );
  213. xIScopeAdm->SetParent( (CComObject<CCatAdm> *)this );
  214. xIScopeAdm->AddRef();
  215. IncObjectCount(); // inc. internal object count
  216. }
  217. //
  218. // Initialize the new object
  219. //
  220. xIScopeAdm->Initialize( xScopeAdmin );
  221. }
  222. //+---------------------------------------------------------------------------
  223. //
  224. // Member: CCatAdm::GetIDisp, public
  225. //
  226. // Synopsis: QI for IDispatch on CScopeAdm object given by the passed in index.
  227. //
  228. // Arguments: [cPosition] -- index of CScopeAdm object
  229. //
  230. // Returns: [IDispatch *] -- pointer to IDispatch on CScopeAdm, throws upon failure.
  231. //
  232. // History: 12-10-97 mohamedn created
  233. //
  234. //----------------------------------------------------------------------------
  235. IDispatch * CCatAdm::GetIDisp( unsigned cPosition )
  236. {
  237. IDispatch * pTmpIDisp = 0;
  238. SCODE sc = _aIScopeAdmin[cPosition]->QueryInterface(IID_IDispatch, (void **) &pTmpIDisp);
  239. if ( FAILED(sc) )
  240. {
  241. odmDebugOut(( DEB_ERROR, "QueryInterface() Failed: %x\n", sc ));
  242. THROW(CException(sc));
  243. }
  244. Win4Assert( pTmpIDisp );
  245. return pTmpIDisp;
  246. }
  247. //+---------------------------------------------------------------------------
  248. //
  249. // Member: CCatAdm::ForceMasterMerge, public
  250. //
  251. // Synopsis: Starts a master merge
  252. //
  253. // History: 12-10-97 mohamedn created
  254. //
  255. //----------------------------------------------------------------------------
  256. STDMETHODIMP CCatAdm::ForceMasterMerge(void)
  257. {
  258. SCODE sc = S_OK;
  259. CLock lock(_mtx);
  260. TRANSLATE_EXCEPTIONS;
  261. TRY
  262. {
  263. SafeForScripting();
  264. sc = ::ForceMasterMerge ( L"\\",
  265. _xCatAdmin->GetName(),
  266. _xCatAdmin->GetMachName() );
  267. }
  268. CATCH ( CException,e )
  269. {
  270. sc = e.GetErrorCode();
  271. }
  272. END_CATCH
  273. UNTRANSLATE_EXCEPTIONS;
  274. if ( FAILED(sc) )
  275. {
  276. odmDebugOut(( DEB_ERROR, "ForceMasterMerge Failed: %x\n",sc ));
  277. SetErrorInfo(sc);
  278. }
  279. return sc;
  280. }
  281. //+---------------------------------------------------------------------------
  282. //
  283. // Member: CCatAdm::AddScope, public
  284. //
  285. // Synopsis: Adds a scope to current catalog, logon & password should only
  286. // be passed in if path is UNC.
  287. //
  288. // Arguments: [bstrScopeName] - in param, scope to Add
  289. // [fExclude] - in param, Exclude flag to set
  290. // [vtLogon] - in param, logon name
  291. // [vtPassword] - in param,
  292. // [pIDisp] - out param, IDispatch for new scope.
  293. //
  294. // Returns: S_OK upon success, other values upon failure.
  295. //
  296. // History: 12-10-97 mohamedn created
  297. //
  298. //----------------------------------------------------------------------------
  299. STDMETHODIMP CCatAdm::AddScope(BSTR bstrScopeName,
  300. VARIANT_BOOL fExclude,
  301. VARIANT vtLogon,
  302. VARIANT vtPassword,
  303. IDispatch * * pIDisp)
  304. {
  305. SCODE sc = S_OK;
  306. CLock lock(_mtx);
  307. TRANSLATE_EXCEPTIONS;
  308. TRY
  309. {
  310. SafeForScripting();
  311. ValidateInputParam( bstrScopeName );
  312. if ( !IsCurrentObjectValid() )
  313. {
  314. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  315. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  316. }
  317. else
  318. {
  319. sc = IsScopeValid( bstrScopeName, SysStringLen(bstrScopeName), _xCatAdmin->IsLocal() );
  320. if ( SUCCEEDED(sc) )
  321. {
  322. WCHAR const * pwszLogon = GetWCHARFromVariant(vtLogon);
  323. WCHAR const * pwszPassword = GetWCHARFromVariant(vtPassword);
  324. if ( (( pwszLogon && *pwszLogon && pwszPassword ) && ( bstrScopeName[0] == L'\\' || bstrScopeName[1] == L'\\')) ||
  325. (( !pwszLogon && !pwszPassword ) && ( bstrScopeName[1] == L':' )) )
  326. {
  327. if ( ScopeExists( bstrScopeName ) )
  328. {
  329. sc = HRESULT_FROM_WIN32( ERROR_ALREADY_EXISTS );
  330. }
  331. else
  332. {
  333. _xCatAdmin->AddScope(bstrScopeName, NULL, fExclude, pwszLogon, pwszPassword);
  334. XPtr<CScopeAdmin> xScopeAdmin( _xCatAdmin->QueryScopeAdmin(bstrScopeName) );
  335. unsigned cPosition = _aIScopeAdmin.Count();
  336. XInterface<ScopeAdmObject> xIScopeAdm;
  337. GetScopeAutomationObject( xScopeAdmin, xIScopeAdm );
  338. _aIScopeAdmin.Add ( xIScopeAdm.GetPointer() , cPosition );
  339. xIScopeAdm.Acquire();
  340. *pIDisp = GetIDisp(cPosition);
  341. }
  342. }
  343. else
  344. {
  345. odmDebugOut(( DEB_ERROR,"Invalid Scope params: UNC scope name require Logon & passwd, local drive doesn't\n"));
  346. sc = E_INVALIDARG;
  347. }
  348. }
  349. }
  350. }
  351. CATCH ( CException,e )
  352. {
  353. sc = e.GetErrorCode();
  354. }
  355. END_CATCH
  356. UNTRANSLATE_EXCEPTIONS;
  357. if ( FAILED(sc) )
  358. {
  359. odmDebugOut(( DEB_ERROR, "AddScope Failed: %x\n",sc ));
  360. SetErrorInfo(sc);
  361. }
  362. return sc;
  363. }
  364. //+---------------------------------------------------------------------------
  365. //
  366. // member: CCatAdm::ScopeExists, public
  367. //
  368. // Synopsis: determines if a scope exists on this catalog.
  369. //
  370. // Arguments: [pScopePath] -- scope path
  371. //
  372. // Returns: TRUE if scope already exists, false otherwise.
  373. //
  374. // History: 12-10-97 mohamedn created
  375. //
  376. //----------------------------------------------------------------------------
  377. BOOL CCatAdm::ScopeExists(WCHAR const * pScopePath)
  378. {
  379. Win4Assert( pScopePath );
  380. unsigned cPosition = _aIScopeAdmin.Count();
  381. for ( DWORD i = 0; i < cPosition; i++ )
  382. {
  383. Win4Assert( _aIScopeAdmin[i] );
  384. CScopeAdmin * pScopeAdmin = _aIScopeAdmin[i]->GetScopeAdmin();
  385. Win4Assert( pScopeAdmin );
  386. if ( !_wcsicmp( pScopePath, pScopeAdmin->GetPath() ) )
  387. {
  388. return TRUE;
  389. }
  390. }
  391. return FALSE;
  392. }
  393. //+---------------------------------------------------------------------------
  394. //
  395. // Function: GetWCHARFromVariant
  396. //
  397. // Synopsis: returns a pointer to WCHAR within a variant
  398. //
  399. // Arguments: [Var] - variant containing a bstr
  400. //
  401. // Returns: valid WCHAR * to the bstr in the variant
  402. //
  403. // History: 12-10-97 mohamedn created
  404. //
  405. //----------------------------------------------------------------------------
  406. WCHAR const * GetWCHARFromVariant( VARIANT & Var )
  407. {
  408. switch ( Var.vt )
  409. {
  410. case VT_BSTR:
  411. if ( 0 == Var.bstrVal )
  412. {
  413. THROW(CException(E_INVALIDARG));
  414. }
  415. return Var.bstrVal;
  416. break;
  417. case VT_BSTR|VT_BYREF:
  418. if ( 0 == Var.pbstrVal || 0 == *Var.pbstrVal )
  419. {
  420. THROW(CException(E_INVALIDARG));
  421. }
  422. return *Var.pbstrVal;
  423. break;
  424. case VT_BYREF|VT_VARIANT:
  425. if ( 0 == Var.pvarVal )
  426. {
  427. THROW( CException(E_INVALIDARG) );
  428. }
  429. return GetWCHARFromVariant(*Var.pvarVal);
  430. break;
  431. case VT_ERROR: // set if optional param is not set.
  432. case VT_EMPTY:
  433. //
  434. // do nothing
  435. //
  436. break;
  437. default:
  438. odmDebugOut(( DEB_ERROR, "Unexpected Variant type: %x\n", Var.vt ));
  439. THROW( CException(E_INVALIDARG) );
  440. }
  441. return 0;
  442. }
  443. //+---------------------------------------------------------------------------
  444. //
  445. // Member: CCatAdm::RemoveScope, public
  446. //
  447. // Synopsis: deletes a scope
  448. //
  449. // Arguments: [bstrScopePath] - in param, scope to delete
  450. //
  451. // Returns: S_OK upon success, other values upon failure.
  452. //
  453. // History: 12-10-97 mohamedn created
  454. //
  455. //----------------------------------------------------------------------------
  456. STDMETHODIMP CCatAdm::RemoveScope(BSTR bstrScopePath)
  457. {
  458. SCODE sc = S_OK;
  459. CLock lock(_mtx);
  460. TRANSLATE_EXCEPTIONS;
  461. TRY
  462. {
  463. SafeForScripting();
  464. ValidateInputParam( bstrScopePath );
  465. if ( !IsCurrentObjectValid() )
  466. {
  467. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  468. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  469. }
  470. else
  471. {
  472. unsigned cPosition = _aIScopeAdmin.Count();
  473. for ( DWORD i = 0; i < cPosition; i++ )
  474. {
  475. Win4Assert( _aIScopeAdmin[i] );
  476. CScopeAdmin * pScopeAdmin = _aIScopeAdmin[i]->GetScopeAdmin();
  477. Win4Assert( pScopeAdmin );
  478. if ( !_wcsicmp( bstrScopePath, pScopeAdmin->GetPath() ) )
  479. {
  480. //
  481. // Remove scope from local list, move last element to empty spot,
  482. // Release corresponding IDispatch
  483. //
  484. ScopeAdmObject * pIScopeAdm = _aIScopeAdmin.AcquireAndShrink(i);
  485. Win4Assert( pIScopeAdm );
  486. pIScopeAdm->SetInvalid();
  487. pIScopeAdm->Release();
  488. //
  489. // Remove from CI
  490. //
  491. _xCatAdmin->RemoveScope(bstrScopePath);
  492. break;
  493. }
  494. }
  495. if ( i == cPosition )
  496. {
  497. odmDebugOut(( DEB_ERROR, "RemoveScope Failed, Scope(%ws) not found\n", bstrScopePath ));
  498. sc = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
  499. }
  500. }
  501. }
  502. CATCH ( CException,e )
  503. {
  504. sc = e.GetErrorCode();
  505. }
  506. END_CATCH
  507. UNTRANSLATE_EXCEPTIONS;
  508. if ( FAILED(sc) )
  509. {
  510. odmDebugOut(( DEB_ERROR, "RemoveScope Failed: %x\n",sc ));
  511. SetErrorInfo( sc );
  512. }
  513. return sc;
  514. }
  515. //+---------------------------------------------------------------------------
  516. //
  517. // Member: CCatAdm::GetScopeByPath, public
  518. //
  519. // Synopsis: Searches for scopes on this catalog by Path
  520. //
  521. // Arguments: [bstrPath] -- Path to search for.
  522. // [pIDisp] -- out param, IDispatch for CScopeAdmin if Path matches
  523. //
  524. // Returns: S_OK upon success, other values upon failure.
  525. //
  526. // History: 12-10-97 mohamedn created
  527. //
  528. //----------------------------------------------------------------------------
  529. STDMETHODIMP CCatAdm::GetScopeByPath(BSTR bstrPath, IDispatch * * pIDisp)
  530. {
  531. SCODE sc = S_OK;
  532. CLock lock(_mtx);
  533. TRANSLATE_EXCEPTIONS;
  534. TRY
  535. {
  536. SafeForScripting();
  537. ValidateInputParam( bstrPath );
  538. if ( !IsCurrentObjectValid() )
  539. {
  540. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  541. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  542. }
  543. else
  544. {
  545. unsigned cMaxScopes = _aIScopeAdmin.Count();
  546. for ( DWORD i = 0; i < cMaxScopes; i++ )
  547. {
  548. Win4Assert( _aIScopeAdmin[i] );
  549. CScopeAdmin *pScopeAdmin = _aIScopeAdmin[i]->GetScopeAdmin();
  550. Win4Assert( pScopeAdmin );
  551. if ( !_wcsicmp( pScopeAdmin->GetPath(), bstrPath ) )
  552. {
  553. *pIDisp = GetIDisp(i);
  554. break;
  555. }
  556. }
  557. //
  558. // Scope not found
  559. //
  560. if ( i == cMaxScopes )
  561. {
  562. odmDebugOut(( DEB_ERROR, "GetScopeByPath(%ws) Failed: Scope Not found\n",bstrPath ));
  563. sc = HRESULT_FROM_WIN32( ERROR_NOT_FOUND );
  564. }
  565. }
  566. }
  567. CATCH ( CException,e )
  568. {
  569. sc = e.GetErrorCode();
  570. }
  571. END_CATCH
  572. UNTRANSLATE_EXCEPTIONS;
  573. if ( FAILED(sc) )
  574. {
  575. odmDebugOut(( DEB_ERROR, "GetScopeByPath Failed: %x\n",sc ));
  576. SetErrorInfo( sc );
  577. }
  578. return sc;
  579. }
  580. //+---------------------------------------------------------------------------
  581. //
  582. // Member: CCatAdm::FindFirstScope, public
  583. //
  584. // Synopsis: Scope enumerator. Resets scan to start of list.
  585. //
  586. // Arguments: [pfFound] -- out param, True --> Found at least one scope
  587. //
  588. // Returns: SO_OK upon success, other values upon faillure
  589. //
  590. // History: 12-10-97 mohamedn created
  591. //
  592. //----------------------------------------------------------------------------
  593. STDMETHODIMP CCatAdm::FindFirstScope(VARIANT_BOOL * pfFound)
  594. {
  595. SCODE sc = S_OK;
  596. CLock lock(_mtx);
  597. TRANSLATE_EXCEPTIONS;
  598. TRY
  599. {
  600. SafeForScripting();
  601. if ( !IsCurrentObjectValid() )
  602. {
  603. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  604. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  605. }
  606. else
  607. {
  608. _cEnumIndex = 0;
  609. if ( _aIScopeAdmin.Count() > 0 )
  610. {
  611. Win4Assert( _aIScopeAdmin[0] );
  612. *pfFound = VARIANT_TRUE;
  613. }
  614. else
  615. {
  616. *pfFound = VARIANT_FALSE;
  617. }
  618. }
  619. }
  620. CATCH ( CException,e )
  621. {
  622. sc = e.GetErrorCode();
  623. }
  624. END_CATCH
  625. UNTRANSLATE_EXCEPTIONS;
  626. if ( FAILED(sc) )
  627. {
  628. odmDebugOut(( DEB_ERROR, "FindFirstScope Failed: %x\n",sc ));
  629. SetErrorInfo( sc );
  630. }
  631. return sc;
  632. }
  633. //+---------------------------------------------------------------------------
  634. //
  635. // Member: CCatAdm::FindNextScope, public
  636. //
  637. // Synopsis: Scope enumerator. Scans for next scope in the list
  638. //
  639. // Arguments: [pfFound] -- out param, True --> Found next scope
  640. //
  641. // Returns: SO_OK upon success, other values upon faillure
  642. //
  643. // History: 12-10-97 mohamedn created
  644. //
  645. //----------------------------------------------------------------------------
  646. STDMETHODIMP CCatAdm::FindNextScope(VARIANT_BOOL * pfFound)
  647. {
  648. SCODE sc = S_OK;
  649. CLock lock(_mtx);
  650. TRANSLATE_EXCEPTIONS;
  651. TRY
  652. {
  653. SafeForScripting();
  654. if ( !IsCurrentObjectValid() )
  655. {
  656. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  657. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  658. }
  659. else
  660. {
  661. _cEnumIndex++;
  662. if ( _cEnumIndex < _aIScopeAdmin.Count() )
  663. {
  664. Win4Assert( _aIScopeAdmin[0] );
  665. *pfFound = VARIANT_TRUE;
  666. }
  667. else
  668. {
  669. *pfFound = VARIANT_FALSE;
  670. }
  671. }
  672. }
  673. CATCH ( CException,e )
  674. {
  675. sc = e.GetErrorCode();
  676. }
  677. END_CATCH
  678. UNTRANSLATE_EXCEPTIONS;
  679. if ( FAILED(sc) )
  680. {
  681. odmDebugOut(( DEB_ERROR, "FindNextScope Failed: %x\n",sc ));
  682. SetErrorInfo( sc );
  683. }
  684. return sc;
  685. }
  686. //+---------------------------------------------------------------------------
  687. //
  688. // Member: CCatAdm::GetScope, public
  689. //
  690. // Synopsis: Scope enumerator. Returns IDispatch to current scope
  691. //
  692. // Arguments: [pIDisp] -- out param, IDispatch to current scope
  693. //
  694. // Returns: SO_OK upon success, other values upon faillure
  695. //
  696. // History: 12-10-97 mohamedn created
  697. //
  698. //----------------------------------------------------------------------------
  699. STDMETHODIMP CCatAdm::GetScope(IDispatch * * pIDisp)
  700. {
  701. SCODE sc = S_OK;
  702. CLock lock(_mtx);
  703. TRANSLATE_EXCEPTIONS;
  704. TRY
  705. {
  706. SafeForScripting();
  707. if ( !IsCurrentObjectValid() )
  708. {
  709. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  710. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  711. }
  712. else
  713. {
  714. if ( _cEnumIndex >= _aIScopeAdmin.Count() )
  715. {
  716. odmDebugOut(( DEB_ERROR, "No More Scopes, Index: %d\n", _cEnumIndex ));
  717. sc = HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS);
  718. }
  719. else
  720. {
  721. Win4Assert( _aIScopeAdmin[_cEnumIndex] );
  722. *pIDisp = GetIDisp(_cEnumIndex);
  723. }
  724. }
  725. }
  726. CATCH ( CException,e )
  727. {
  728. sc = e.GetErrorCode();
  729. }
  730. END_CATCH
  731. UNTRANSLATE_EXCEPTIONS;
  732. if ( FAILED(sc) )
  733. {
  734. odmDebugOut(( DEB_ERROR, "GetScope Failed: %x\n",sc ));
  735. SetErrorInfo( sc );
  736. }
  737. return sc;
  738. }
  739. //+---------------------------------------------------------------------------
  740. //
  741. // Member: CCatAdm::get_CatalogName, public
  742. //
  743. // Synopsis: Gets the CatalogName Property
  744. //
  745. // Arguments: [pVal] -- out param, buffer containing catalog name
  746. //
  747. // Returns: S_OK upon success, other values upon failure.
  748. //
  749. // History: 12-10-97 mohamedn created
  750. //
  751. //----------------------------------------------------------------------------
  752. STDMETHODIMP CCatAdm::get_CatalogName(BSTR * pVal)
  753. {
  754. SCODE sc = S_OK;
  755. CLock lock(_mtx);
  756. TRANSLATE_EXCEPTIONS;
  757. TRY
  758. {
  759. SafeForScripting();
  760. if ( !IsCurrentObjectValid() )
  761. {
  762. odmDebugOut(( DEB_ERROR, "Invalid catalog: %ws\n", _xCatAdmin->GetName() ));
  763. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  764. }
  765. else
  766. {
  767. WCHAR const * pwszName = _xCatAdmin->GetName();
  768. *pVal = SysAllocString(pwszName);
  769. if ( !*pVal )
  770. {
  771. odmDebugOut(( DEB_ERROR, "get_CatalogName Failed: Out of memory\n" ));
  772. sc = E_OUTOFMEMORY;
  773. }
  774. }
  775. }
  776. CATCH( CException, e )
  777. {
  778. sc = e.GetErrorCode();
  779. }
  780. END_CATCH
  781. UNTRANSLATE_EXCEPTIONS;
  782. if ( FAILED(sc) )
  783. {
  784. odmDebugOut(( DEB_ERROR, "get_CatalogName Failed: %x\n",sc ));
  785. SetErrorInfo( sc );
  786. }
  787. return sc;
  788. }
  789. //+---------------------------------------------------------------------------
  790. //
  791. // Member: CCatAdm::get_CatalogLocation, public
  792. //
  793. // Synopsis: Gets the CatalogLocation property
  794. //
  795. // Arguments: [pVal] -- out param, buffer containing catalog location
  796. //
  797. // Returns: S_OK upon success, other values upon failure.
  798. //
  799. // History: 12-10-97 mohamedn created
  800. //
  801. //----------------------------------------------------------------------------
  802. STDMETHODIMP CCatAdm::get_CatalogLocation(BSTR * pVal)
  803. {
  804. SCODE sc = S_OK;
  805. CLock lock(_mtx);
  806. TRANSLATE_EXCEPTIONS;
  807. TRY
  808. {
  809. SafeForScripting();
  810. if ( !IsCurrentObjectValid() )
  811. {
  812. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  813. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  814. }
  815. else
  816. {
  817. WCHAR const * pwszLocation = _xCatAdmin->GetLocation();
  818. *pVal = SysAllocString(pwszLocation);
  819. if ( !*pVal )
  820. {
  821. odmDebugOut(( DEB_ERROR, "get_CatalogLocation Failed: Out of memory\n"));
  822. sc = E_OUTOFMEMORY;
  823. }
  824. }
  825. }
  826. CATCH( CException, e )
  827. {
  828. sc = e.GetErrorCode();
  829. }
  830. END_CATCH
  831. UNTRANSLATE_EXCEPTIONS;
  832. if ( FAILED(sc) )
  833. {
  834. odmDebugOut(( DEB_ERROR, "get_CatalogLocation Failed: %x\n",sc ));
  835. SetErrorInfo( sc );
  836. }
  837. return sc;
  838. }
  839. //+---------------------------------------------------------------------------
  840. //
  841. // Member: CCatAdm::GetScopeByAlias, public
  842. //
  843. // Synopsis: Searches for scopes on this catalog by Alias
  844. //
  845. // Arguments: [bstrAlias] -- Alias to search for.
  846. // [pIDisp] -- out param, IDispatch for CScopeAdmin if Alias matches
  847. //
  848. // Returns: S_OK upon success, other values upon failure.
  849. //
  850. // History: 12-10-97 mohamedn created
  851. //
  852. //----------------------------------------------------------------------------
  853. STDMETHODIMP CCatAdm::GetScopeByAlias(BSTR bstrAlias, IDispatch * * pIDisp)
  854. {
  855. SCODE sc = S_OK;
  856. CLock lock(_mtx);
  857. TRANSLATE_EXCEPTIONS;
  858. TRY
  859. {
  860. SafeForScripting();
  861. ValidateInputParam( bstrAlias );
  862. if ( !IsCurrentObjectValid() )
  863. {
  864. odmDebugOut(( DEB_ERROR, "Invalid catalog: %ws\n", _xCatAdmin->GetName() ));
  865. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  866. }
  867. else
  868. {
  869. unsigned cMaxScopes = _aIScopeAdmin.Count();
  870. for ( DWORD i = 0; i < cMaxScopes; i++ )
  871. {
  872. Win4Assert( _aIScopeAdmin[i] );
  873. CScopeAdmin * pScopeAdmin = _aIScopeAdmin[i]->GetScopeAdmin();
  874. Win4Assert( pScopeAdmin );
  875. if ( !_wcsicmp( pScopeAdmin->GetAlias(), bstrAlias ) )
  876. {
  877. *pIDisp = GetIDisp(i);
  878. break;
  879. }
  880. }
  881. //
  882. // Scope not found
  883. //
  884. if ( i == cMaxScopes )
  885. {
  886. odmDebugOut(( DEB_ERROR, "GetScopeByAlias(%ws) Failed: Alias not found\n", bstrAlias ));
  887. sc = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
  888. }
  889. }
  890. }
  891. CATCH( CException, e )
  892. {
  893. sc = e.GetErrorCode();
  894. }
  895. END_CATCH
  896. UNTRANSLATE_EXCEPTIONS;
  897. if ( FAILED(sc) )
  898. {
  899. odmDebugOut(( DEB_ERROR, "GetScopeByAlias Failed: %x\n",sc ));
  900. SetErrorInfo( sc );
  901. }
  902. return sc;
  903. }
  904. //+---------------------------------------------------------------------------
  905. //
  906. // Member: CCatAdm::get_WordListCount, public property
  907. //
  908. // Synopsis: returns catalog's WordListCount property
  909. //
  910. // Arguments: [pVal] -- out param
  911. //
  912. // Returns: S_OK upon success, other values upon failure.
  913. //
  914. // Notes: Property value is an unsigned, though it is being
  915. // passed in as a signed LONG for compatiblity with automation
  916. // clients (VB5, VB6 don't support unsigned long).
  917. //
  918. // History: 4-6-97 mohamedn created
  919. //
  920. //----------------------------------------------------------------------------
  921. STDMETHODIMP CCatAdm::get_WordListCount(LONG *pVal)
  922. {
  923. SCODE sc = S_OK;
  924. CLock lock(_mtx);
  925. TRANSLATE_EXCEPTIONS;
  926. TRY
  927. {
  928. SafeForScripting();
  929. CCatStateInfo & state = _xCatAdmin->State();
  930. if ( !IsCurrentObjectValid() )
  931. {
  932. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  933. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  934. }
  935. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  936. {
  937. state.LokUpdate();
  938. _dwTickCount = GetTickCount();
  939. }
  940. if ( state.IsValid() )
  941. {
  942. *pVal = state.GetWordListCount();
  943. }
  944. else
  945. {
  946. sc = state.GetErrorCode();
  947. }
  948. }
  949. CATCH( CException, e )
  950. {
  951. sc = e.GetErrorCode();
  952. }
  953. END_CATCH
  954. UNTRANSLATE_EXCEPTIONS;
  955. if ( FAILED(sc) )
  956. {
  957. odmDebugOut(( DEB_ERROR, "get_WordListCount Failed: %x\n",sc ));
  958. SetErrorInfo( sc );
  959. }
  960. return sc;
  961. }
  962. //+---------------------------------------------------------------------------
  963. //
  964. // Member: CCatAdm::get_PersistentIndexCount, public property
  965. //
  966. // Synopsis: returns catalog's PersistentIndexCount property
  967. //
  968. // Arguments: [pVal] -- out param
  969. //
  970. // Returns: S_OK upon success, other values upon failure.
  971. //
  972. // Notes: Property value is an unsigned, though it is being
  973. // passed in as a signed LONG for compatiblity with automation
  974. // clients (VB5, VB6 don't support unsigned long).
  975. //
  976. // History: 4-6-97 mohamedn created
  977. //
  978. //----------------------------------------------------------------------------
  979. STDMETHODIMP CCatAdm::get_PersistentIndexCount(LONG *pVal)
  980. {
  981. SCODE sc = S_OK;
  982. CLock lock(_mtx);
  983. TRANSLATE_EXCEPTIONS;
  984. TRY
  985. {
  986. SafeForScripting();
  987. CCatStateInfo & state = _xCatAdmin->State();
  988. if ( !IsCurrentObjectValid() )
  989. {
  990. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  991. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  992. }
  993. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  994. {
  995. state.LokUpdate();
  996. _dwTickCount = GetTickCount();
  997. }
  998. if ( state.IsValid() )
  999. {
  1000. *pVal = state.GetPersistentIndexCount();
  1001. }
  1002. else
  1003. {
  1004. sc = state.GetErrorCode();
  1005. }
  1006. }
  1007. CATCH( CException, e )
  1008. {
  1009. sc = e.GetErrorCode();
  1010. }
  1011. END_CATCH
  1012. UNTRANSLATE_EXCEPTIONS;
  1013. if ( FAILED(sc) )
  1014. {
  1015. odmDebugOut(( DEB_ERROR, "get_PersistentIndexCount Failed: %x\n",sc ));
  1016. SetErrorInfo( sc );
  1017. }
  1018. return sc;
  1019. }
  1020. //+---------------------------------------------------------------------------
  1021. //
  1022. // Member: CCatAdm::get_QueryCount, public property
  1023. //
  1024. // Synopsis: returns catalog's QueryCount property
  1025. //
  1026. // Arguments: [pVal] -- out param,
  1027. //
  1028. // Returns: S_OK upon success, other values upon failure.
  1029. //
  1030. // Notes: Property value is an unsigned, though it is being
  1031. // passed in as a signed LONG for compatiblity with automation
  1032. // clients (VB5, VB6 don't support unsigned long).
  1033. //
  1034. // History: 4-6-97 mohamedn created
  1035. //
  1036. //----------------------------------------------------------------------------
  1037. STDMETHODIMP CCatAdm::get_QueryCount(LONG *pVal)
  1038. {
  1039. SCODE sc = S_OK;
  1040. CLock lock(_mtx);
  1041. TRANSLATE_EXCEPTIONS;
  1042. TRY
  1043. {
  1044. SafeForScripting();
  1045. CCatStateInfo & state = _xCatAdmin->State();
  1046. if ( !IsCurrentObjectValid() )
  1047. {
  1048. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1049. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1050. }
  1051. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1052. {
  1053. state.LokUpdate();
  1054. _dwTickCount = GetTickCount();
  1055. }
  1056. if ( state.IsValid() )
  1057. {
  1058. *pVal = state.GetQueryCount();
  1059. }
  1060. else
  1061. {
  1062. sc = state.GetErrorCode();
  1063. }
  1064. }
  1065. CATCH( CException, e )
  1066. {
  1067. sc = e.GetErrorCode();
  1068. }
  1069. END_CATCH
  1070. UNTRANSLATE_EXCEPTIONS;
  1071. if ( FAILED(sc) )
  1072. {
  1073. odmDebugOut(( DEB_ERROR, "get_QueryCount Failed: %x\n",sc ));
  1074. SetErrorInfo( sc );
  1075. }
  1076. return sc;
  1077. }
  1078. //+---------------------------------------------------------------------------
  1079. //
  1080. // Member: CCatAdm::get_DocumentsToFilter, public property
  1081. //
  1082. // Synopsis: returns catalog's DocumentsToFilter property
  1083. //
  1084. // Arguments: [pVal] -- out param,
  1085. //
  1086. // Returns: S_OK upon success, other values upon failure.
  1087. //
  1088. // Notes: Property value is an unsigned, though it is being
  1089. // passed in as a signed LONG for compatiblity with automation
  1090. // clients (VB5, VB6 don't support unsigned long).
  1091. //
  1092. // History: 4-6-97 mohamedn created
  1093. //
  1094. //----------------------------------------------------------------------------
  1095. STDMETHODIMP CCatAdm::get_DocumentsToFilter(LONG *pVal)
  1096. {
  1097. SCODE sc = S_OK;
  1098. CLock lock(_mtx);
  1099. TRANSLATE_EXCEPTIONS;
  1100. TRY
  1101. {
  1102. SafeForScripting();
  1103. CCatStateInfo & state = _xCatAdmin->State();
  1104. if ( !IsCurrentObjectValid() )
  1105. {
  1106. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1107. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1108. }
  1109. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1110. {
  1111. state.LokUpdate();
  1112. _dwTickCount = GetTickCount();
  1113. }
  1114. if ( state.IsValid() )
  1115. {
  1116. *pVal = state.GetDocumentsToFilter();
  1117. }
  1118. else
  1119. {
  1120. sc = state.GetErrorCode();
  1121. }
  1122. }
  1123. CATCH( CException, e )
  1124. {
  1125. sc = e.GetErrorCode();
  1126. }
  1127. END_CATCH
  1128. UNTRANSLATE_EXCEPTIONS;
  1129. if ( FAILED(sc) )
  1130. {
  1131. odmDebugOut(( DEB_ERROR, "get_DocumentsToFilter Failed: %x\n",sc ));
  1132. SetErrorInfo( sc );
  1133. }
  1134. return sc;
  1135. }
  1136. //+---------------------------------------------------------------------------
  1137. //
  1138. // Member: CCatAdm::get_FreshTestCount, public property
  1139. //
  1140. // Synopsis: returns catalog's FreshTestCount
  1141. //
  1142. // Arguments: [pVal] -- out param,
  1143. //
  1144. // Returns: S_OK upon success, other values upon failure.
  1145. //
  1146. // Notes: Property value is an unsigned, though it is being
  1147. // passed in as a signed LONG for compatiblity with automation
  1148. // clients (VB5, VB6 don't support unsigned long).
  1149. //
  1150. // History: 4-6-97 mohamedn created
  1151. //
  1152. //----------------------------------------------------------------------------
  1153. STDMETHODIMP CCatAdm::get_FreshTestCount(LONG *pVal)
  1154. {
  1155. SCODE sc = S_OK;
  1156. CLock lock(_mtx);
  1157. TRANSLATE_EXCEPTIONS;
  1158. TRY
  1159. {
  1160. SafeForScripting();
  1161. CCatStateInfo & state = _xCatAdmin->State();
  1162. if ( !IsCurrentObjectValid() )
  1163. {
  1164. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1165. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1166. }
  1167. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1168. {
  1169. state.LokUpdate();
  1170. _dwTickCount = GetTickCount();
  1171. }
  1172. if ( state.IsValid() )
  1173. {
  1174. *pVal = state.GetFreshTestCount();
  1175. }
  1176. else
  1177. {
  1178. sc = state.GetErrorCode();
  1179. }
  1180. }
  1181. CATCH( CException, e )
  1182. {
  1183. sc = e.GetErrorCode();
  1184. }
  1185. END_CATCH
  1186. UNTRANSLATE_EXCEPTIONS;
  1187. if ( FAILED(sc) )
  1188. {
  1189. odmDebugOut(( DEB_ERROR, "get_FreshTestCount Failed: %x\n",sc ));
  1190. SetErrorInfo( sc );
  1191. }
  1192. return sc;
  1193. }
  1194. //+---------------------------------------------------------------------------
  1195. //
  1196. // Member: CCatAdm::get_PctMergeComplete, public property
  1197. //
  1198. // Synopsis: returns catalog's PctMergeComplete property
  1199. //
  1200. // Arguments: [pVal] -- out param,
  1201. //
  1202. // Returns: S_OK upon success, other values upon failure.
  1203. //
  1204. // Notes: Property value is an unsigned, though it is being
  1205. // passed in as a signed LONG for compatiblity with automation
  1206. // clients (VB5, VB6 don't support unsigned long).
  1207. //
  1208. // History: 4-6-97 mohamedn created
  1209. //
  1210. //----------------------------------------------------------------------------
  1211. STDMETHODIMP CCatAdm::get_PctMergeComplete(LONG *pVal)
  1212. {
  1213. SCODE sc = S_OK;
  1214. CLock lock(_mtx);
  1215. TRANSLATE_EXCEPTIONS;
  1216. TRY
  1217. {
  1218. SafeForScripting();
  1219. CCatStateInfo & state = _xCatAdmin->State();
  1220. if ( !IsCurrentObjectValid() )
  1221. {
  1222. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1223. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1224. }
  1225. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1226. {
  1227. state.LokUpdate();
  1228. _dwTickCount = GetTickCount();
  1229. }
  1230. if ( state.IsValid() )
  1231. {
  1232. *pVal = state.PctMergeComplete();
  1233. }
  1234. else
  1235. {
  1236. sc = state.GetErrorCode();
  1237. }
  1238. }
  1239. CATCH( CException, e )
  1240. {
  1241. sc = e.GetErrorCode();
  1242. }
  1243. END_CATCH
  1244. UNTRANSLATE_EXCEPTIONS;
  1245. if ( FAILED(sc) )
  1246. {
  1247. odmDebugOut(( DEB_ERROR, "get_PctMergeComplete Failed: %x\n",sc ));
  1248. SetErrorInfo( sc );
  1249. }
  1250. return sc;
  1251. }
  1252. //+---------------------------------------------------------------------------
  1253. //
  1254. // Member: CCatAdm::get_FilteredDocumentCount, public property
  1255. //
  1256. // Synopsis: returns catalog's FilteredDocumentCount property
  1257. //
  1258. // Arguments: [pVal] -- out param,
  1259. //
  1260. // Returns: S_OK upon success, other values upon failure.
  1261. //
  1262. // Notes: Property value is an unsigned, though it is being
  1263. // passed in as a signed LONG for compatiblity with automation
  1264. // clients (VB5, VB6 don't support unsigned long).
  1265. //
  1266. // History: 4-6-97 mohamedn created
  1267. //
  1268. //----------------------------------------------------------------------------
  1269. STDMETHODIMP CCatAdm::get_FilteredDocumentCount(LONG *pVal)
  1270. {
  1271. SCODE sc = S_OK;
  1272. CLock lock(_mtx);
  1273. TRANSLATE_EXCEPTIONS;
  1274. TRY
  1275. {
  1276. SafeForScripting();
  1277. CCatStateInfo & state = _xCatAdmin->State();
  1278. if ( !IsCurrentObjectValid() )
  1279. {
  1280. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1281. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1282. }
  1283. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1284. {
  1285. state.LokUpdate();
  1286. _dwTickCount = GetTickCount();
  1287. }
  1288. if ( state.IsValid() )
  1289. {
  1290. *pVal = state.GetFilteredDocumentCount();
  1291. }
  1292. else
  1293. {
  1294. sc = state.GetErrorCode();
  1295. }
  1296. }
  1297. CATCH( CException, e )
  1298. {
  1299. sc = e.GetErrorCode();
  1300. }
  1301. END_CATCH
  1302. UNTRANSLATE_EXCEPTIONS;
  1303. if ( FAILED(sc) )
  1304. {
  1305. odmDebugOut(( DEB_ERROR, "get_FilteredDocumentCount Failed: %x\n",sc ));
  1306. SetErrorInfo( sc );
  1307. }
  1308. return sc;
  1309. }
  1310. //+---------------------------------------------------------------------------
  1311. //
  1312. // Member: CCatAdm::get_TotalDocumentCount, public property
  1313. //
  1314. // Synopsis: returns catalog's TotalDocumentCount property
  1315. //
  1316. // Arguments: [pVal] -- out param,
  1317. //
  1318. // Returns: S_OK upon success, other values upon failure.
  1319. //
  1320. // Notes: Property value is an unsigned, though it is being
  1321. // passed in as a signed LONG for compatiblity with automation
  1322. // clients (VB5, VB6 don't support unsigned long).
  1323. //
  1324. // History: 4-6-97 mohamedn created
  1325. //
  1326. //----------------------------------------------------------------------------
  1327. STDMETHODIMP CCatAdm::get_TotalDocumentCount(LONG *pVal)
  1328. {
  1329. SCODE sc = S_OK;
  1330. CLock lock(_mtx);
  1331. TRANSLATE_EXCEPTIONS;
  1332. TRY
  1333. {
  1334. SafeForScripting();
  1335. CCatStateInfo & state = _xCatAdmin->State();
  1336. if ( !IsCurrentObjectValid() )
  1337. {
  1338. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1339. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1340. }
  1341. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1342. {
  1343. state.LokUpdate();
  1344. _dwTickCount = GetTickCount();
  1345. }
  1346. if ( state.IsValid() )
  1347. {
  1348. *pVal = state.GetTotalDocumentCount();
  1349. }
  1350. else
  1351. {
  1352. sc = state.GetErrorCode();
  1353. }
  1354. }
  1355. CATCH( CException, e )
  1356. {
  1357. sc = e.GetErrorCode();
  1358. }
  1359. END_CATCH
  1360. UNTRANSLATE_EXCEPTIONS;
  1361. if ( FAILED(sc) )
  1362. {
  1363. odmDebugOut(( DEB_ERROR, "get_TotalDocumentCount Failed: %x\n",sc ));
  1364. SetErrorInfo( sc );
  1365. }
  1366. return sc;
  1367. }
  1368. //+---------------------------------------------------------------------------
  1369. //
  1370. // Member: CCatAdm::get_PendingScanCount, public property
  1371. //
  1372. // Synopsis: returns catalog's PendingDocumentCount property
  1373. //
  1374. // Arguments: [pVal] -- out param,
  1375. //
  1376. // Returns: S_OK upon success, other values upon failure.
  1377. //
  1378. // Notes: Property value is an unsigned, though it is being
  1379. // passed in as a signed LONG for compatiblity with automation
  1380. // clients (VB5, VB6 don't support unsigned long).
  1381. //
  1382. // History: 4-6-97 mohamedn created
  1383. //
  1384. //----------------------------------------------------------------------------
  1385. STDMETHODIMP CCatAdm::get_PendingScanCount(LONG *pVal)
  1386. {
  1387. SCODE sc = S_OK;
  1388. CLock lock(_mtx);
  1389. TRANSLATE_EXCEPTIONS;
  1390. TRY
  1391. {
  1392. SafeForScripting();
  1393. CCatStateInfo & state = _xCatAdmin->State();
  1394. if ( !IsCurrentObjectValid() )
  1395. {
  1396. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1397. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1398. }
  1399. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1400. {
  1401. state.LokUpdate();
  1402. _dwTickCount = GetTickCount();
  1403. }
  1404. if ( state.IsValid() )
  1405. {
  1406. *pVal = state.GetPendingScanCount();
  1407. }
  1408. else
  1409. {
  1410. sc = state.GetErrorCode();
  1411. }
  1412. }
  1413. CATCH( CException, e )
  1414. {
  1415. sc = e.GetErrorCode();
  1416. }
  1417. END_CATCH
  1418. UNTRANSLATE_EXCEPTIONS;
  1419. if ( FAILED(sc) )
  1420. {
  1421. odmDebugOut(( DEB_ERROR, "get_PendingScanCount Failed: %x\n",sc ));
  1422. SetErrorInfo( sc );
  1423. }
  1424. return sc;
  1425. }
  1426. //+---------------------------------------------------------------------------
  1427. //
  1428. // Member: CCatAdm::get_IndexSize, public property
  1429. //
  1430. // Synopsis: returns catalog's IndexSize property
  1431. //
  1432. // Arguments: [pVal] -- out param,
  1433. //
  1434. // Returns: S_OK upon success, other values upon failure.
  1435. //
  1436. // Notes: Property value is an unsigned, though it is being
  1437. // passed in as a signed LONG for compatiblity with automation
  1438. // clients (VB5, VB6 don't support unsigned long).
  1439. //
  1440. // History: 4-6-97 mohamedn created
  1441. //
  1442. //----------------------------------------------------------------------------
  1443. STDMETHODIMP CCatAdm::get_IndexSize(LONG *pVal)
  1444. {
  1445. SCODE sc = S_OK;
  1446. CLock lock(_mtx);
  1447. TRANSLATE_EXCEPTIONS;
  1448. TRY
  1449. {
  1450. SafeForScripting();
  1451. CCatStateInfo & state = _xCatAdmin->State();
  1452. if ( !IsCurrentObjectValid() )
  1453. {
  1454. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1455. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1456. }
  1457. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1458. {
  1459. state.LokUpdate();
  1460. _dwTickCount = GetTickCount();
  1461. }
  1462. if ( state.IsValid() )
  1463. {
  1464. *pVal = state.GetIndexSize();
  1465. }
  1466. else
  1467. {
  1468. sc = state.GetErrorCode();
  1469. }
  1470. }
  1471. CATCH( CException, e )
  1472. {
  1473. sc = e.GetErrorCode();
  1474. }
  1475. END_CATCH
  1476. UNTRANSLATE_EXCEPTIONS;
  1477. if ( FAILED(sc) )
  1478. {
  1479. odmDebugOut(( DEB_ERROR, "get_IndexSize Failed: %x\n",sc ));
  1480. SetErrorInfo( sc );
  1481. }
  1482. return sc;
  1483. }
  1484. //+---------------------------------------------------------------------------
  1485. //
  1486. // Member: CCatAdm::get_UniqueKeyCount, public property
  1487. //
  1488. // Synopsis: returns catalog's UniqueKeyCount
  1489. //
  1490. // Arguments: [pVal] -- out param,
  1491. //
  1492. // Returns: S_OK upon success, other values upon failure.
  1493. //
  1494. // Notes: Property value is an unsigned value, though it is being
  1495. // passed in as a signed LONG for compatiblity with automation
  1496. // clients (VB5, VB6 don't support unsigned long).
  1497. //
  1498. // History: 4-6-97 mohamedn created
  1499. //
  1500. //----------------------------------------------------------------------------
  1501. STDMETHODIMP CCatAdm::get_UniqueKeyCount(LONG *pVal)
  1502. {
  1503. SCODE sc = S_OK;
  1504. CLock lock(_mtx);
  1505. TRANSLATE_EXCEPTIONS;
  1506. TRY
  1507. {
  1508. SafeForScripting();
  1509. CCatStateInfo & state = _xCatAdmin->State();
  1510. if ( !IsCurrentObjectValid() )
  1511. {
  1512. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1513. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1514. }
  1515. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1516. {
  1517. state.LokUpdate();
  1518. _dwTickCount = GetTickCount();
  1519. }
  1520. if ( state.IsValid() )
  1521. {
  1522. *pVal = state.GetUniqueKeyCount();
  1523. }
  1524. else
  1525. {
  1526. sc = state.GetErrorCode();
  1527. }
  1528. }
  1529. CATCH( CException, e )
  1530. {
  1531. sc = e.GetErrorCode();
  1532. }
  1533. END_CATCH
  1534. UNTRANSLATE_EXCEPTIONS;
  1535. if ( FAILED(sc) )
  1536. {
  1537. odmDebugOut(( DEB_ERROR, "get_UniqueKeyCount Failed: %x\n",sc ));
  1538. SetErrorInfo( sc );
  1539. }
  1540. return sc;
  1541. }
  1542. //+---------------------------------------------------------------------------
  1543. //
  1544. // Member: CCatAdm::get_StateInfo, public property
  1545. //
  1546. // Synopsis: returns catalog's StateInformation
  1547. //
  1548. // Arguments: [pVal] -- out param,
  1549. //
  1550. // Returns: S_OK upon success, other values upon failure.
  1551. //
  1552. // Notes: Property value is an unsigned value, though it is being
  1553. // passed in as a signed LONG for compatiblity with automation
  1554. // clients (VB5, VB6 don't support unsigned long).
  1555. //
  1556. // History: 4-6-97 mohamedn created
  1557. //
  1558. //----------------------------------------------------------------------------
  1559. STDMETHODIMP CCatAdm::get_StateInfo(LONG *pVal)
  1560. {
  1561. SCODE sc = S_OK;
  1562. CLock lock(_mtx);
  1563. TRANSLATE_EXCEPTIONS;
  1564. TRY
  1565. {
  1566. SafeForScripting();
  1567. CCatStateInfo & state = _xCatAdmin->State();
  1568. if ( !IsCurrentObjectValid() )
  1569. {
  1570. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1571. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1572. }
  1573. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1574. {
  1575. state.LokUpdate();
  1576. _dwTickCount = GetTickCount();
  1577. }
  1578. if ( state.IsValid() )
  1579. {
  1580. *pVal = state.GetStateInfo();
  1581. }
  1582. else
  1583. {
  1584. sc = state.GetErrorCode();
  1585. }
  1586. }
  1587. CATCH( CException, e )
  1588. {
  1589. sc = e.GetErrorCode();
  1590. }
  1591. END_CATCH
  1592. UNTRANSLATE_EXCEPTIONS;
  1593. if ( FAILED(sc) )
  1594. {
  1595. odmDebugOut(( DEB_ERROR, "get_StateInfo Failed: %x\n",sc ));
  1596. SetErrorInfo( sc );
  1597. }
  1598. return sc;
  1599. }
  1600. //+---------------------------------------------------------------------------
  1601. //
  1602. // Member: CCatAdm::get_IsUpToDate, public property
  1603. //
  1604. // Synopsis: property is TRUE if catalog is up to date.
  1605. //
  1606. // Arguments: [pVal] -- out param,
  1607. //
  1608. // Returns: S_OK upon success, other values upon failure.
  1609. //
  1610. // History: 4-6-97 mohamedn created
  1611. //
  1612. //----------------------------------------------------------------------------
  1613. STDMETHODIMP CCatAdm::get_IsUpToDate(VARIANT_BOOL *pVal)
  1614. {
  1615. SCODE sc = S_OK;
  1616. CLock lock(_mtx);
  1617. TRANSLATE_EXCEPTIONS;
  1618. TRY
  1619. {
  1620. SafeForScripting();
  1621. CCatStateInfo & state = _xCatAdmin->State();
  1622. if ( !IsCurrentObjectValid() )
  1623. {
  1624. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1625. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1626. }
  1627. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1628. {
  1629. state.LokUpdate();
  1630. _dwTickCount = GetTickCount();
  1631. }
  1632. if ( state.IsValid() )
  1633. {
  1634. DWORD currentState = state.GetStateInfo();
  1635. if ( 0 != state.GetDocumentsToFilter() ||
  1636. currentState & CI_STATE_CONTENT_SCAN_REQUIRED ||
  1637. currentState & CI_STATE_SCANNING ||
  1638. currentState & CI_STATE_RECOVERING ||
  1639. currentState & CI_STATE_READING_USNS ||
  1640. currentState & CI_STATE_STARTING )
  1641. {
  1642. *pVal = VARIANT_FALSE;
  1643. }
  1644. else
  1645. {
  1646. *pVal = VARIANT_TRUE;
  1647. }
  1648. }
  1649. else
  1650. {
  1651. sc = state.GetErrorCode();
  1652. }
  1653. }
  1654. CATCH( CException, e )
  1655. {
  1656. sc = e.GetErrorCode();
  1657. }
  1658. END_CATCH
  1659. UNTRANSLATE_EXCEPTIONS;
  1660. if ( FAILED(sc) )
  1661. {
  1662. odmDebugOut(( DEB_ERROR, "get_IsUpToDate Failed: %x\n",sc ));
  1663. SetErrorInfo( sc );
  1664. }
  1665. return sc;
  1666. }
  1667. //+---------------------------------------------------------------------------
  1668. //
  1669. // Member: CCatAdm::get_DelayedFilterCount, public property
  1670. //
  1671. // Synopsis: returns catalog's DelayedFilterCount property
  1672. //
  1673. // Arguments: [pVal] -- out param
  1674. //
  1675. // Returns: S_OK upon success, other values upon failure.
  1676. //
  1677. // Notes: out value is an unsigned value, though it is being
  1678. // passed as a signed LONG for compatiblity with automation
  1679. // clients (VB5, VB6 don't support unsigned long).
  1680. //
  1681. // History: 4-14-98 vikasman created
  1682. //
  1683. //----------------------------------------------------------------------------
  1684. STDMETHODIMP CCatAdm::get_DelayedFilterCount(LONG *pVal)
  1685. {
  1686. SCODE sc = S_OK;
  1687. CLock lock(_mtx);
  1688. TRANSLATE_EXCEPTIONS;
  1689. TRY
  1690. {
  1691. SafeForScripting();
  1692. CCatStateInfo & state = _xCatAdmin->State();
  1693. if ( !IsCurrentObjectValid() )
  1694. {
  1695. odmDebugOut(( DEB_ERROR, "Invalid catalog\n" ));
  1696. sc = HRESULT_FROM_WIN32( ERROR_INVALID_STATE );
  1697. }
  1698. else if ( GetTickCount() > _dwTickCount + UpdateInterval )
  1699. {
  1700. state.LokUpdate();
  1701. _dwTickCount = GetTickCount();
  1702. }
  1703. if ( state.IsValid() )
  1704. {
  1705. *pVal = state.GetDelayedFilterCount();
  1706. }
  1707. else
  1708. {
  1709. sc = state.GetErrorCode();
  1710. }
  1711. }
  1712. CATCH( CException, e )
  1713. {
  1714. sc = e.GetErrorCode();
  1715. }
  1716. END_CATCH
  1717. UNTRANSLATE_EXCEPTIONS;
  1718. if ( FAILED(sc) )
  1719. {
  1720. odmDebugOut(( DEB_ERROR, "get_DelayedFilterCount Failed: %x\n",sc ));
  1721. SetErrorInfo( sc );
  1722. }
  1723. return sc;
  1724. }
  1725. //+---------------------------------------------------------------------------
  1726. //
  1727. // Member: CCatAdm::PauseCatalog, public
  1728. //
  1729. // Synopsis: Pauses the catalog
  1730. //
  1731. // Returns: S_OK upon success, other values upon failure.
  1732. //
  1733. // Arguments: [pdwOldState] -- out param, DWORD indicating the previous
  1734. // state of the catalog
  1735. //
  1736. // History: 08-03-98 kitmanh created
  1737. //
  1738. //----------------------------------------------------------------------------
  1739. STDMETHODIMP CCatAdm::PauseCatalog( CatalogStateType * pdwOldState )
  1740. {
  1741. Win4Assert( CICAT_STOPPED == csStopped );
  1742. Win4Assert( CICAT_READONLY == csReadOnly );
  1743. Win4Assert( CICAT_WRITABLE == csWritable );
  1744. SCODE sc = S_OK;
  1745. CLock lock(_mtx);
  1746. TRANSLATE_EXCEPTIONS;
  1747. TRY
  1748. {
  1749. SafeForScripting();
  1750. DWORD dwOldState;
  1751. sc = SetCatalogState ( _xCatAdmin->GetName(),
  1752. _xCatAdmin->GetMachName(),
  1753. CICAT_READONLY,
  1754. &dwOldState );
  1755. // mask off the no_query bit
  1756. *pdwOldState = (CatalogStateType)(dwOldState & (~CICAT_NO_QUERY));
  1757. }
  1758. CATCH ( CException,e )
  1759. {
  1760. sc = e.GetErrorCode();
  1761. }
  1762. END_CATCH
  1763. UNTRANSLATE_EXCEPTIONS;
  1764. if ( FAILED(sc) )
  1765. {
  1766. odmDebugOut(( DEB_ERROR, "PauseCatalog Failed: %x\n",sc ));
  1767. SetErrorInfo(sc);
  1768. }
  1769. return sc;
  1770. }
  1771. //+---------------------------------------------------------------------------
  1772. //
  1773. // Member: CCatAdm::StartCatalog, public
  1774. //
  1775. // Synopsis: Starts the catalog
  1776. //
  1777. // Returns: S_OK upon success, other values upon failure.
  1778. //
  1779. // Arguments: [pdwOldState] -- out param, DWORD indicating the previous
  1780. // state of the catalog
  1781. //
  1782. // History: 08-05-98 kitmanh created
  1783. //
  1784. //----------------------------------------------------------------------------
  1785. STDMETHODIMP CCatAdm::StartCatalog( CatalogStateType * pdwOldState )
  1786. {
  1787. Win4Assert( CICAT_STOPPED == csStopped );
  1788. Win4Assert( CICAT_READONLY == csReadOnly );
  1789. Win4Assert( CICAT_WRITABLE == csWritable );
  1790. SCODE sc = S_OK;
  1791. CLock lock(_mtx);
  1792. TRANSLATE_EXCEPTIONS;
  1793. TRY
  1794. {
  1795. SafeForScripting();
  1796. DWORD dwOldState;
  1797. sc = SetCatalogState ( _xCatAdmin->GetName(),
  1798. _xCatAdmin->GetMachName(),
  1799. CICAT_WRITABLE,
  1800. &dwOldState );
  1801. // mask off the no_query bit
  1802. *pdwOldState = (CatalogStateType)(dwOldState & (~CICAT_NO_QUERY));
  1803. }
  1804. CATCH ( CException,e )
  1805. {
  1806. sc = e.GetErrorCode();
  1807. }
  1808. END_CATCH
  1809. UNTRANSLATE_EXCEPTIONS;
  1810. if ( FAILED(sc) )
  1811. {
  1812. odmDebugOut(( DEB_ERROR, "StartCatalog Failed: %x\n",sc ));
  1813. SetErrorInfo(sc);
  1814. }
  1815. return sc;
  1816. }
  1817. //+---------------------------------------------------------------------------
  1818. //
  1819. // Member: CCatAdm::StopCatalog, public
  1820. //
  1821. // Synopsis: Stops the catalog
  1822. //
  1823. // Returns: S_OK upon success, other values upon failure.
  1824. //
  1825. // Arguments: [pdwOldState] -- out param, DWORD indicating the previous
  1826. // state of the catalog
  1827. //
  1828. // History: 08-05-98 kitmanh created
  1829. //
  1830. //----------------------------------------------------------------------------
  1831. STDMETHODIMP CCatAdm::StopCatalog( CatalogStateType * pdwOldState )
  1832. {
  1833. Win4Assert( CICAT_STOPPED == csStopped );
  1834. Win4Assert( CICAT_READONLY == csReadOnly );
  1835. Win4Assert( CICAT_WRITABLE == csWritable );
  1836. SCODE sc = S_OK;
  1837. CLock lock(_mtx);
  1838. TRANSLATE_EXCEPTIONS;
  1839. TRY
  1840. {
  1841. SafeForScripting();
  1842. DWORD dwOldState;
  1843. sc = SetCatalogState ( _xCatAdmin->GetName(),
  1844. _xCatAdmin->GetMachName(),
  1845. CICAT_STOPPED,
  1846. &dwOldState );
  1847. // mask off the no_query bit
  1848. *pdwOldState = (CatalogStateType)(dwOldState & (~CICAT_NO_QUERY));
  1849. }
  1850. CATCH ( CException,e )
  1851. {
  1852. sc = e.GetErrorCode();
  1853. }
  1854. END_CATCH
  1855. UNTRANSLATE_EXCEPTIONS;
  1856. if ( FAILED(sc) )
  1857. {
  1858. odmDebugOut(( DEB_ERROR, "StopCatalog Failed: %x\n",sc ));
  1859. SetErrorInfo(sc);
  1860. }
  1861. return sc;
  1862. }
  1863. //+---------------------------------------------------------------------------
  1864. //
  1865. // Member: CCatAdm::ContinueCatalog, public
  1866. //
  1867. // Synopsis: Continues the catalog
  1868. //
  1869. // Returns: S_OK upon success, other values upon failure.
  1870. //
  1871. // Arguments: [pdwOldState] -- out param, DWORD indicating the previous
  1872. // state of the catalog
  1873. //
  1874. // History: 09-08-98 kitmanh created
  1875. //
  1876. //----------------------------------------------------------------------------
  1877. STDMETHODIMP CCatAdm::ContinueCatalog( CatalogStateType * pdwOldState )
  1878. {
  1879. Win4Assert( CICAT_STOPPED == csStopped );
  1880. Win4Assert( CICAT_READONLY == csReadOnly );
  1881. Win4Assert( CICAT_WRITABLE == csWritable );
  1882. SCODE sc = S_OK;
  1883. CLock lock(_mtx);
  1884. TRANSLATE_EXCEPTIONS;
  1885. TRY
  1886. {
  1887. SafeForScripting();
  1888. DWORD dwOldState;
  1889. sc = SetCatalogState ( _xCatAdmin->GetName(),
  1890. _xCatAdmin->GetMachName(),
  1891. CICAT_WRITABLE,
  1892. &dwOldState );
  1893. // mask off the no_query bit
  1894. *pdwOldState = (CatalogStateType)(dwOldState & (~CICAT_NO_QUERY));
  1895. }
  1896. CATCH ( CException,e )
  1897. {
  1898. sc = e.GetErrorCode();
  1899. }
  1900. END_CATCH
  1901. UNTRANSLATE_EXCEPTIONS;
  1902. if ( FAILED(sc) )
  1903. {
  1904. odmDebugOut(( DEB_ERROR, "ContinueCatalog Failed: %x\n",sc ));
  1905. SetErrorInfo(sc);
  1906. }
  1907. return sc;
  1908. }
  1909. //+---------------------------------------------------------------------------
  1910. //
  1911. // Member: CCatAdm::IsCatalogRunning, public
  1912. //
  1913. // Synopsis: check if the catalog is in R/W mode
  1914. //
  1915. // Returns: S_OK upon success, other values upon failure.
  1916. //
  1917. // Arguments: [pfIsRunning] -- out param
  1918. //
  1919. // History: 08-10-98 kitmanh created
  1920. //
  1921. //----------------------------------------------------------------------------
  1922. STDMETHODIMP CCatAdm::IsCatalogRunning( VARIANT_BOOL *pfIsRunning )
  1923. {
  1924. SCODE sc = S_OK;
  1925. CLock lock(_mtx);
  1926. TRANSLATE_EXCEPTIONS;
  1927. TRY
  1928. {
  1929. SafeForScripting();
  1930. DWORD dwOldState;
  1931. sc = SetCatalogState ( _xCatAdmin->GetName(),
  1932. _xCatAdmin->GetMachName(),
  1933. CICAT_GET_STATE,
  1934. &dwOldState );
  1935. *pfIsRunning = ( ( CICAT_WRITABLE & dwOldState ) &&
  1936. !( CICAT_NO_QUERY & dwOldState) ) ? VARIANT_TRUE : VARIANT_FALSE;
  1937. }
  1938. CATCH ( CException,e )
  1939. {
  1940. sc = e.GetErrorCode();
  1941. }
  1942. END_CATCH
  1943. UNTRANSLATE_EXCEPTIONS;
  1944. if ( FAILED(sc) )
  1945. {
  1946. odmDebugOut(( DEB_ERROR, "IsCatalogRunning Failed: %x\n",sc ));
  1947. SetErrorInfo(sc);
  1948. }
  1949. return sc;
  1950. }
  1951. //+---------------------------------------------------------------------------
  1952. //
  1953. // Member: CCatAdm::IsCatalogPaused, public
  1954. //
  1955. // Synopsis: check if the catalog is paused (read-only)
  1956. //
  1957. // Returns: S_OK upon success, other values upon failure.
  1958. //
  1959. // Arguments: [pfIsPaused] -- out param
  1960. //
  1961. // History: 08-10-98 kitmanh created
  1962. //
  1963. //----------------------------------------------------------------------------
  1964. STDMETHODIMP CCatAdm::IsCatalogPaused( VARIANT_BOOL *pfIsPaused )
  1965. {
  1966. SCODE sc = S_OK;
  1967. CLock lock(_mtx);
  1968. TRANSLATE_EXCEPTIONS;
  1969. TRY
  1970. {
  1971. SafeForScripting();
  1972. DWORD dwOldState;
  1973. sc = SetCatalogState ( _xCatAdmin->GetName(),
  1974. _xCatAdmin->GetMachName(),
  1975. CICAT_GET_STATE,
  1976. &dwOldState );
  1977. *pfIsPaused = (CICAT_READONLY & dwOldState) ? VARIANT_TRUE : VARIANT_FALSE;
  1978. }
  1979. CATCH ( CException,e )
  1980. {
  1981. sc = e.GetErrorCode();
  1982. }
  1983. END_CATCH
  1984. UNTRANSLATE_EXCEPTIONS;
  1985. if ( FAILED(sc) )
  1986. {
  1987. odmDebugOut(( DEB_ERROR, "IsCatalogPaused Failed: %x\n",sc ));
  1988. SetErrorInfo(sc);
  1989. }
  1990. return sc;
  1991. }
  1992. //+---------------------------------------------------------------------------
  1993. //
  1994. // Member: CCatAdm::IsCatalogStopped, public
  1995. //
  1996. // Synopsis: check if the catalog is stopped
  1997. //
  1998. // Returns: S_OK upon success, other values upon failure.
  1999. //
  2000. // Arguments: [pfIsStopped] -- out param
  2001. //
  2002. // History: 08-10-98 kitmanh created
  2003. //
  2004. //----------------------------------------------------------------------------
  2005. STDMETHODIMP CCatAdm::IsCatalogStopped( VARIANT_BOOL *pfIsStopped )
  2006. {
  2007. SCODE sc = S_OK;
  2008. CLock lock(_mtx);
  2009. TRANSLATE_EXCEPTIONS;
  2010. TRY
  2011. {
  2012. SafeForScripting();
  2013. DWORD dwOldState;
  2014. sc = SetCatalogState ( _xCatAdmin->GetName(),
  2015. _xCatAdmin->GetMachName(),
  2016. CICAT_GET_STATE,
  2017. &dwOldState );
  2018. *pfIsStopped = (CICAT_STOPPED & dwOldState) ? VARIANT_TRUE : VARIANT_FALSE;
  2019. }
  2020. CATCH ( CException,e )
  2021. {
  2022. sc = e.GetErrorCode();
  2023. }
  2024. END_CATCH
  2025. UNTRANSLATE_EXCEPTIONS;
  2026. if ( FAILED(sc) )
  2027. {
  2028. odmDebugOut(( DEB_ERROR, "IsCatalogStopped Failed: %x\n",sc ));
  2029. SetErrorInfo(sc);
  2030. }
  2031. return sc;
  2032. }