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 FILES
|
|
19 |
|
|
20 |
#include "stubsrvapiexecutor.h"
|
|
21 |
#include "stubsrvsession.h"
|
|
22 |
|
|
23 |
CApiExecutor* CApiExecutor::NewL()
|
|
24 |
{
|
|
25 |
CApiExecutor* self = new (ELeave) CApiExecutor();
|
|
26 |
CleanupStack::PushL(self);
|
|
27 |
self->ConstructL();
|
|
28 |
CleanupStack::Pop(self);
|
|
29 |
return self;
|
|
30 |
}
|
|
31 |
|
|
32 |
CApiExecutor::~CApiExecutor()
|
|
33 |
{
|
|
34 |
Cancel();
|
|
35 |
iTimer.Close();
|
|
36 |
if (iMessage.Handle())
|
|
37 |
{
|
|
38 |
iMessage.Complete(KErrCancel);
|
|
39 |
}
|
|
40 |
}
|
|
41 |
|
|
42 |
const TApiBehavior& CApiExecutor::ApiBehavior() const
|
|
43 |
{
|
|
44 |
return iBeh;
|
|
45 |
}
|
|
46 |
|
|
47 |
TApiInvokeMode CApiExecutor::Mode() const
|
|
48 |
{
|
|
49 |
return iMode;
|
|
50 |
}
|
|
51 |
|
|
52 |
void CApiExecutor::ExecuteL(const RMessage2& aMessage, CStubSrvSess& aSession, TUint aLib, TUint aApi)
|
|
53 |
{
|
|
54 |
iMessage = aMessage;
|
|
55 |
iSess = &aSession;
|
|
56 |
iBeh = TApiBehavior(aLib, aApi);
|
|
57 |
iMode = (TApiInvokeMode) iMessage.Int1();
|
|
58 |
if (iMode == ECompleteIfNoBehaviorSet)
|
|
59 |
{
|
|
60 |
TRequestStatus* status = &iStatus;
|
|
61 |
User::RequestComplete(status, KErrNone);
|
|
62 |
SetActive();
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
void CApiExecutor::ExecuteL(const RMessage2& aMessage, CStubSrvSess& aSession, const TApiBehavior& aBeh, TInt aExeDuration)
|
|
67 |
{
|
|
68 |
iMessage = aMessage;
|
|
69 |
iSess = &aSession;
|
|
70 |
iMode = ECompleteIfNoBehaviorSet;
|
|
71 |
iBeh = aBeh;
|
|
72 |
iTimeout = aExeDuration;
|
|
73 |
if (iTimeout == 0)
|
|
74 |
{
|
|
75 |
TRequestStatus* status = &iStatus;
|
|
76 |
User::RequestComplete(status, KErrNone);
|
|
77 |
SetActive();
|
|
78 |
}
|
|
79 |
else if (iTimeout > 0)
|
|
80 |
{
|
|
81 |
iTimer.After(iStatus, iTimeout);
|
|
82 |
SetActive();
|
|
83 |
}
|
|
84 |
}
|
|
85 |
|
|
86 |
void CApiExecutor::Resume(const TApiBehavior& aBeh, TInt aExeDuration)
|
|
87 |
{
|
|
88 |
iBeh = aBeh;
|
|
89 |
iTimeout = aExeDuration;
|
|
90 |
iMode = ECompleteIfNoBehaviorSet;
|
|
91 |
if (iTimeout == 0)
|
|
92 |
{
|
|
93 |
TRequestStatus* status = &iStatus;
|
|
94 |
User::RequestComplete(status, KErrNone);
|
|
95 |
SetActive();
|
|
96 |
}
|
|
97 |
else if (iTimeout > 0)
|
|
98 |
{
|
|
99 |
iTimer.After(iStatus, iTimeout);
|
|
100 |
SetActive();
|
|
101 |
}
|
|
102 |
}
|
|
103 |
|
|
104 |
void CApiExecutor::RunL()
|
|
105 |
{
|
|
106 |
TInt err = KErrNone;
|
|
107 |
TApiBehaviorPckgBuf pckg(iBeh);
|
|
108 |
err = iMessage.Write(0, pckg);
|
|
109 |
iMessage.Complete(err);
|
|
110 |
iSess->InvokeApiComplete();
|
|
111 |
}
|
|
112 |
|
|
113 |
TInt CApiExecutor::RunError(TInt /*aReason*/)
|
|
114 |
{
|
|
115 |
return KErrNone;
|
|
116 |
}
|
|
117 |
|
|
118 |
void CApiExecutor::DoCancel()
|
|
119 |
{
|
|
120 |
iTimer.Cancel();
|
|
121 |
if (iMessage.Handle())
|
|
122 |
{
|
|
123 |
iMessage.Complete(KErrCancel);
|
|
124 |
}
|
|
125 |
}
|
|
126 |
|
|
127 |
CApiExecutor::CApiExecutor()
|
|
128 |
: CActive(CActive::EPriorityStandard)
|
|
129 |
{
|
|
130 |
CActiveScheduler::Add(this);
|
|
131 |
}
|
|
132 |
|
|
133 |
void CApiExecutor::ConstructL()
|
|
134 |
{
|
|
135 |
iTimer.CreateLocal();
|
|
136 |
}
|
|
137 |
|
|
138 |
|