0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file basicwatcher.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "BasicWatcher.h"
|
|
20 |
#include "testdebug.h"
|
|
21 |
|
|
22 |
namespace NUnitTesting_USBDI
|
|
23 |
{
|
|
24 |
|
|
25 |
CBasicWatcher::CBasicWatcher(const TCallBack& aCallBack,TInt aPriority)
|
|
26 |
: CActive(aPriority),
|
|
27 |
iCallBack(aCallBack),
|
|
28 |
iCompletionCode(KErrNone)
|
|
29 |
{
|
|
30 |
CActiveScheduler::Add(this);
|
|
31 |
}
|
|
32 |
|
|
33 |
CBasicWatcher::~CBasicWatcher()
|
|
34 |
{
|
|
35 |
LOG_FUNC
|
|
36 |
|
|
37 |
Cancel();
|
|
38 |
}
|
|
39 |
|
|
40 |
void CBasicWatcher::DoCancel()
|
|
41 |
{
|
|
42 |
LOG_FUNC
|
|
43 |
|
|
44 |
RDebug::Printf("Watch cancelled");
|
|
45 |
iStatus = KErrCancel;
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
void CBasicWatcher::StartWatching()
|
|
50 |
{
|
|
51 |
LOG_FUNC
|
|
52 |
|
|
53 |
if(iStatus != KRequestPending)
|
|
54 |
{
|
|
55 |
User::Panic(_L("iStatus has not been set to pending this will lead to E32USER-CBase Panic"),46);
|
|
56 |
}
|
|
57 |
SetActive();
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
void CBasicWatcher::RunL()
|
|
62 |
{
|
|
63 |
LOG_FUNC
|
|
64 |
|
|
65 |
iCompletionCode = iStatus.Int();
|
|
66 |
User::LeaveIfError(iCallBack.CallBack());
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
TInt CBasicWatcher::RunError(TInt aError)
|
|
71 |
{
|
|
72 |
LOG_FUNC
|
|
73 |
|
|
74 |
RDebug::Printf("Watcher code Left with %d",aError);
|
|
75 |
return KErrNone;
|
|
76 |
}
|
|
77 |
|
|
78 |
}
|
|
79 |
|