|
1 /* |
|
2 * Copyright (c) 2009 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: Implementation of CSsmSwpPolicyBase class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <bautils.h> |
|
19 #include <ssm/ssmcmd.hrh> |
|
20 #include <ssm/ssmcommandlistresourcereader.h> |
|
21 #include <ssm/ssmstatemanager.h> |
|
22 #include <ssm/ssmswp.h> |
|
23 #include <ssm/ssmsubstates.hrh> |
|
24 #include <ssm/starterclient.h> |
|
25 |
|
26 #include "ssmswppolicybase.h" |
|
27 #include "trace.h" |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CSsmSwpPolicyBase::NewL |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CSsmSwpPolicyBase::CSsmSwpPolicyBase() |
|
36 { |
|
37 FUNC_LOG; |
|
38 } |
|
39 |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CSsmSwpPolicyBase::~CSsmSwpPolicyBase |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CSsmSwpPolicyBase::~CSsmSwpPolicyBase() |
|
46 { |
|
47 FUNC_LOG; |
|
48 } |
|
49 |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CSsmSwpPolicyBase::Initialize |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C void CSsmSwpPolicyBase::Initialize( TRequestStatus& aStatus ) |
|
56 { |
|
57 FUNC_LOG; |
|
58 ASSERT_TRACE( iCommandListResourceReader ); |
|
59 |
|
60 // Initialise command list resource reader. |
|
61 iCommandListResourceReader->Initialise( aStatus ); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CSsmSwpPolicyBase::InitializeCancel |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C void CSsmSwpPolicyBase::InitializeCancel() |
|
70 { |
|
71 FUNC_LOG; |
|
72 |
|
73 iCommandListResourceReader->InitialiseCancel(); |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CSsmSwpPolicyBase::PrepareCommandList |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C void CSsmSwpPolicyBase::PrepareCommandList( |
|
82 const TSsmSwp& aSwp, |
|
83 TRequestStatus& aStatus ) |
|
84 { |
|
85 FUNC_LOG; |
|
86 INFO_2( "Preparing cmd list for swp: 0x%08x::0x%08x", aSwp.Key(), aSwp.Value() ); |
|
87 |
|
88 // SWP value is used as a command list id. |
|
89 iCommandListResourceReader->PrepareCommandList( aSwp.Value(), aSwp, aStatus ); |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CSsmSwpPolicyBase::PrepareCommandListCancel |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C void CSsmSwpPolicyBase::PrepareCommandListCancel() |
|
98 { |
|
99 FUNC_LOG; |
|
100 |
|
101 iCommandListResourceReader->PrepareCommandListCancel(); |
|
102 } |
|
103 |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CSsmSwpPolicyBase::CommandList |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C CSsmCommandList* CSsmSwpPolicyBase::CommandList() |
|
110 { |
|
111 FUNC_LOG; |
|
112 |
|
113 return iCommandListResourceReader->GetCommandList(); |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CSsmSwpPolicyBase::HandleCleReturnValue |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C void CSsmSwpPolicyBase::HandleCleReturnValue( |
|
122 const TSsmSwp& INFO_PARAM( aSwp ), |
|
123 TInt aError, |
|
124 TInt aSeverity, |
|
125 TRequestStatus& aStatus ) |
|
126 { |
|
127 FUNC_LOG; |
|
128 INFO_3( "Completed swp transition: 0x%08x::0x%08x with result code %d", |
|
129 aSwp.Key(), aSwp.Value(), aError ); |
|
130 |
|
131 if ( aError == KErrNone || aSeverity < ECmdHighSeverity ) |
|
132 { |
|
133 TRequestStatus* status = &aStatus; |
|
134 User::RequestComplete( status, KErrNone ); |
|
135 } |
|
136 else |
|
137 { |
|
138 RSsmStateManager session; |
|
139 TInt errorCode = session.Connect(); |
|
140 ERROR( errorCode, "Failed to connect to RSsmStateManager" ); |
|
141 if ( errorCode == KErrNone ) |
|
142 { |
|
143 if ( ResetLimitReached() ) // Updates the reset count |
|
144 { |
|
145 INFO( "SWP transition failed -> Fail" ); |
|
146 errorCode = session.RequestStateTransition( |
|
147 TSsmStateTransition( ESsmFail, KSsmAnySubState, 0 ) ); |
|
148 } |
|
149 else |
|
150 { |
|
151 INFO( "SWP transition failed -> Reset" ); |
|
152 errorCode = session.RequestStateTransition( |
|
153 TSsmStateTransition( ESsmShutdown, KSsmAnySubState, |
|
154 RStarterSession::EUnknownReset ) ); |
|
155 } |
|
156 |
|
157 session.Close(); |
|
158 } |
|
159 |
|
160 TRequestStatus* status = &aStatus; |
|
161 User::RequestComplete( status, errorCode ); |
|
162 } |
|
163 } |
|
164 |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CSsmSwpPolicyBase::HandleCleReturnValueCancel |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 EXPORT_C void CSsmSwpPolicyBase::HandleCleReturnValueCancel() |
|
171 { |
|
172 FUNC_LOG; |
|
173 } |
|
174 |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CSsmSwpPolicyBase::Release |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C void CSsmSwpPolicyBase::Release() |
|
181 { |
|
182 FUNC_LOG; |
|
183 |
|
184 delete this; |
|
185 } |