26
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2010 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
|
|
22 |
#include "iaupdatefwdetailsdialog.h"
|
|
23 |
#include "iaupdatedialogutil.h"
|
|
24 |
#include "iaupdatebasenode.h"
|
|
25 |
#include "iaupdatefwnode.h"
|
|
26 |
#include "iaupdatedebug.h"
|
|
27 |
#include <iaupdate.rsg>
|
|
28 |
|
|
29 |
#include <aknmessagequerydialog.h> // CAknMessageQueryDialog
|
|
30 |
|
|
31 |
#include <StringLoader.h>
|
|
32 |
|
|
33 |
// CONSTANTS
|
|
34 |
const TInt KKiloByte = 1024;
|
|
35 |
const TInt KMegaByte = 1024 * 1024;
|
|
36 |
const TInt KMaxShownInKiloBytes = 10 * KMegaByte;
|
|
37 |
|
|
38 |
_LIT( KSpace, " ");
|
|
39 |
|
|
40 |
|
|
41 |
/*******************************************************************************
|
|
42 |
* class CIAUpdateDetailsDialog
|
|
43 |
*******************************************************************************/
|
|
44 |
|
|
45 |
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
// CIAUpdateDetailsDialog::ShowDialogL
|
|
48 |
//
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
TBool CIAUpdateFwDetailsDialog::ShowDialogL( MIAUpdateFwNode* aFwNode )
|
|
51 |
{
|
|
52 |
CIAUpdateFwDetailsDialog* dialog = CIAUpdateFwDetailsDialog::NewL( aFwNode );
|
|
53 |
CleanupStack::PushL( dialog );
|
|
54 |
|
|
55 |
dialog->ShowDialogL();
|
|
56 |
|
|
57 |
CleanupStack::PopAndDestroy( dialog );
|
|
58 |
|
|
59 |
return ETrue;
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// CIAUpdateFwDetailsDialog::NewL
|
|
65 |
//
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
CIAUpdateFwDetailsDialog* CIAUpdateFwDetailsDialog::NewL( MIAUpdateFwNode* aFwNode )
|
|
68 |
{
|
|
69 |
CIAUpdateFwDetailsDialog* self = new ( ELeave ) CIAUpdateFwDetailsDialog( aFwNode );
|
|
70 |
CleanupStack::PushL( self );
|
|
71 |
self->ConstructL();
|
|
72 |
CleanupStack::Pop( self );
|
|
73 |
|
|
74 |
return self;
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CIAUpdateFwDetailsDialog::CIAUpdateFwDetailsDialog
|
|
80 |
//
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CIAUpdateFwDetailsDialog::CIAUpdateFwDetailsDialog( MIAUpdateFwNode* aFwNode )
|
|
84 |
{
|
|
85 |
iFwNode = aFwNode;
|
|
86 |
}
|
|
87 |
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CIAUpdateFwDetailsDialog::ConstructL
|
|
91 |
//
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CIAUpdateFwDetailsDialog::ConstructL()
|
|
95 |
{
|
|
96 |
TInt size = BufferSize();
|
|
97 |
iBuf = HBufC::NewL( size );
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
// ----------------------------------------------------------------------------
|
|
103 |
// Destructor
|
|
104 |
//
|
|
105 |
// ----------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
CIAUpdateFwDetailsDialog::~CIAUpdateFwDetailsDialog()
|
|
108 |
{
|
|
109 |
delete iBuf;
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// CIAUpdateFwDetailsDialog::BufferSize
|
|
115 |
//
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
TInt CIAUpdateFwDetailsDialog::BufferSize()
|
|
119 |
{
|
|
120 |
const TInt KExtraSize = 512;
|
|
121 |
|
|
122 |
TPtrC ptr1 = iFwNode->Base().Name();
|
|
123 |
TPtrC ptr2 = iFwNode->Base().Description();
|
|
124 |
|
|
125 |
TInt len = ptr1.Length() + ptr2.Length() + KExtraSize;
|
|
126 |
|
|
127 |
return len;
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
// CIAUpdateFwDetailsDialog::ConstructTextL
|
|
133 |
//
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
void CIAUpdateFwDetailsDialog::ConstructTextL()
|
|
137 |
{
|
|
138 |
_LIT(KNewLine, "\n");
|
|
139 |
|
|
140 |
TPtr ptr = iBuf->Des();
|
|
141 |
|
|
142 |
TInt contentSize = iFwNode->Base().ContentSizeL();
|
|
143 |
|
|
144 |
HBufC* hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_APP_NAME );
|
|
145 |
ptr.Append( KOpeningBoldTag );
|
|
146 |
ptr.Append( *hBuf );
|
|
147 |
ptr.Append( KClosingBoldTag );
|
|
148 |
CleanupStack::PopAndDestroy( hBuf );
|
|
149 |
|
|
150 |
HBufC* firmwareHeader = StringLoader::LoadLC(R_IAUPDATE_MAIN_DEVICE_FW);
|
|
151 |
HBufC* firmwarename = HBufC::NewLC( iFwNode->Base().Name().Length() +
|
|
152 |
KSpace.iTypeLength +
|
|
153 |
firmwareHeader->Length() );
|
|
154 |
firmwarename->Des() = iFwNode->Base().Name();
|
|
155 |
firmwarename->Des() += KSpace();
|
|
156 |
firmwarename->Des() += *firmwareHeader;
|
|
157 |
|
|
158 |
ptr.Append( KNewLine );
|
|
159 |
ptr.Append( *firmwarename );
|
|
160 |
CleanupStack::PopAndDestroy( firmwarename );
|
|
161 |
CleanupStack::PopAndDestroy( firmwareHeader );
|
|
162 |
ptr.Append( KNewLine );
|
|
163 |
ptr.Append( KNewLine );
|
|
164 |
|
|
165 |
|
|
166 |
hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_DESCRIPTION );
|
|
167 |
ptr.Append( KOpeningBoldTag );
|
|
168 |
ptr.Append( *hBuf );
|
|
169 |
ptr.Append( KClosingBoldTag );
|
|
170 |
CleanupStack::PopAndDestroy( hBuf );
|
|
171 |
|
|
172 |
|
|
173 |
HBufC* description = StringLoader::LoadLC( R_IAUPDATE_FW_DESCRIPTION );
|
|
174 |
ptr.Append( KNewLine );
|
|
175 |
ptr.Append( *description );
|
|
176 |
ptr.Append( KNewLine );
|
|
177 |
ptr.Append( KNewLine );
|
|
178 |
CleanupStack::PopAndDestroy( description );
|
|
179 |
|
|
180 |
if ( iFwNode->FwVersion1().Length() > 0 )
|
|
181 |
{
|
|
182 |
hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_VERSION );
|
|
183 |
ptr.Append( KOpeningBoldTag );
|
|
184 |
ptr.Append( *hBuf );
|
|
185 |
ptr.Append( KClosingBoldTag );
|
|
186 |
CleanupStack::PopAndDestroy( hBuf );
|
|
187 |
|
|
188 |
ptr.Append( KNewLine );
|
|
189 |
ptr.Append( iFwNode->FwVersion1() );
|
|
190 |
ptr.Append( KNewLine );
|
|
191 |
ptr.Append( KNewLine );
|
|
192 |
}
|
|
193 |
|
|
194 |
|
|
195 |
if( contentSize > 0 && (iFwNode->FwType() == MIAUpdateFwNode::EFotaDp2) )
|
|
196 |
{
|
|
197 |
hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_FILE_SIZE );
|
|
198 |
ptr.Append( KOpeningBoldTag );
|
|
199 |
ptr.Append( *hBuf );
|
|
200 |
ptr.Append( KClosingBoldTag );
|
|
201 |
CleanupStack::PopAndDestroy( hBuf );
|
|
202 |
|
|
203 |
ptr.Append( KNewLine );
|
|
204 |
|
|
205 |
hBuf = FileSizeTextLC( contentSize );
|
|
206 |
|
|
207 |
ptr.Append( *hBuf );
|
|
208 |
CleanupStack::PopAndDestroy( hBuf );
|
|
209 |
}
|
|
210 |
|
|
211 |
}
|
|
212 |
|
|
213 |
|
|
214 |
// -----------------------------------------------------------------------------
|
|
215 |
// CIAUpdateFwDetailsDialog::ShowDialogL
|
|
216 |
//
|
|
217 |
// -----------------------------------------------------------------------------
|
|
218 |
TBool CIAUpdateFwDetailsDialog::ShowDialogL()
|
|
219 |
{
|
|
220 |
ConstructTextL();
|
|
221 |
HBufC* hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_TITLE );
|
|
222 |
IAUpdateDialogUtil::ShowMessageQueryL( *hBuf, *iBuf );
|
|
223 |
CleanupStack::PopAndDestroy( hBuf );
|
|
224 |
return ETrue;
|
|
225 |
}
|
|
226 |
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
// CIAUpdateFwDetailsDialog::FileSizeTextLC
|
|
229 |
//
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
//
|
|
232 |
HBufC* CIAUpdateFwDetailsDialog::FileSizeTextLC( TInt aFileSize )
|
|
233 |
{
|
|
234 |
TInt resourceId = 0;
|
|
235 |
TInt size = 0;
|
|
236 |
|
|
237 |
if ( aFileSize >= KMaxShownInKiloBytes )
|
|
238 |
{
|
|
239 |
resourceId = R_IAUPDATE_DETAILS_DIALOG_SIZE_MEGABYTE;
|
|
240 |
size = aFileSize / KMegaByte;
|
|
241 |
if ( aFileSize % KMegaByte != 0 )
|
|
242 |
{
|
|
243 |
size++;
|
|
244 |
}
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
resourceId = R_IAUPDATE_DETAILS_DIALOG_SIZE_KILOBYTE;
|
|
249 |
size = aFileSize / KKiloByte;
|
|
250 |
if ( aFileSize % KKiloByte != 0 )
|
|
251 |
{
|
|
252 |
size++;
|
|
253 |
}
|
|
254 |
}
|
|
255 |
|
|
256 |
HBufC* sizeAsString = StringLoader::LoadLC( resourceId, size );
|
|
257 |
TPtr ptr = sizeAsString->Des();
|
|
258 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
|
|
259 |
return sizeAsString;
|
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
// End of File
|