39
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Restore settings
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <StringLoader.h>
|
|
22 |
#include <filemanagerengine.rsg>
|
|
23 |
#include <AknUtils.h>
|
|
24 |
#include "FileManagerEngine.hrh"
|
|
25 |
#include "CFileManagerEngine.h"
|
|
26 |
#include "CFileManagerRestoreSettings.h"
|
|
27 |
#include "CFileManagerBackupSettings.h"
|
|
28 |
#include "TFileManagerDriveInfo.h"
|
|
29 |
#include "FileManagerPrivateCRKeys.h"
|
|
30 |
#include "FileManagerDebug.h"
|
|
31 |
|
|
32 |
|
|
33 |
// CONSTANTS
|
|
34 |
_LIT( KDateFormat1, "%1" );
|
|
35 |
_LIT( KDateFormat2, "%2" );
|
|
36 |
_LIT( KDateFormat3, "%3" );
|
|
37 |
_LIT( KTimeFormatBefore, " %-B %J:%T" );
|
|
38 |
_LIT( KTimeFormatAfter, " %J:%T %+B" );
|
|
39 |
_LIT( KEmptyChar, " " );
|
|
40 |
const TUint KSecondSeparator = 1;
|
|
41 |
const TUint KThirdSeparator = 2;
|
|
42 |
const TInt KTimeStrMax = 20;
|
|
43 |
_LIT( KSeparator, "\t" );
|
|
44 |
const TInt KSeparatorSpace = 9;
|
|
45 |
_LIT( KIconFormat, "%d" );
|
|
46 |
const TInt KIconIdStrMax = 3;
|
|
47 |
_LIT( KTimeSeparatorPlaceHolder, ":" );
|
|
48 |
const TInt KHourMinSeparator = 1;
|
|
49 |
|
|
50 |
|
|
51 |
// ======== MEMBER FUNCTIONS ========
|
|
52 |
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
// CFileManagerRestoreSettings::CFileManagerRestoreSettings
|
|
55 |
// ----------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
CFileManagerRestoreSettings::CFileManagerRestoreSettings(
|
|
58 |
CFileManagerEngine& aEngine ) :
|
|
59 |
iEngine( aEngine )
|
|
60 |
{
|
|
61 |
FUNC_LOG
|
|
62 |
}
|
|
63 |
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
// CFileManagerRestoreSettings::~CFileManagerRestoreSettings
|
|
66 |
// ----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
CFileManagerRestoreSettings::~CFileManagerRestoreSettings()
|
|
69 |
{
|
|
70 |
FUNC_LOG
|
|
71 |
|
|
72 |
iList.ResetAndDestroy();
|
|
73 |
iList.Close();
|
|
74 |
}
|
|
75 |
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
// CFileManagerRestoreSettings::NewL
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CFileManagerRestoreSettings* CFileManagerRestoreSettings::NewL(
|
|
81 |
CFileManagerEngine& aEngine )
|
|
82 |
{
|
|
83 |
CFileManagerRestoreSettings* self =
|
|
84 |
new ( ELeave ) CFileManagerRestoreSettings(
|
|
85 |
aEngine );
|
|
86 |
CleanupStack::PushL( self );
|
|
87 |
self->ConstructL();
|
|
88 |
CleanupStack::Pop( self );
|
|
89 |
return self;
|
|
90 |
}
|
|
91 |
|
|
92 |
// ----------------------------------------------------------------------------
|
|
93 |
// CFileManagerRestoreSettings::ConstructL
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
void CFileManagerRestoreSettings::ConstructL()
|
|
97 |
{
|
|
98 |
FUNC_LOG
|
|
99 |
|
|
100 |
RefreshL();
|
|
101 |
}
|
|
102 |
|
|
103 |
// ----------------------------------------------------------------------------
|
|
104 |
// CFileManagerRestoreSettings::SetSelection
|
|
105 |
// ----------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
EXPORT_C void CFileManagerRestoreSettings::SetSelection(
|
|
108 |
const TUint64& aSelection )
|
|
109 |
{
|
|
110 |
iSelection = aSelection;
|
|
111 |
}
|
|
112 |
|
|
113 |
// ----------------------------------------------------------------------------
|
|
114 |
// CFileManagerRestoreSettings::RefreshL
|
|
115 |
// ----------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
EXPORT_C void CFileManagerRestoreSettings::RefreshL()
|
|
118 |
{
|
|
119 |
FUNC_LOG
|
|
120 |
|
|
121 |
iList.ResetAndDestroy();
|
|
122 |
|
|
123 |
RArray< TInfo > infoArray;
|
|
124 |
CleanupClosePushL( infoArray );
|
|
125 |
iEngine.GetRestoreInfoArrayL( infoArray );
|
|
126 |
|
|
127 |
TInt count( infoArray.Count() );
|
|
128 |
TUint32 mask( EFileManagerBackupContentFirst);
|
|
129 |
while ( mask <= EFileManagerBackupContentLast )
|
|
130 |
{
|
|
131 |
for ( TInt i( 0 ); i < count; ++i )
|
|
132 |
{
|
|
133 |
TInfo& info( infoArray[ i ] );
|
|
134 |
if ( info.iContent & mask )
|
|
135 |
{
|
|
136 |
CEntry* entry = CreateEntryLC( info );
|
|
137 |
iList.AppendL( entry );
|
|
138 |
CleanupStack::Pop( entry );
|
|
139 |
}
|
|
140 |
}
|
|
141 |
mask <<= 1;
|
|
142 |
}
|
|
143 |
CleanupStack::PopAndDestroy( &infoArray );
|
|
144 |
|
|
145 |
}
|
|
146 |
|
|
147 |
// ----------------------------------------------------------------------------
|
|
148 |
// CFileManagerRestoreSettings::CEntry::MdcaCount
|
|
149 |
// ----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
TInt CFileManagerRestoreSettings::MdcaCount() const
|
|
152 |
{
|
|
153 |
return iList.Count();
|
|
154 |
}
|
|
155 |
|
|
156 |
// ----------------------------------------------------------------------------
|
|
157 |
// CFileManagerRestoreSettings::CEntry::MdcaPoint
|
|
158 |
// ----------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
TPtrC CFileManagerRestoreSettings::MdcaPoint( TInt aIndex ) const
|
|
161 |
{
|
|
162 |
return TPtrC( *( iList[ aIndex ]->iText ) );
|
|
163 |
}
|
|
164 |
|
|
165 |
// ----------------------------------------------------------------------------
|
|
166 |
// CFileManagerRestoreSettings::CEntry::CreateEntryLC
|
|
167 |
// ----------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
CFileManagerRestoreSettings::CEntry*
|
|
170 |
CFileManagerRestoreSettings::CreateEntryLC(
|
|
171 |
const TInfo& aInfo )
|
|
172 |
{
|
|
173 |
TBuf< KIconIdStrMax > iconStr;
|
|
174 |
CEntry* entry = new ( ELeave ) CEntry;
|
|
175 |
CleanupStack::PushL( entry );
|
|
176 |
|
|
177 |
TInt titleId( CFileManagerBackupSettings::ContentToTextId( aInfo.iContent ) );
|
|
178 |
HBufC* title = StringLoader::LoadLC( titleId );
|
|
179 |
HBufC* timeAndDate = DateTimeStringLC( aInfo.iTime );
|
|
180 |
entry->iText = HBufC::NewL(
|
|
181 |
title->Length() + timeAndDate->Length() + KSeparatorSpace );
|
|
182 |
|
|
183 |
// "0\tFirstLabel\tSecondLabel\t0"
|
|
184 |
TPtr ptr( entry->iText->Des() );
|
|
185 |
iconStr.Copy( KIconFormat );
|
|
186 |
iconStr.Format( KIconFormat, EIconCheckBoxOff );
|
|
187 |
ptr.Append( iconStr );
|
|
188 |
ptr.Append( KSeparator );
|
|
189 |
ptr.Append( *title );
|
|
190 |
ptr.Append( KSeparator );
|
|
191 |
ptr.Append( *timeAndDate );
|
|
192 |
ptr.Append( KSeparator );
|
|
193 |
|
|
194 |
TUint32 drvState( 0 );
|
|
195 |
if ( iEngine.DriveState( drvState, aInfo.iDrive ) == KErrNone )
|
|
196 |
{
|
|
197 |
TInt icon( KErrNotFound );
|
|
198 |
if ( drvState & TFileManagerDriveInfo::EDriveUsbMemory )
|
|
199 |
{
|
|
200 |
icon = EIconUsbMemory;
|
|
201 |
}
|
|
202 |
else if ( drvState & TFileManagerDriveInfo::EDriveRemovable )
|
|
203 |
{
|
|
204 |
icon = EIconMemoryCard;
|
|
205 |
}
|
|
206 |
if ( icon >= 0 )
|
|
207 |
{
|
|
208 |
iconStr.Copy( KIconFormat );
|
|
209 |
iconStr.Format( KIconFormat, icon );
|
|
210 |
ptr.Append( iconStr );
|
|
211 |
}
|
|
212 |
}
|
|
213 |
entry->iInfo = aInfo;
|
|
214 |
|
|
215 |
CleanupStack::PopAndDestroy( timeAndDate );
|
|
216 |
CleanupStack::PopAndDestroy( title );
|
|
217 |
return entry;
|
|
218 |
}
|
|
219 |
|
|
220 |
// ----------------------------------------------------------------------------
|
|
221 |
// CFileManagerRestoreSettings::CEntry::~CEntry
|
|
222 |
// ----------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
CFileManagerRestoreSettings::CEntry::~CEntry()
|
|
225 |
{
|
|
226 |
delete iText;
|
|
227 |
}
|
|
228 |
|
|
229 |
// ----------------------------------------------------------------------------
|
|
230 |
// CFileManagerRestoreSettings::GetSelectionL
|
|
231 |
// ----------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void CFileManagerRestoreSettings::GetSelectionL(
|
|
234 |
RArray< TInfo >& aInfoArray ) const
|
|
235 |
{
|
|
236 |
CleanupClosePushL( aInfoArray );
|
|
237 |
aInfoArray.Reset();
|
|
238 |
|
|
239 |
TInt count( iList.Count() );
|
|
240 |
|
|
241 |
for ( TInt i( 0 ); i < count; ++i )
|
|
242 |
{
|
|
243 |
if ( ( ( ( TUint64 ) 1 ) << i ) & iSelection )
|
|
244 |
{
|
|
245 |
aInfoArray.AppendL( iList[ i ]->iInfo );
|
|
246 |
}
|
|
247 |
}
|
|
248 |
CleanupStack::Pop( &aInfoArray );
|
|
249 |
}
|
|
250 |
|
|
251 |
// ----------------------------------------------------------------------------
|
|
252 |
// CFileManagerRestoreSettings::DateTimeStringLC
|
|
253 |
// ----------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
HBufC* CFileManagerRestoreSettings::DateTimeStringLC( const TTime& aTime )
|
|
256 |
{
|
|
257 |
TBuf< KTimeStrMax > dateStr;
|
|
258 |
TBuf< KTimeStrMax > dateStrFormat;
|
|
259 |
|
|
260 |
// Localized date separator form
|
|
261 |
TLocale local;
|
|
262 |
dateStrFormat.Append( KDateFormat1 );
|
|
263 |
dateStrFormat.Append( local.DateSeparator( KSecondSeparator ) );
|
|
264 |
dateStrFormat.Append( KDateFormat2 );
|
|
265 |
dateStrFormat.Append( local.DateSeparator( KThirdSeparator ) );
|
|
266 |
dateStrFormat.Append( KDateFormat3 );
|
|
267 |
aTime.FormatL( dateStr, dateStrFormat );
|
|
268 |
|
|
269 |
TBuf< KTimeStrMax > timeFormatStr;
|
|
270 |
if ( local.AmPmSymbolPosition() == ELocaleBefore )
|
|
271 |
{
|
|
272 |
timeFormatStr.Copy( KTimeFormatBefore );
|
|
273 |
}
|
|
274 |
else
|
|
275 |
{
|
|
276 |
timeFormatStr.Copy( KTimeFormatAfter );
|
|
277 |
}
|
|
278 |
|
|
279 |
TChar timeSeparator( local.TimeSeparator( KHourMinSeparator ) );
|
|
280 |
AknTextUtils::ReplaceCharacters(
|
|
281 |
timeFormatStr, KTimeSeparatorPlaceHolder, timeSeparator );
|
|
282 |
TBuf< KTimeStrMax > timeStr;
|
|
283 |
aTime.FormatL( timeStr, timeFormatStr );
|
|
284 |
|
|
285 |
HBufC* buf = HBufC::NewLC( dateStr.Length() +
|
|
286 |
KEmptyChar().Length() +
|
|
287 |
timeStr.Length() );
|
|
288 |
TPtr ptrBuffer( buf->Des() );
|
|
289 |
ptrBuffer.Append( timeStr );
|
|
290 |
ptrBuffer.Append( KEmptyChar );
|
|
291 |
ptrBuffer.Append( dateStr );
|
|
292 |
|
|
293 |
return buf;
|
|
294 |
}
|
|
295 |
|
|
296 |
// End of File
|