author | Tom Cosgrove <tom.cosgrove@nokia.com> |
Fri, 28 May 2010 16:29:07 +0100 | |
changeset 30 | 8aab599e3476 |
parent 6 | 0173bcd7697c |
child 19 | 4a8fed1c0ef6 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// USB Mass Storage Application - also used as an improvised boot loader mechanism |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
||
19 |
||
20 |
/** |
|
21 |
@file |
|
22 |
*/ |
|
23 |
||
24 |
#include <e32cons.h> |
|
25 |
#include <f32file.h> |
|
26 |
||
27 |
#include "rusbotgsession.h" |
|
28 |
||
29 |
#include "usbtypes.h" |
|
30 |
#include "mdrivedisplay.h" |
|
31 |
#include "cdisplay.h" |
|
32 |
||
33 |
// Display positions and test constants |
|
34 |
// Number of attached devices |
|
35 |
static const TInt KRow_DevicesNumber = 13; |
|
36 |
_LIT(KMsg_DevicesAttached, "USB Devices Attached = %d"); |
|
37 |
||
38 |
// Device Map |
|
39 |
static const TInt KStartRow_DeviceMap = KRow_DevicesNumber + 2; |
|
40 |
static const TInt KMaxRows_DeviceMap = 4; |
|
41 |
_LIT(KMsg_DeviceMap_DriveList, "%d: "); // [drive index] |
|
42 |
_LIT(KMsg_DeviceMap_DriveLunEntry, "%c "); // [drive letter] |
|
43 |
||
44 |
||
45 |
// Drive Map |
|
46 |
static const TInt KStartRow_DriveMap = KStartRow_DeviceMap + KMaxRows_DeviceMap; |
|
47 |
static const TInt KMaxRows_DriveMap = 4; |
|
48 |
_LIT(KMsg_DriveMap_EntryLetter, "%c token = %d"); // [drive letter] [token] |
|
49 |
_LIT(KDbgMsg_DriveMap_EntryLetter, "*** %c token = %d"); // [drive letter] [token] |
|
50 |
||
51 |
// System Status |
|
52 |
static const TInt KStartRow_UpTime = 28; |
|
53 |
_LIT(KMsg_UpTime, "up time : %dh:%dm:%ds "); // use trailing space to overwrite any leftover chars in line |
|
54 |
||
55 |
static const TInt KStartRow_MemoryFree = 29; |
|
56 |
_LIT(KMsg_MemoryFree, "mem (bytes) : 0x%X"); |
|
57 |
||
58 |
// User Keys |
|
59 |
static const TInt KStartRow_UserKeys = 25; |
|
60 |
_LIT(KMsgUser1Keys, "[Esc]=Quit [A-Z]=DriveInfo"); |
|
61 |
_LIT(KMsgUser2Keys, "[F5]=Hub update"); |
|
62 |
||
63 |
||
64 |
// Scroll Window status |
|
65 |
_LIT(KScrollWindowStatus, "Page %d of %d"); |
|
66 |
||
67 |
// Available drives |
|
68 |
static const TInt KStartRow_AvailableDrives = 1; |
|
69 |
_LIT(KAvailDriveMsg, "Drives: "); |
|
70 |
||
71 |
_LIT(KDriveAtts,"DriveList %c: %02x "); |
|
72 |
||
73 |
// Drive info |
|
74 |
static const TInt KStartRow_MsgWindow = 3; |
|
75 |
static const TInt KStartRow_DriveInfo = KStartRow_MsgWindow; |
|
76 |
||
77 |
// **************************************************************************** |
|
78 |
||
79 |
||
80 |
CScrollWindow* CScrollWindow::NewL(CConsoleBase& aConsole) |
|
81 |
{ |
|
82 |
CScrollWindow* r = new (ELeave) CScrollWindow(aConsole); |
|
83 |
CleanupStack::PushL(r); |
|
84 |
r->ConstructL(); |
|
85 |
CleanupStack::Pop(r); |
|
86 |
return r; |
|
87 |
} |
|
88 |
||
89 |
||
90 |
void CScrollWindow::ConstructL() |
|
91 |
{ |
|
92 |
||
93 |
} |
|
94 |
||
95 |
||
96 |
CScrollWindow::CScrollWindow(CConsoleBase& aConsole) |
|
97 |
: iConsole(aConsole) |
|
98 |
{ |
|
99 |
} |
|
100 |
||
101 |
CScrollWindow::~CScrollWindow() |
|
102 |
{ |
|
103 |
iLineArray.Close(); |
|
104 |
} |
|
105 |
||
106 |
void CScrollWindow::Reset() |
|
107 |
{ |
|
108 |
iPage = 0; |
|
109 |
iLineArray.Reset(); |
|
110 |
} |
|
111 |
||
112 |
||
113 |
void CScrollWindow::AppendL(const TDesC& aLine) |
|
114 |
{ |
|
115 |
iTmpLine.Zero(); |
|
116 |
iLineArray.AppendL(iTmpLine); |
|
117 |
TInt last = iLineArray.Count() - 1; |
|
118 |
iLineArray[last].Copy(aLine); |
|
119 |
} |
|
120 |
||
121 |
||
122 |
TLine* CScrollWindow::NewLineL() |
|
123 |
{ |
|
124 |
iTmpLine.Zero(); |
|
125 |
iLineArray.AppendL(iTmpLine); |
|
126 |
TInt last = iLineArray.Count() - 1; |
|
127 |
return &iLineArray[last]; |
|
128 |
} |
|
129 |
||
130 |
||
131 |
void CScrollWindow::Update() |
|
132 |
{ |
|
133 |
TInt line = iPage * KPageLength; |
|
134 |
||
135 |
TInt row = KStartRow_DriveInfo; |
|
136 |
do |
|
137 |
{ |
|
138 |
iConsole.SetPos(0, row + line%KPageLength); |
|
139 |
if (line < iLineArray.Count()) |
|
140 |
{ |
|
141 |
iConsole.Printf(iLineArray[line]); |
|
142 |
} |
|
143 |
iConsole.ClearToEndOfLine(); |
|
144 |
line++; |
|
145 |
} |
|
146 |
while (((line-1)%KPageLength) != (KPageLength - 1)); |
|
147 |
iConsole.SetPos(0, KStartRow_DriveInfo + KPageLength); |
|
148 |
iConsole.Printf(KScrollWindowStatus, iPage + 1, iLineArray.Count()/KPageLength + 1); |
|
149 |
} |
|
150 |
||
151 |
void CScrollWindow::PageInc() |
|
152 |
{ |
|
153 |
TInt lastPage = iLineArray.Count()/KPageLength; |
|
154 |
if (iPage == lastPage) |
|
155 |
{ |
|
156 |
iPage = 0; |
|
157 |
} |
|
158 |
else |
|
159 |
{ |
|
160 |
iPage++; |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
||
165 |
void CScrollWindow::PageDec() |
|
166 |
{ |
|
167 |
if (iPage == 0) |
|
168 |
{ |
|
169 |
TInt lastPage = iLineArray.Count()/KPageLength; |
|
170 |
iPage = lastPage; |
|
171 |
} |
|
172 |
else |
|
173 |
{ |
|
174 |
iPage--; |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
||
179 |
||
180 |
CDisplay* CDisplay::NewLC(RFs& aFs, CConsoleBase& aConsole) |
|
181 |
{ |
|
182 |
CDisplay* r = new (ELeave) CDisplay(aFs, aConsole); |
|
183 |
CleanupStack::PushL(r); |
|
184 |
r->ConstructL(); |
|
185 |
return r; |
|
186 |
} |
|
187 |
||
188 |
||
189 |
void CDisplay::ConstructL() |
|
190 |
{ |
|
191 |
iScrollWindow = CScrollWindow::NewL(iConsole); |
|
192 |
} |
|
193 |
||
194 |
||
195 |
CDisplay::CDisplay(RFs& aFs, CConsoleBase& aConsole) |
|
196 |
: iFs(aFs), |
|
197 |
iConsole(aConsole) |
|
198 |
{ |
|
199 |
iConsole.ClearScreen(); |
|
200 |
} |
|
201 |
||
202 |
||
203 |
CDisplay::~CDisplay() |
|
204 |
{ |
|
205 |
delete iScrollWindow; |
|
206 |
} |
|
207 |
||
208 |
||
209 |
void CDisplay::Menu() |
|
210 |
{ |
|
211 |
iConsole.SetPos(0, KStartRow_UserKeys); |
|
212 |
iConsole.Printf(KMsgUser1Keys); |
|
213 |
iConsole.SetPos(0, KStartRow_UserKeys + 1); |
|
214 |
iConsole.Printf(KMsgUser2Keys); |
|
215 |
iCursorPos = iConsole.CursorPos(); |
|
216 |
} |
|
217 |
||
218 |
||
219 |
void CDisplay::DriveListL() const |
|
220 |
{ |
|
221 |
TDriveList drivelist; |
|
222 |
TRAPD(err, iFs.DriveList(drivelist)); |
|
223 |
if (err) |
|
224 |
{ |
|
225 |
return; |
|
226 |
} |
|
227 |
// A TDriveList (the list of available drives), is an array of |
|
228 |
// 26 bytes. Each byte with a non zero value signifies that the |
|
229 |
// corresponding drive is available. |
|
230 |
TBuf<KDisplayWidth> iLineBuffer; |
|
231 |
iLineBuffer = KAvailDriveMsg; |
|
232 |
TChar driveLetter; |
|
233 |
||
234 |
for (TInt driveNumber = EDriveA; driveNumber <= EDriveZ;driveNumber++) |
|
235 |
{ |
|
236 |
if (drivelist[driveNumber]) // if drive-list entry non-zero, drive is available |
|
237 |
{ |
|
238 |
// overflow check |
|
239 |
if (iLineBuffer.Length() == iLineBuffer.MaxLength()) |
|
240 |
{ |
|
241 |
iLineBuffer[iLineBuffer.MaxLength() - 1] = '>'; |
|
242 |
break; |
|
243 |
} |
|
244 |
||
245 |
User::LeaveIfError(iFs.DriveToChar(driveNumber,driveLetter)); |
|
246 |
||
247 |
// The following line prints the drive letter followed by the hex value |
|
248 |
// of the integer indicating that drive's attributes |
|
249 |
RDebug::Print(KDriveAtts,TUint(driveLetter), drivelist[driveNumber]); |
|
250 |
iLineBuffer.Append(driveLetter); |
|
251 |
||
252 |
} |
|
253 |
} |
|
254 |
||
255 |
iConsole.SetPos(0, KStartRow_AvailableDrives); |
|
256 |
iConsole.Printf(iLineBuffer); |
|
257 |
iConsole.ClearToEndOfLine(); |
|
258 |
CursorHome(); |
|
259 |
} |
|
260 |
||
261 |
||
262 |
void CDisplay::DevicesNumber(TInt aDevicesNumber) const |
|
263 |
{ |
|
264 |
iConsole.SetPos(0, KRow_DevicesNumber); |
|
265 |
iConsole.Printf(KMsg_DevicesAttached, aDevicesNumber); |
|
266 |
iConsole.ClearToEndOfLine(); |
|
267 |
} |
|
268 |
||
269 |
||
270 |
void CDisplay::DriveMapL(const TDriveMap& aDriveMap) const |
|
271 |
{ |
|
272 |
TChar letter; |
|
273 |
||
274 |
TInt i = 0; |
|
275 |
||
276 |
// Output to debug port |
|
277 |
for (; i < aDriveMap.Count(); i++) |
|
278 |
{ |
|
279 |
TToken token = aDriveMap[i]; |
|
280 |
if (token) |
|
281 |
{ |
|
282 |
User::LeaveIfError(iFs.DriveToChar(i, letter)); |
|
283 |
RDebug::Print(KDbgMsg_DriveMap_EntryLetter, TUint(letter), token); |
|
284 |
} |
|
285 |
} |
|
286 |
||
287 |
// Output to console |
|
288 |
TInt row = KStartRow_DriveMap; |
|
289 |
for (i = (aDriveMap.Count() -1); i >= 0 && row < (KStartRow_DriveMap + KMaxRows_DriveMap); i--) |
|
290 |
{ |
|
291 |
TToken token = aDriveMap[i]; |
|
292 |
if (token) |
|
293 |
{ |
|
294 |
User::LeaveIfError(iFs.DriveToChar(i, letter)); |
|
295 |
iConsole.SetPos(0, row); |
|
296 |
iConsole.Printf(KMsg_DriveMap_EntryLetter, TUint(letter), token); |
|
297 |
iConsole.ClearToEndOfLine(); |
|
298 |
row++; |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
for (; row < KStartRow_DriveMap + KMaxRows_DriveMap; row++) |
|
303 |
{ |
|
304 |
iConsole.SetPos(0, row); |
|
305 |
iConsole.ClearToEndOfLine(); |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
||
310 |
void CDisplay::DeviceMapL(TInt aRow, TInt deviceIndex, const TDeviceMap& aDeviceMap) const |
|
311 |
{ |
|
312 |
TChar letter; |
|
313 |
TInt drive; |
|
314 |
||
315 |
// Output to debug port |
|
316 |
RDebug::Printf("*** deviceIndex = %d", deviceIndex); |
|
317 |
for (TInt lunIndex = 0; lunIndex < 16; lunIndex++) |
|
318 |
{ |
|
319 |
drive = aDeviceMap[lunIndex]; |
|
320 |
||
321 |
if (drive == 0) |
|
322 |
break; |
|
323 |
||
324 |
User::LeaveIfError(iFs.DriveToChar(drive, letter)); |
|
325 |
RDebug::Printf("*** drive=%d %c", drive, TUint(letter)); |
|
326 |
} |
|
327 |
||
328 |
// Output to console |
|
329 |
if (aRow >= KMaxRows_DeviceMap) |
|
330 |
{ |
|
331 |
return; |
|
332 |
} |
|
333 |
RDebug::Printf("-----> Device MAP %x", deviceIndex); |
|
334 |
TInt row = KStartRow_DeviceMap + aRow; |
|
335 |
iConsole.SetPos(0, row); |
|
336 |
iConsole.Printf(KMsg_DeviceMap_DriveList, deviceIndex); |
|
337 |
||
338 |
for (TInt lunIndex = 0; lunIndex < 16; lunIndex++) |
|
339 |
{ |
|
340 |
drive = aDeviceMap[lunIndex]; |
|
341 |
||
342 |
if (drive == 0) |
|
343 |
break; |
|
344 |
||
345 |
User::LeaveIfError(iFs.DriveToChar(drive, letter)); |
|
346 |
iConsole.Printf(KMsg_DeviceMap_DriveLunEntry, TUint(letter)); |
|
347 |
iConsole.ClearToEndOfLine(); |
|
348 |
} |
|
349 |
} |
|
350 |
||
351 |
||
352 |
void CDisplay::DeviceMapClear(TInt aRow) const |
|
353 |
{ |
|
354 |
TInt row = KStartRow_DeviceMap; |
|
355 |
||
356 |
if (aRow > KMaxRows_DeviceMap) |
|
357 |
return; |
|
358 |
||
359 |
for (row = KStartRow_DeviceMap + aRow; row < KStartRow_DeviceMap + KMaxRows_DeviceMap; row++) |
|
360 |
{ |
|
361 |
iConsole.SetPos(0, row); |
|
362 |
iConsole.ClearToEndOfLine(); |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
||
367 |
void CDisplay::GetDriveInfoL(TChar aChar) |
|
368 |
{ |
|
369 |
iScrollWindow->Reset(); |
|
370 |
||
371 |
TDriveInfo driveInfo; |
|
372 |
||
373 |
TInt driveNumber; |
|
374 |
User::LeaveIfError(iFs.CharToDrive(aChar, driveNumber)); |
|
375 |
||
376 |
TLine* line; |
|
377 |
line = iScrollWindow->NewLineL(); |
|
378 |
_LIT(KDrive,"Drive=%d %C"); |
|
379 |
line->Format(KDrive, driveNumber, TInt(aChar.GetUpperCase())); |
|
380 |
||
381 |
iFs.Drive(driveInfo, driveNumber); |
|
382 |
if (driveInfo.iDriveAtt == KDriveAbsent) |
|
383 |
{ |
|
384 |
_LIT(KTxt_MappingDriveError, "Drive absent !"); |
|
385 |
iScrollWindow->AppendL(KTxt_MappingDriveError); |
|
386 |
return; |
|
387 |
} |
|
388 |
||
389 |
FormatDriveInfoL(driveInfo); |
|
390 |
||
391 |
TVolumeInfo volumeInfo; |
|
392 |
||
393 |
TInt err = iFs.Volume(volumeInfo, driveNumber); |
|
394 |
if (err != KErrNotReady) |
|
395 |
// Volume() returns KErrNotReady if no volume present. |
|
396 |
// In this case, check next drive number |
|
397 |
{ |
|
398 |
FormatVolumeInfoL(volumeInfo); |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
||
403 |
void CDisplay::DriveInfo() |
|
404 |
{ |
|
405 |
iScrollWindow->Update(); |
|
406 |
CursorHome(); |
|
407 |
} |
|
408 |
||
409 |
void CDisplay::FormatDriveInfoL(const TDriveInfo& aDriveInfo) |
|
410 |
{ |
|
411 |
// Append battery, media and drive information to aBuffer |
|
412 |
// Define descriptor constants using the _LIT macro |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
_LIT(KDriveInfo1, "iType=%02x %02x iDriveAtt=%04x"); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
_LIT(KDriveInfo2, "iMediaAtt=%02x"); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
_LIT(KConnectionBusInternal,"Connection Bus Internal"); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
_LIT(KConnectionBusUsb,"Connection Bus USB"); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
417 |
_LIT(KConnectionBusUnknown,"Connection Bus Unknown"); |
0 | 418 |
_LIT(KNotPresent,"No media present"); |
419 |
_LIT(KFloppy,"Media is floppy disk"); |
|
420 |
_LIT(KHard,"Media is hard disk"); |
|
421 |
_LIT(KCDROM,"Media is CD-ROM"); |
|
422 |
_LIT(KRam,"Media is RAM"); |
|
423 |
_LIT(KFlash,"Media is flash"); |
|
424 |
_LIT(KRom,"Media is ROM"); |
|
425 |
_LIT(KRemote,"Media is remote"); |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
426 |
_LIT(KExternal,"Media is external"); |
0 | 427 |
_LIT(KNANDFlash,"Media is NAND flash"); |
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
428 |
_LIT(KUnknown,"Media unknown"); |
0 | 429 |
_LIT(KDriveAtts,"Drive attributes:"); |
430 |
_LIT(KLocal," local"); |
|
431 |
_LIT(KROMDrive," ROM"); |
|
432 |
_LIT(KRedirected," redirected"); |
|
433 |
_LIT(KSubstituted," substituted"); |
|
434 |
_LIT(KInternal," internal"); |
|
435 |
_LIT(KRemovable," removable"); |
|
436 |
_LIT(KMediaAtts,"Media attributes:"); |
|
437 |
_LIT(KDynamic," dynamic"); |
|
438 |
_LIT(KDual," dual-density"); |
|
439 |
_LIT(KFormattable," formattable"); |
|
440 |
_LIT(KLockable," lockable"); |
|
441 |
_LIT(KLocked," locked"); |
|
442 |
_LIT(KHasPassword," has password"); |
|
443 |
_LIT(KWriteProtected," write-protected"); |
|
444 |
||
445 |
TLine* line; |
|
446 |
line = iScrollWindow->NewLineL(); |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
line->Format(KDriveInfo1, TInt(aDriveInfo.iType), TInt(aDriveInfo.iConnectionBusType), TInt(aDriveInfo.iDriveAtt)); |
0 | 448 |
|
449 |
line = iScrollWindow->NewLineL(); |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
450 |
line->Format(KDriveInfo2, TInt(aDriveInfo.iMediaAtt)); |
0 | 451 |
|
452 |
line = iScrollWindow->NewLineL(); |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
453 |
switch (aDriveInfo.iConnectionBusType) |
0 | 454 |
{ |
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
455 |
case EConnectionBusInternal: |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
456 |
line->Append(KConnectionBusInternal); |
0 | 457 |
break; |
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
458 |
case EConnectionBusUsb: |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
459 |
line->Append(KConnectionBusUsb); |
0 | 460 |
break; |
461 |
default: |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
462 |
line->Append(KConnectionBusUnknown); |
0 | 463 |
} |
464 |
||
465 |
line = iScrollWindow->NewLineL(); |
|
466 |
switch (aDriveInfo.iType) |
|
467 |
{ |
|
468 |
case EMediaNotPresent: |
|
469 |
line->Append(KNotPresent); |
|
470 |
break; |
|
471 |
case EMediaFloppy: |
|
472 |
line->Append(KFloppy); |
|
473 |
break; |
|
474 |
case EMediaHardDisk: |
|
475 |
line->Append(KHard); |
|
476 |
break; |
|
477 |
case EMediaCdRom: |
|
478 |
line->Append(KCDROM); |
|
479 |
break; |
|
480 |
case EMediaRam: |
|
481 |
line->Append(KRam); |
|
482 |
break; |
|
483 |
case EMediaFlash: |
|
484 |
line->Append(KFlash); |
|
485 |
break; |
|
486 |
case EMediaRom: |
|
487 |
line->Append(KRom); |
|
488 |
break; |
|
489 |
case EMediaRemote: |
|
490 |
line->Append(KRemote); |
|
491 |
break; |
|
492 |
case EMediaNANDFlash: |
|
493 |
line->Append(KNANDFlash); |
|
494 |
break; |
|
495 |
default: |
|
496 |
line->Append(KUnknown); |
|
497 |
} |
|
498 |
||
499 |
// Drive Attributes |
|
500 |
line = iScrollWindow->NewLineL(); |
|
501 |
line->Append(KDriveAtts); |
|
502 |
if (aDriveInfo.iDriveAtt & KDriveAttLocal) |
|
503 |
{ |
|
504 |
line = iScrollWindow->NewLineL(); |
|
505 |
line->Append(KLocal); |
|
506 |
} |
|
507 |
if (aDriveInfo.iDriveAtt & KDriveAttRom) |
|
508 |
{ |
|
509 |
line = iScrollWindow->NewLineL(); |
|
510 |
line->Append(KROMDrive); |
|
511 |
} |
|
512 |
if (aDriveInfo.iDriveAtt & KDriveAttRedirected) |
|
513 |
{ |
|
514 |
line = iScrollWindow->NewLineL(); |
|
515 |
line->Append(KRedirected); |
|
516 |
} |
|
517 |
if (aDriveInfo.iDriveAtt & KDriveAttSubsted) |
|
518 |
{ |
|
519 |
line = iScrollWindow->NewLineL(); |
|
520 |
line->Append(KSubstituted); |
|
521 |
} |
|
522 |
if (aDriveInfo.iDriveAtt & KDriveAttInternal) |
|
523 |
{ |
|
524 |
line = iScrollWindow->NewLineL(); |
|
525 |
line->Append(KInternal); |
|
526 |
} |
|
527 |
if (aDriveInfo.iDriveAtt & KDriveAttRemovable) |
|
528 |
{ |
|
529 |
line = iScrollWindow->NewLineL(); |
|
530 |
line->Append(KRemovable); |
|
531 |
} |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
532 |
if (aDriveInfo.iDriveAtt & KDriveAttExternal) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
533 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
534 |
line = iScrollWindow->NewLineL(); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
535 |
line->Append(KExternal); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
536 |
} |
0 | 537 |
|
538 |
// Media Attributes |
|
539 |
line = iScrollWindow->NewLineL(); |
|
540 |
line->Append(KMediaAtts); |
|
541 |
if (aDriveInfo.iMediaAtt & KMediaAttVariableSize) |
|
542 |
{ |
|
543 |
line = iScrollWindow->NewLineL(); |
|
544 |
line->Append(KDynamic); |
|
545 |
} |
|
546 |
if (aDriveInfo.iMediaAtt & KMediaAttDualDensity) |
|
547 |
{ |
|
548 |
line = iScrollWindow->NewLineL(); |
|
549 |
line->Append(KDual); |
|
550 |
} |
|
551 |
if (aDriveInfo.iMediaAtt & KMediaAttFormattable) |
|
552 |
{ |
|
553 |
line = iScrollWindow->NewLineL(); |
|
554 |
line->Append(KFormattable); |
|
555 |
} |
|
556 |
if (aDriveInfo.iMediaAtt & KMediaAttWriteProtected) |
|
557 |
{ |
|
558 |
line = iScrollWindow->NewLineL(); |
|
559 |
line->Append(KWriteProtected); |
|
560 |
} |
|
561 |
if (aDriveInfo.iMediaAtt & KMediaAttLockable) |
|
562 |
{ |
|
563 |
line = iScrollWindow->NewLineL(); |
|
564 |
line->Append(KLockable); |
|
565 |
} |
|
566 |
||
567 |
if (aDriveInfo.iMediaAtt & KMediaAttLocked) |
|
568 |
{ |
|
569 |
line = iScrollWindow->NewLineL(); |
|
570 |
line->Append(KLocked); |
|
571 |
} |
|
572 |
if (aDriveInfo.iMediaAtt & KMediaAttHasPassword) |
|
573 |
{ |
|
574 |
line = iScrollWindow->NewLineL(); |
|
575 |
line->Append(KHasPassword); |
|
576 |
} |
|
577 |
} |
|
578 |
||
579 |
void CDisplay::FormatVolumeInfoL(const TVolumeInfo& aVolumeInfo) |
|
580 |
{ |
|
581 |
// Append volume information to line |
|
582 |
_LIT(KUID, "Unique ID: 0x%08X"); |
|
583 |
_LIT(KSize, "Size: 0x%LX bytes"); |
|
584 |
_LIT(KFree, "Free space: 0x%LX bytes"); |
|
585 |
_LIT(KVolName, "Volume name: %S"); |
|
586 |
TLine* line; |
|
587 |
line = iScrollWindow->NewLineL(); |
|
588 |
line->Format(KUID, aVolumeInfo.iUniqueID); |
|
589 |
line = iScrollWindow->NewLineL(); |
|
590 |
line->Format(KSize, aVolumeInfo.iSize); |
|
591 |
line = iScrollWindow->NewLineL(); |
|
592 |
line->Format(KFree, aVolumeInfo.iFree); |
|
593 |
line = iScrollWindow->NewLineL(); |
|
594 |
line->Format(KVolName, &aVolumeInfo.iName); |
|
595 |
||
596 |
} |
|
597 |
||
598 |
||
599 |
void CDisplay::UpTime(TUint aUpTime) const |
|
600 |
{ |
|
601 |
TUint totalMins = aUpTime/60; |
|
602 |
TUint totalHrs = totalMins/60; |
|
603 |
iConsole.SetPos(0, KStartRow_UpTime); |
|
604 |
iConsole.Printf(KMsg_UpTime, totalHrs, totalMins%60, aUpTime%60); |
|
605 |
CursorHome(); |
|
606 |
} |
|
607 |
||
608 |
void CDisplay::MemoryFree(TInt aBytes) const |
|
609 |
{ |
|
610 |
iConsole.SetPos(0, KStartRow_MemoryFree); |
|
611 |
iConsole.Printf(KMsg_MemoryFree, aBytes); |
|
612 |
CursorHome(); |
|
613 |
} |
|
614 |
||
615 |
||
616 |
////////////////////////////////////////////////////////////////////////////// |
|
617 |
// |
|
618 |
// CMessageKeyProcessor |
|
619 |
// |
|
620 |
////////////////////////////////////////////////////////////////////////////// |
|
621 |
CMessageKeyProcessor::CMessageKeyProcessor(CDisplay& aDisplay, RUsbOtgSession& aUsbOtgSession) |
|
622 |
: CActive(CActive::EPriorityUserInput), |
|
623 |
iDisplay(aDisplay), |
|
624 |
iUsbOtgSession(aUsbOtgSession) |
|
625 |
{ |
|
626 |
} |
|
627 |
||
628 |
CMessageKeyProcessor* CMessageKeyProcessor::NewLC(CDisplay& aDisplay, RUsbOtgSession& aUsbOtgSession) |
|
629 |
{ |
|
630 |
CMessageKeyProcessor* self=new (ELeave) CMessageKeyProcessor(aDisplay, aUsbOtgSession); |
|
631 |
CleanupStack::PushL(self); |
|
632 |
self->ConstructL(); |
|
633 |
return self; |
|
634 |
} |
|
635 |
||
636 |
||
637 |
void CMessageKeyProcessor::ConstructL() |
|
638 |
{ |
|
639 |
// Add to active scheduler |
|
640 |
CActiveScheduler::Add(this); |
|
641 |
RequestCharacter(); |
|
642 |
} |
|
643 |
||
644 |
||
645 |
CMessageKeyProcessor::~CMessageKeyProcessor() |
|
646 |
{ |
|
647 |
// Make sure we're cancelled |
|
648 |
Cancel(); |
|
649 |
} |
|
650 |
||
651 |
void CMessageKeyProcessor::DoCancel() |
|
652 |
{ |
|
653 |
iDisplay.ReadCancel(); |
|
654 |
} |
|
655 |
||
656 |
void CMessageKeyProcessor::RunL() |
|
657 |
{ |
|
658 |
// Handle completed request |
|
659 |
ProcessKeyPressL(iDisplay.KeyCode()); |
|
660 |
} |
|
661 |
||
662 |
void CMessageKeyProcessor::RequestCharacter() |
|
663 |
{ |
|
664 |
// A request is issued to the CConsoleBase to accept a |
|
665 |
// character from the keyboard. |
|
666 |
iDisplay.Read(iStatus); |
|
667 |
SetActive(); |
|
668 |
} |
|
669 |
||
670 |
void CMessageKeyProcessor::ProcessKeyPressL(TKeyCode aKeyCode) |
|
671 |
{ |
|
672 |
TBool done = HandleKeyL(aKeyCode); |
|
673 |
||
674 |
if (done) |
|
675 |
{ |
|
676 |
CActiveScheduler::Stop(); |
|
677 |
return; |
|
678 |
} |
|
679 |
||
680 |
RequestCharacter(); |
|
681 |
} |
|
682 |
||
683 |
||
684 |
TBool CMessageKeyProcessor::HandleKeyL(TKeyCode aKeyCode) |
|
685 |
{ |
|
686 |
TBool done = EFalse; |
|
687 |
if (TChar(aKeyCode).IsAlpha()) |
|
688 |
{ |
|
689 |
iDisplay.GetDriveInfoL(aKeyCode); |
|
690 |
iDisplay.DriveInfo(); |
|
691 |
return done; |
|
692 |
} |
|
693 |
||
694 |
switch (aKeyCode) |
|
695 |
{ |
|
696 |
case EKeyF5: |
|
697 |
{ |
|
698 |
// Update USB status |
|
699 |
iUsbOtgSession.DeviceInserted(); |
|
700 |
iDisplay.DriveListL(); |
|
701 |
} |
|
702 |
break; |
|
703 |
||
704 |
case EKeyUpArrow: |
|
705 |
case EKeyPageUp: |
|
706 |
iDisplay.PageDec(); |
|
707 |
iDisplay.DriveInfo(); |
|
708 |
break; |
|
709 |
case EKeyDownArrow: |
|
710 |
case EKeyPageDown: |
|
711 |
iDisplay.PageInc(); |
|
712 |
iDisplay.DriveInfo(); |
|
713 |
break; |
|
714 |
case EKeyEscape: |
|
715 |
done = ETrue; |
|
716 |
break; |
|
717 |
default: |
|
718 |
break; |
|
719 |
} |
|
720 |
return done; |
|
721 |
} |
|
722 |
||
723 |