|
1 /* |
|
2 * Copyright (c) 2008-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: Updation via IAD |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "glxiadupdate.h" |
|
22 #include <iaupdate.h> |
|
23 #include <iaupdateparameters.h> |
|
24 #include <iaupdateresult.h> |
|
25 #include <featmgr.h> |
|
26 #include <glxtracer.h> |
|
27 #include <glxlog.h> |
|
28 |
|
29 |
|
30 |
|
31 // CONSTANTS |
|
32 const TUid KIADParamUid = { 0x200009EE }; // Uid of glxgallary.sis |
|
33 _LIT( KIADParamExec, "glx.exe" ); |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // CGlxIadUpdate::NewL |
|
39 // Two-phased constructor. |
|
40 // -------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C CGlxIadUpdate* CGlxIadUpdate::NewL() |
|
43 { |
|
44 TRACER( "CGlxIadUpdate::NewL()" ); |
|
45 CGlxIadUpdate* self = new( ELeave ) CGlxIadUpdate(); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // -------------------------------------------------------------------------- |
|
53 // CGlxIadUpdate::CGlxIadUpdate |
|
54 // C++ default constructor can NOT contain any code, that might leave. |
|
55 // -------------------------------------------------------------------------- |
|
56 // |
|
57 CGlxIadUpdate::CGlxIadUpdate() |
|
58 : iUpdate( NULL ), iParameters( NULL ) |
|
59 { |
|
60 // None |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CGlxIadUpdate::ConstructL |
|
65 // Symbian 2nd phase constructor can leave. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CGlxIadUpdate::ConstructL() |
|
69 { |
|
70 TRACER( "CGlxIadUpdate::ConstructL()" ); |
|
71 |
|
72 if( FeatureManager::FeatureSupported( KFeatureIdIAUpdate ) ) |
|
73 { |
|
74 iUpdate = CIAUpdate::NewL( *this ); |
|
75 iParameters = CIAUpdateParameters::NewL(); |
|
76 } |
|
77 else |
|
78 { |
|
79 GLX_LOG_INFO( "CGlxIadUpdate::ConstructL(), Feature not supported" ); |
|
80 } |
|
81 } |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // CGlxIadUpdate::~CGlxIadUpdate |
|
85 // Destructor |
|
86 // -------------------------------------------------------------------------- |
|
87 // |
|
88 CGlxIadUpdate::~CGlxIadUpdate() |
|
89 { |
|
90 TRACER( "CGlxIadUpdate::~CGlxIadUpdate()" ); |
|
91 ReleaseIADUpdate(); |
|
92 } |
|
93 |
|
94 // -------------------------------------------------------------------------- |
|
95 // CGlxIadUpdate::StartL |
|
96 // Starts update process. |
|
97 // -------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C void CGlxIadUpdate::StartL() |
|
100 { |
|
101 TRACER( "CGlxIadUpdate::StartL()" ); |
|
102 |
|
103 if( iUpdate && iParameters ) |
|
104 { |
|
105 iParameters->SetUid( KIADParamUid ); |
|
106 // We want VC to be started after update is finished |
|
107 iParameters->SetCommandLineExecutableL( KIADParamExec ); |
|
108 iParameters->SetShowProgress( EFalse ); |
|
109 |
|
110 // Check the updates |
|
111 iUpdate->CheckUpdates( *iParameters ); |
|
112 } |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CGlxIadUpdate::CheckUpdatesComplete |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CGlxIadUpdate::CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates ) |
|
120 { |
|
121 TRACER( "CGlxIadUpdate::CheckUpdatesComplete()" ); |
|
122 GLX_LOG_INFO2("CGlxIadUpdate::CheckUpdatesComplete(), aErrorCode: %d, aAvailableUpdates: %d",aErrorCode, aAvailableUpdates ); |
|
123 if ( aErrorCode == KErrNone ) |
|
124 { |
|
125 if ( aAvailableUpdates > 0 ) |
|
126 { |
|
127 // There were some updates available. |
|
128 iUpdate->UpdateQuery(); |
|
129 } |
|
130 else |
|
131 { |
|
132 // No updates available. |
|
133 ReleaseIADUpdate(); |
|
134 } |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CGlxIadUpdate::UpdateComplete |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CGlxIadUpdate::UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResult ) |
|
143 { |
|
144 TRACER( "CGlxIadUpdate::UpdateComplete()" ); |
|
145 GLX_LOG_INFO2("CGlxIadUpdate::UpdateComplete(), aErrorCode: %d, SuccessCount: %d",aErrorCode, aResult->SuccessCount()); |
|
146 if ( aErrorCode == KErrNone ) |
|
147 { |
|
148 // The update process that the user started from IAUpdate UI is now completed. |
|
149 // If the client application itself was updated in the update process, this callback |
|
150 // is never called, since the client is not running anymore. |
|
151 GLX_LOG_INFO1("UpdateComplete(), SuccessCount: %d", aResult->SuccessCount()); |
|
152 } |
|
153 |
|
154 delete aResult; // Ownership was transferred, so this must be deleted by the client |
|
155 |
|
156 // We do not need the client-server session anymore |
|
157 ReleaseIADUpdate(); |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CGlxIadUpdate::UpdateQueryComplete |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CGlxIadUpdate::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow ) |
|
165 { |
|
166 TRACER( "CGlxIadUpdate::UpdateQueryComplete()" ); |
|
167 GLX_LOG_INFO2("CGlxIadUpdate::UpdateComplete(), aErrorCode: %d, aUpdateNow: %d",aErrorCode, aUpdateNow); |
|
168 if ( aErrorCode == KErrNone ) |
|
169 { |
|
170 if ( aUpdateNow ) |
|
171 { |
|
172 // User choosed to update now, so let's launch the IAUpdate UI. |
|
173 iUpdate->ShowUpdates( *iParameters ); |
|
174 } |
|
175 else |
|
176 { |
|
177 // The answer was 'Later'. |
|
178 ReleaseIADUpdate(); |
|
179 } |
|
180 } |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CGlxIadUpdate::ReleaseIADUpdate |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CGlxIadUpdate::ReleaseIADUpdate() |
|
188 { |
|
189 TRACER( "CGlxIadUpdate::ReleaseIADUpdate()" ); |
|
190 |
|
191 delete iUpdate; |
|
192 iUpdate = NULL; |
|
193 |
|
194 delete iParameters; |
|
195 iParameters = NULL; |
|
196 } |
|
197 |
|
198 // End of File |
|
199 |