62
|
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 "stubber.h"
|
|
19 |
#include "stubclient.h"
|
|
20 |
|
|
21 |
|
|
22 |
EXPORT_C CStubber* CStubber::NewL()
|
|
23 |
{
|
|
24 |
CStubber* self = new (ELeave) CStubber();
|
|
25 |
CleanupStack::PushL(self);
|
|
26 |
self->ConstructL();
|
|
27 |
CleanupStack::Pop(self);
|
|
28 |
return self;
|
|
29 |
}
|
|
30 |
|
|
31 |
EXPORT_C CStubber::~CStubber()
|
|
32 |
{
|
|
33 |
Cancel();
|
|
34 |
if (iClient)
|
|
35 |
iClient->Close();
|
|
36 |
delete iClient;
|
|
37 |
}
|
|
38 |
|
|
39 |
EXPORT_C void CStubber::EnqueBehavior(const TApiBehavior& aBeh, TInt aExeDuration)
|
|
40 |
{
|
|
41 |
iClient->EnqueBehavior(aBeh, aExeDuration);
|
|
42 |
}
|
|
43 |
|
|
44 |
EXPORT_C void CStubber::DeleteBehaviors(TUint aLib, TUint aApi)
|
|
45 |
{
|
|
46 |
iClient->DeleteBehaviors(aLib, aApi);
|
|
47 |
}
|
|
48 |
|
|
49 |
EXPORT_C void CStubber::InvokeApi(TApiBehavior& aBeh, TApiInvokeMode aMode)
|
|
50 |
{
|
|
51 |
aBeh = TApiBehavior(aBeh.iLib, aBeh.iApi);
|
|
52 |
TApiBehaviorPckg pckg(aBeh);
|
|
53 |
iClient->InvokeApi(pckg, aMode);
|
|
54 |
}
|
|
55 |
|
|
56 |
EXPORT_C void CStubber::InvokeApiL(MApiInvoker& aInvoker, TUint aLib, TUint aApi, TApiInvokeMode aMode)
|
|
57 |
{
|
|
58 |
if (IsActive())
|
|
59 |
{
|
|
60 |
User::Panic(_L("Stubber"), KErrInUse);
|
|
61 |
}
|
|
62 |
iInvoker = &aInvoker;
|
|
63 |
iBeh = TApiBehavior(aLib, aApi);
|
|
64 |
iClient->InvokeApiL(iBehPckg, iStatus, aMode);
|
|
65 |
SetActive();
|
|
66 |
}
|
|
67 |
|
|
68 |
EXPORT_C void CStubber::InvokeApiCancel()
|
|
69 |
{
|
|
70 |
Cancel();
|
|
71 |
}
|
|
72 |
|
|
73 |
void CStubber::RunL()
|
|
74 |
{
|
|
75 |
if (iStatus != KErrNone)
|
|
76 |
{
|
|
77 |
iBeh.iAsyncCompleteCode = iStatus.Int();
|
|
78 |
}
|
|
79 |
iInvoker->InvokeApiComplete(iBeh);
|
|
80 |
}
|
|
81 |
|
|
82 |
void CStubber::DoCancel()
|
|
83 |
{
|
|
84 |
iClient->InvokeApiCancel(iBeh.iLib, iBeh.iApi);
|
|
85 |
}
|
|
86 |
|
|
87 |
TInt CStubber::RunError(TInt /*aReason*/)
|
|
88 |
{
|
|
89 |
return KErrNone;
|
|
90 |
}
|
|
91 |
|
|
92 |
CStubber::CStubber() :
|
|
93 |
CActive(EPriorityStandard), iBehPckg(iBeh)
|
|
94 |
{
|
|
95 |
CActiveScheduler::Add(this);
|
|
96 |
}
|
|
97 |
|
|
98 |
void CStubber::ConstructL()
|
|
99 |
{
|
|
100 |
iClient = new (ELeave) RStubClient();
|
|
101 |
User::LeaveIfError(iClient->Connect());
|
|
102 |
}
|