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