|
72
|
1 |
// Copyright (c) 2003-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 "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 |
//
|
|
|
15 |
// This contains CTestAsynchHandler which is an active object to
|
|
|
16 |
// handle the asynch calls from the RootServer during testing
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
// EPOC includes
|
|
|
21 |
#include <e32base.h>
|
|
|
22 |
|
|
|
23 |
// RootServer includes
|
|
|
24 |
#include "rsshared.h"
|
|
|
25 |
|
|
|
26 |
// Test system includes
|
|
|
27 |
#include "TestAsynchHandler.h"
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
CTestAsynchHandler* CTestAsynchHandler::NewLC(RRootServ* aRootServer)
|
|
|
31 |
{
|
|
|
32 |
CTestAsynchHandler* self = new(ELeave) CTestAsynchHandler;
|
|
|
33 |
CleanupStack::PushL(self);
|
|
|
34 |
self->ConstructL(aRootServer);
|
|
|
35 |
return self;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
CTestAsynchHandler::CTestAsynchHandler() : CActive(0)
|
|
|
39 |
{
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
void CTestAsynchHandler::ConstructL(RRootServ* aRootServer)
|
|
|
43 |
{
|
|
|
44 |
iState = EIdle;
|
|
|
45 |
iRootServer = aRootServer;
|
|
|
46 |
User::LeaveIfError(iTimer.CreateLocal());
|
|
|
47 |
CActiveScheduler::Add(this);
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
CTestAsynchHandler::~CTestAsynchHandler()
|
|
|
51 |
{
|
|
|
52 |
Cancel();
|
|
|
53 |
iTimer.Close();
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
// from CActive
|
|
|
57 |
void CTestAsynchHandler::RunL()
|
|
|
58 |
{
|
|
|
59 |
switch(iState)
|
|
|
60 |
{
|
|
|
61 |
case ELoading:
|
|
|
62 |
case EUnLoading:
|
|
|
63 |
case EBinding:
|
|
|
64 |
case EUnBinding:
|
|
|
65 |
case EListeningforDeath:
|
|
|
66 |
case EWaitingforTimer:
|
|
|
67 |
case EIdle:
|
|
|
68 |
default:
|
|
|
69 |
CActiveScheduler::Stop();
|
|
|
70 |
break;
|
|
|
71 |
}
|
|
|
72 |
iState = EIdle;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
void CTestAsynchHandler::DoCancel()
|
|
|
76 |
{
|
|
|
77 |
switch (iState)
|
|
|
78 |
{
|
|
|
79 |
case EListeningforDeath:
|
|
|
80 |
iPropertyDeath.Cancel();
|
|
|
81 |
break;
|
|
|
82 |
|
|
|
83 |
case EWaitingforTimer:
|
|
|
84 |
iTimer.Cancel();
|
|
|
85 |
break;
|
|
|
86 |
|
|
|
87 |
case ELoading:
|
|
|
88 |
case EIdle:
|
|
|
89 |
default:
|
|
|
90 |
break;
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
// requests
|
|
|
96 |
void CTestAsynchHandler::TryLoad(const TRSStartModuleParams& aParams,
|
|
|
97 |
const TDesC8& aIniData)
|
|
|
98 |
{
|
|
|
99 |
iState = ELoading;
|
|
|
100 |
iRootServer->LoadCpm(iStatus, aParams, aIniData);
|
|
|
101 |
SetActive();
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
void CTestAsynchHandler::TryUnLoad(const TCFModuleName& aName, TRSUnLoadType aType)
|
|
|
105 |
{
|
|
|
106 |
iState = EUnLoading;
|
|
|
107 |
iRootServer->UnloadCpm(iStatus, aName, aType);
|
|
|
108 |
SetActive();
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
void CTestAsynchHandler::TryBind( TRSBindingInfo& aBindInfo )
|
|
|
112 |
{
|
|
|
113 |
iState = EBinding;
|
|
|
114 |
iRootServer->Bind( iStatus, aBindInfo );
|
|
|
115 |
SetActive();
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
void CTestAsynchHandler::TryUnBind( TRSUnBindingInfo& aUnbindInfo )
|
|
|
119 |
{
|
|
|
120 |
iState = EUnBinding;
|
|
|
121 |
iRootServer->Unbind( iStatus, aUnbindInfo );
|
|
|
122 |
SetActive();
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
void CTestAsynchHandler::TryWaitForDeath(void)
|
|
|
126 |
{
|
|
|
127 |
iState = EListeningforDeath;
|
|
|
128 |
TInt result = iPropertyDeath.Attach( KUidSystemCategory,KUidC32RootModuleDeathKey.iUid );
|
|
|
129 |
if(result != KErrNone)
|
|
|
130 |
{
|
|
|
131 |
_LIT( KAsynch, "Asynch" );
|
|
|
132 |
User::Panic( KAsynch, result );
|
|
|
133 |
}
|
|
|
134 |
iPropertyDeath.Subscribe( iStatus );
|
|
|
135 |
SetActive();
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
void CTestAsynchHandler::TryCancelDeath()
|
|
|
139 |
{
|
|
|
140 |
|
|
|
141 |
// we are already active cos we are waiting on our subscription
|
|
|
142 |
// therefore we will simply cancel the property subscription
|
|
|
143 |
iState=EIdle;
|
|
|
144 |
DoCancel();
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
void CTestAsynchHandler::WaitForTimer(TInt aTimeout_ms)
|
|
|
148 |
{
|
|
|
149 |
iState = EWaitingforTimer;
|
|
|
150 |
|
|
|
151 |
DoCancel(); // in case timer already running
|
|
|
152 |
iTimer.After(iStatus, aTimeout_ms * 1000);
|
|
|
153 |
SetActive();
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
|