|
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: CIAUpdateInstallOperation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <ncdquery.h> |
|
21 #include <ncdprogress.h> |
|
22 #include <ncdoperation.h> |
|
23 #include <ncdinstalloperation.h> |
|
24 #include <ncdnodeinstall.h> |
|
25 #include <ncdnode.h> |
|
26 |
|
27 |
|
28 #include "iaupdateinstalloperation.h" |
|
29 #include "iaupdatenodeimpl.h" |
|
30 #include "iaupdateutils.h" |
|
31 #include "iaupdatedebug.h" |
|
32 |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CIAUpdateInstallOperation::NewL |
|
36 // |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CIAUpdateInstallOperation* CIAUpdateInstallOperation::NewL( |
|
40 CIAUpdateNode& aNode, |
|
41 MIAUpdateContentOperationObserver& aObserver ) |
|
42 { |
|
43 CIAUpdateInstallOperation* self = |
|
44 CIAUpdateInstallOperation::NewLC( aNode, aObserver ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CIAUpdateInstallOperation::NewLC |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CIAUpdateInstallOperation* CIAUpdateInstallOperation::NewLC( |
|
56 CIAUpdateNode& aNode, |
|
57 MIAUpdateContentOperationObserver& aObserver ) |
|
58 { |
|
59 CIAUpdateInstallOperation* self = |
|
60 new( ELeave ) CIAUpdateInstallOperation( aNode, aObserver ); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CIAUpdateInstallOperation::CIAUpdateInstallOperation |
|
69 // |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CIAUpdateInstallOperation::CIAUpdateInstallOperation( |
|
73 CIAUpdateNode& aNode, |
|
74 MIAUpdateContentOperationObserver& aObserver ) |
|
75 : CIAUpdateNormalContentOperation( aNode, aObserver ) |
|
76 { |
|
77 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::CIAUpdateInstallOperation"); |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CIAUpdateInstallOperation::ConstructL |
|
83 // |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CIAUpdateInstallOperation::ConstructL() |
|
87 { |
|
88 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::ConstructL begin"); |
|
89 |
|
90 CIAUpdateNormalContentOperation::ConstructL(); |
|
91 |
|
92 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::ConstructL end"); |
|
93 } |
|
94 |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CIAUpdateInstallOperation::~CIAUpdateInstallOperation |
|
98 // |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 CIAUpdateInstallOperation::~CIAUpdateInstallOperation() |
|
102 { |
|
103 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::~CIAUpdateInstallOperation begin"); |
|
104 |
|
105 // This will also reset and delete all the necessary data if needed. |
|
106 CancelOperation(); |
|
107 |
|
108 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::~CIAUpdateInstallOperation end"); |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CIAUpdateInstallOperation::InstallProgress |
|
114 // Content install functions |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void CIAUpdateInstallOperation::InstallProgress( |
|
118 MNcdInstallOperation& /*aOperation*/, |
|
119 TNcdProgress aProgress ) |
|
120 { |
|
121 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::InstallProgress() begin"); |
|
122 |
|
123 OperationProgress( aProgress.iProgress, aProgress.iMaxProgress ); |
|
124 |
|
125 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::InstallProgress() end"); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CIAUpdateInstallOperation::QueryReceived |
|
130 // |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CIAUpdateInstallOperation::QueryReceived( |
|
134 MNcdInstallOperation& aOperation, |
|
135 MNcdQuery* aQuery ) |
|
136 { |
|
137 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::QueryReceived() begin"); |
|
138 |
|
139 ContentQueryReceived( aOperation, aQuery ); |
|
140 |
|
141 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::QueryReceived() end"); |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CIAUpdateInstallOperation::OperationComplete |
|
146 // |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CIAUpdateInstallOperation::OperationComplete( |
|
150 MNcdInstallOperation& aOperation, |
|
151 TInt aError ) |
|
152 { |
|
153 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::OperationComplete() begin"); |
|
154 |
|
155 ContentOperationComplete( aOperation, aError ); |
|
156 |
|
157 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::OperationComplete() end"); |
|
158 } |
|
159 |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // CIAUpdateInstallOperation::HandleContentL |
|
163 // |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 MNcdOperation* CIAUpdateInstallOperation::HandleContentL() |
|
167 { |
|
168 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::HandleContentL begin"); |
|
169 |
|
170 MNcdOperation* operation( NULL ); |
|
171 |
|
172 // If node is already installed, then do not install it again. |
|
173 // Notice, that casting is safe here, because NewLC function uses |
|
174 // CIAUpdateNode which is given to the constructor and for parent class. |
|
175 // So, the node is CIAUpdateNode even if the parent operation class uses |
|
176 // pointer to node's parent. |
|
177 CIAUpdateNode& node( static_cast< CIAUpdateNode& >( Node() ) ); |
|
178 if ( !node.IsInstalled() ) |
|
179 { |
|
180 IAUPDATE_TRACE("[IAUPDATE] Create install operation."); |
|
181 operation = InstallL(); |
|
182 } |
|
183 |
|
184 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::HandleContentL end"); |
|
185 |
|
186 return operation; |
|
187 } |
|
188 |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CIAUpdateInstallOperation::InstallL |
|
192 // |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 MNcdOperation* CIAUpdateInstallOperation::InstallL() |
|
196 { |
|
197 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::InstallL() begin"); |
|
198 |
|
199 MNcdOperation* operation( NULL ); |
|
200 |
|
201 MNcdNodeInstall* install( |
|
202 Node().Node().QueryInterfaceLC<MNcdNodeInstall>() ); |
|
203 |
|
204 if( install ) |
|
205 { |
|
206 // Install interface was available. |
|
207 // So, start installing with silent install operation. |
|
208 SwiUI::TInstallOptions options( |
|
209 IAUpdateUtils::SilentInstallOptionsL( |
|
210 Node().Uid(), Node().OwnContentSizeL() ) ); |
|
211 operation = install->SilentInstallL( *this, options ); |
|
212 |
|
213 if( !operation ) |
|
214 { |
|
215 // Could not create the operation for some reason. |
|
216 IAUPDATE_TRACE("[IAUPDATE] ERROR Could not create the operation."); |
|
217 User::Leave( KErrGeneral ); |
|
218 } |
|
219 |
|
220 CleanupStack::PopAndDestroy( install ); |
|
221 } |
|
222 else |
|
223 { |
|
224 IAUPDATE_TRACE("[IAUPDATE] Install interface was not found."); |
|
225 User::Leave( KErrNotFound ); |
|
226 } |
|
227 |
|
228 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateInstallOperation::InstallL() end"); |
|
229 |
|
230 return operation; |
|
231 } |