|
1 /* |
|
2 * Copyright (c) 2007-2008 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: CIAUpdateSelfUpdateInitOperation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <ncdnode.h> |
|
21 |
|
22 #include "iaupdateselfupdateinitoperation.h" |
|
23 #include "iaupdatenodeimpl.h" |
|
24 #include "iaupdateselfupdaterinitializer.h" |
|
25 |
|
26 #include "iaupdatedebug.h" |
|
27 |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CIAUpdateSelfUpdateInitOperation::NewL |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CIAUpdateSelfUpdateInitOperation* CIAUpdateSelfUpdateInitOperation::NewL( |
|
35 CIAUpdateNode& aNode, |
|
36 MIAUpdateContentOperationObserver& aObserver ) |
|
37 { |
|
38 CIAUpdateSelfUpdateInitOperation* self = |
|
39 CIAUpdateSelfUpdateInitOperation::NewLC( aNode, aObserver ); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CIAUpdateSelfUpdateInitOperation::NewLC |
|
47 // |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CIAUpdateSelfUpdateInitOperation* CIAUpdateSelfUpdateInitOperation::NewLC( |
|
51 CIAUpdateNode& aNode, |
|
52 MIAUpdateContentOperationObserver& aObserver ) |
|
53 { |
|
54 CIAUpdateSelfUpdateInitOperation* self = |
|
55 new( ELeave ) CIAUpdateSelfUpdateInitOperation( aNode, aObserver ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CIAUpdateSelfUpdateInitOperation::CIAUpdateSelfUpdateInitOperation |
|
64 // |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CIAUpdateSelfUpdateInitOperation::CIAUpdateSelfUpdateInitOperation( |
|
68 CIAUpdateNode& aNode, |
|
69 MIAUpdateContentOperationObserver& aObserver ) |
|
70 : CIAUpdateContentOperation( aNode, aObserver ) |
|
71 { |
|
72 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::CIAUpdateSelfUpdateInitOperation"); |
|
73 } |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CIAUpdateSelfUpdateInitOperation::ConstructL |
|
78 // |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CIAUpdateSelfUpdateInitOperation::ConstructL() |
|
82 { |
|
83 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::ConstructL begin"); |
|
84 |
|
85 CIAUpdateContentOperation::ConstructL(); |
|
86 |
|
87 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::ConstructL end"); |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CIAUpdateSelfUpdateInitOperation::~CIAUpdateSelfUpdateInitOperation |
|
93 // |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CIAUpdateSelfUpdateInitOperation::~CIAUpdateSelfUpdateInitOperation() |
|
97 { |
|
98 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::~CIAUpdateSelfUpdateInitOperation begin"); |
|
99 |
|
100 // Notice, that this will also cancel the possible ongoing operation. |
|
101 delete iOperation; |
|
102 |
|
103 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::~CIAUpdateSelfUpdateInitOperation end"); |
|
104 } |
|
105 |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CIAUpdateSelfUpdateInitOperation::SelfUpdateInitComplete |
|
109 // |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CIAUpdateSelfUpdateInitOperation::SelfUpdateInitComplete( TInt aError ) |
|
113 { |
|
114 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::SelfUpdateInitComplete begin"); |
|
115 |
|
116 // Delete operation if it exists. |
|
117 delete iOperation; |
|
118 iOperation = NULL; |
|
119 |
|
120 if ( aError != KErrNone ) |
|
121 { |
|
122 IAUPDATE_TRACE_1("[IAUPDATE] Self update completed with error: %d", aError); |
|
123 |
|
124 // Because an error has occurred, the install operation will not continue |
|
125 // to the end. So, update the purchase history now. |
|
126 TRAP_IGNORE( |
|
127 Node().SetInstallStatusToPurchaseHistoryL( aError, EFalse ) ); |
|
128 } |
|
129 |
|
130 // Parent will handle the rest. |
|
131 OperationComplete( aError ); |
|
132 |
|
133 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::~SelfUpdateInitComplete end"); |
|
134 } |
|
135 |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CIAUpdateSelfUpdateInitOperation::StartOperationL |
|
139 // |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 TBool CIAUpdateSelfUpdateInitOperation::StartOperationL() |
|
143 { |
|
144 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::StartOperationL begin"); |
|
145 |
|
146 // Initialize variables by using the parent. |
|
147 CIAUpdateContentOperation::StartOperationL(); |
|
148 |
|
149 // Start new active object round. |
|
150 // Operation may already exist. If the StartL last time left. |
|
151 if ( !iOperation ) |
|
152 { |
|
153 // Create new operation because old did not exist. |
|
154 // Notice, that casting is safe here, because NewLC function uses |
|
155 // CIAUpdateNode which is given to the constructor and for parent class. |
|
156 // So, the node is CIAUpdateNode even if the parent operation class uses |
|
157 // pointer to node's parent. |
|
158 CIAUpdateNode& node( static_cast< CIAUpdateNode& >( Node() ) ); |
|
159 iOperation = CIAUpdateSelfUpdaterInitializer::NewL( node, *this ); |
|
160 } |
|
161 iOperation->StartL(); |
|
162 |
|
163 SetOperationInUse( ETrue ); |
|
164 |
|
165 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::StartOperationL end"); |
|
166 |
|
167 return ETrue; |
|
168 } |
|
169 |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CIAUpdateSelfUpdateInitOperation::CancelOperation |
|
173 // |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CIAUpdateSelfUpdateInitOperation::CancelOperation() |
|
177 { |
|
178 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::CancelOperation begin"); |
|
179 |
|
180 if ( iOperation ) |
|
181 { |
|
182 // This will also cancel the operation. |
|
183 // Notice, that SelfUpdateInitComplete callback is called |
|
184 // by the operation when cancel is done. Then, the purchase history |
|
185 // is also updated by the KErrCancel value. |
|
186 iOperation->Cancel(); |
|
187 } |
|
188 |
|
189 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSelfUpdateInitOperation::CancelOperation end"); |
|
190 } |