|
1 // Copyright (c) 2005-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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file TestAscynHandler.cpp |
|
20 */ |
|
21 |
|
22 #include "TestAscynHandler.h" |
|
23 |
|
24 //Cancelling the Loading CPM before and after loading |
|
25 CCanceledLoadCpm* CCanceledLoadCpm::NewL() |
|
26 { |
|
27 CCanceledLoadCpm* self = new(ELeave) CCanceledLoadCpm; |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(self); |
|
31 return self; |
|
32 } |
|
33 |
|
34 |
|
35 CCanceledLoadCpm::CCanceledLoadCpm() |
|
36 : CActive(CActive::EPriorityStandard) |
|
37 { |
|
38 } |
|
39 |
|
40 void CCanceledLoadCpm::ConstructL() |
|
41 { |
|
42 iState = EIdle; |
|
43 iConfigurator.Connect(); |
|
44 CActiveScheduler::Add(this); |
|
45 } |
|
46 |
|
47 CCanceledLoadCpm::~CCanceledLoadCpm() |
|
48 { |
|
49 Cancel(); |
|
50 iTimer.Close(); |
|
51 iConfigurator.Close(); |
|
52 } |
|
53 |
|
54 void CCanceledLoadCpm::RunL() |
|
55 { |
|
56 switch(iState) |
|
57 { |
|
58 case ELoading: |
|
59 case EUnLoading: |
|
60 case EBinding: |
|
61 case EUnBinding: |
|
62 case EListeningforDeath: |
|
63 case EWaitingforTimer: |
|
64 case EIdle: |
|
65 default: |
|
66 CActiveScheduler::Stop(); |
|
67 break; |
|
68 } |
|
69 iState = EIdle; |
|
70 } |
|
71 |
|
72 void CCanceledLoadCpm::DoCancel() |
|
73 { |
|
74 switch (iState) |
|
75 { |
|
76 case EListeningforDeath: |
|
77 iPropertyDeath.Cancel(); |
|
78 break; |
|
79 |
|
80 case EWaitingforTimer: |
|
81 iTimer.Cancel(); |
|
82 break; |
|
83 |
|
84 case EIdle: |
|
85 default: |
|
86 break; |
|
87 } |
|
88 } |
|
89 |
|
90 |
|
91 // requests |
|
92 void CCanceledLoadCpm::TryLoad(const TCFModuleName& aName) |
|
93 { |
|
94 iState = ELoading; |
|
95 iName = aName; |
|
96 iConfigurator.LoadCpm(aName, iStatus); |
|
97 SetActive(); |
|
98 } |
|
99 |
|
100 void CCanceledLoadCpm::TryUnLoad(const TCFModuleName& aName, TRSUnLoadType aType) |
|
101 { |
|
102 iState = EUnLoading; |
|
103 iConfigurator.UnloadCpm(aName, aType, iStatus); |
|
104 SetActive(); |
|
105 } |
|
106 |
|
107 void CCanceledLoadCpm::TryWaitForDeath(void) |
|
108 { |
|
109 iState = EListeningforDeath; |
|
110 TInt result = iPropertyDeath.Attach( KUidSystemCategory,KUidC32RootModuleDeathKey.iUid ); |
|
111 if(result != KErrNone) |
|
112 { |
|
113 _LIT( KAsync, "Async" ); |
|
114 User::Panic( KAsync, result ); |
|
115 } |
|
116 iPropertyDeath.Subscribe( iStatus ); |
|
117 SetActive(); |
|
118 } |
|
119 |
|
120 void CCanceledLoadCpm::TryCancelDeath() |
|
121 { |
|
122 |
|
123 // we are already active cos we are waiting on our subscription |
|
124 // therefore we will simply cancel the property subscription |
|
125 iState=EIdle; |
|
126 DoCancel(); |
|
127 } |
|
128 |
|
129 void CCanceledLoadCpm::WaitForTimer(TInt aTimeout_ms) |
|
130 { |
|
131 iState = EWaitingforTimer; |
|
132 |
|
133 DoCancel(); // in case timer already running |
|
134 iTimer.After(iStatus, aTimeout_ms * 1000); |
|
135 SetActive(); |
|
136 } |
|
137 |
|
138 |