|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "harvesterobserver.h" |
|
19 |
|
20 CHarvesterObserver* CHarvesterObserver::NewL( CIndexingPlugin* aPluginToObserve ) |
|
21 { |
|
22 __ASSERT_ALWAYS( aPluginToObserve, User::Leave( KErrArgument ) ); |
|
23 CHarvesterObserver* observer = CHarvesterObserver::NewLC( aPluginToObserve ); |
|
24 CleanupStack::Pop( observer ); |
|
25 return observer; |
|
26 } |
|
27 |
|
28 CHarvesterObserver* CHarvesterObserver::NewLC( CIndexingPlugin* aPluginToObserve ) |
|
29 { |
|
30 CHarvesterObserver* observer = new ( ELeave ) CHarvesterObserver( aPluginToObserve ); |
|
31 CleanupStack::PushL( observer ); |
|
32 observer->ConstructL(); |
|
33 return observer; |
|
34 } |
|
35 |
|
36 void CHarvesterObserver::ConstructL() |
|
37 { |
|
38 iWaitForHarvester = new (ELeave) CActiveSchedulerWait; |
|
39 User::LeaveIfError( iSearchSession.Connect() ); |
|
40 iObservedPlugin->SetSearchSession( iSearchSession ); |
|
41 iObservedPlugin->SetObserver( *this ); |
|
42 iWaitTime = TTimeIntervalMicroSeconds32(0); //Zero initially |
|
43 iCallback = CDelayedCallback::NewL(CActive::EPriorityIdle); |
|
44 } |
|
45 |
|
46 void CHarvesterObserver::SetWaitTime(TTimeIntervalMicroSeconds32 aTimetoWait) |
|
47 { |
|
48 iWaitTime = aTimetoWait; |
|
49 } |
|
50 CHarvesterObserver::CHarvesterObserver( CIndexingPlugin* aPluginToObserve ) |
|
51 { |
|
52 iObservedPlugin = aPluginToObserve; |
|
53 }; |
|
54 |
|
55 CHarvesterObserver::~CHarvesterObserver() |
|
56 { |
|
57 delete iWaitForHarvester; |
|
58 iSearchSession.Close(); |
|
59 delete iCallback; |
|
60 } |
|
61 |
|
62 void CHarvesterObserver::HarvestingCompleted( CIndexingPlugin* /*aPlugin*/, const TDesC& /*aQualifiedBaseAppClass*/, TInt /*aError*/) |
|
63 { |
|
64 if(iWaitTime > TTimeIntervalMicroSeconds32(0)) //harvesters requested to wait so wait before completion |
|
65 { |
|
66 iCallback->Start( 0, this, iWaitTime.Int()); //Stop wait AO in callback |
|
67 } |
|
68 else |
|
69 { |
|
70 //Stop WAIT AO here |
|
71 iWaitForHarvester->AsyncStop(); |
|
72 } |
|
73 } |
|
74 |
|
75 void CHarvesterObserver::DelayedCallbackL(TInt aCode) |
|
76 { |
|
77 iWaitForHarvester->AsyncStop(); |
|
78 } |
|
79 |
|
80 void CHarvesterObserver::DelayedError(TInt aErrorCode) |
|
81 { |
|
82 iWaitForHarvester->AsyncStop(); |
|
83 } |
|
84 |
|
85 void CHarvesterObserver::AddHarvestingQueue(CIndexingPlugin* /*aPlugin*/, const TDesC& /*aQualifiedBaseAppClass*/,TBool aForceReharvest) |
|
86 { |
|
87 } |