1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/app/cdisplay.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,723 @@
1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// USB Mass Storage Application - also used as an improvised boot loader mechanism
1.18 +//
1.19 +//
1.20 +
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 +*/
1.26 +
1.27 +#include <e32cons.h>
1.28 +#include <f32file.h>
1.29 +
1.30 +#include "rusbotgsession.h"
1.31 +
1.32 +#include "usbtypes.h"
1.33 +#include "mdrivedisplay.h"
1.34 +#include "cdisplay.h"
1.35 +
1.36 +// Display positions and test constants
1.37 +// Number of attached devices
1.38 +static const TInt KRow_DevicesNumber = 13;
1.39 +_LIT(KMsg_DevicesAttached, "USB Devices Attached = %d");
1.40 +
1.41 +// Device Map
1.42 +static const TInt KStartRow_DeviceMap = KRow_DevicesNumber + 2;
1.43 +static const TInt KMaxRows_DeviceMap = 4;
1.44 +_LIT(KMsg_DeviceMap_DriveList, "%d: "); // [drive index]
1.45 +_LIT(KMsg_DeviceMap_DriveLunEntry, "%c "); // [drive letter]
1.46 +
1.47 +
1.48 +// Drive Map
1.49 +static const TInt KStartRow_DriveMap = KStartRow_DeviceMap + KMaxRows_DeviceMap;
1.50 +static const TInt KMaxRows_DriveMap = 4;
1.51 +_LIT(KMsg_DriveMap_EntryLetter, "%c token = %d"); // [drive letter] [token]
1.52 +_LIT(KDbgMsg_DriveMap_EntryLetter, "*** %c token = %d"); // [drive letter] [token]
1.53 +
1.54 +// System Status
1.55 +static const TInt KStartRow_UpTime = 28;
1.56 +_LIT(KMsg_UpTime, "up time : %dh:%dm:%ds "); // use trailing space to overwrite any leftover chars in line
1.57 +
1.58 +static const TInt KStartRow_MemoryFree = 29;
1.59 +_LIT(KMsg_MemoryFree, "mem (bytes) : 0x%X");
1.60 +
1.61 +// User Keys
1.62 +static const TInt KStartRow_UserKeys = 25;
1.63 +_LIT(KMsgUser1Keys, "[Esc]=Quit [A-Z]=DriveInfo");
1.64 +_LIT(KMsgUser2Keys, "[F5]=Hub update");
1.65 +
1.66 +
1.67 +// Scroll Window status
1.68 +_LIT(KScrollWindowStatus, "Page %d of %d");
1.69 +
1.70 +// Available drives
1.71 +static const TInt KStartRow_AvailableDrives = 1;
1.72 +_LIT(KAvailDriveMsg, "Drives: ");
1.73 +
1.74 +_LIT(KDriveAtts,"DriveList %c: %02x ");
1.75 +
1.76 +// Drive info
1.77 +static const TInt KStartRow_MsgWindow = 3;
1.78 +static const TInt KStartRow_DriveInfo = KStartRow_MsgWindow;
1.79 +
1.80 +// ****************************************************************************
1.81 +
1.82 +
1.83 +CScrollWindow* CScrollWindow::NewL(CConsoleBase& aConsole)
1.84 + {
1.85 + CScrollWindow* r = new (ELeave) CScrollWindow(aConsole);
1.86 + CleanupStack::PushL(r);
1.87 + r->ConstructL();
1.88 + CleanupStack::Pop(r);
1.89 + return r;
1.90 + }
1.91 +
1.92 +
1.93 +void CScrollWindow::ConstructL()
1.94 + {
1.95 +
1.96 + }
1.97 +
1.98 +
1.99 +CScrollWindow::CScrollWindow(CConsoleBase& aConsole)
1.100 +: iConsole(aConsole)
1.101 + {
1.102 + }
1.103 +
1.104 +CScrollWindow::~CScrollWindow()
1.105 + {
1.106 + iLineArray.Close();
1.107 + }
1.108 +
1.109 +void CScrollWindow::Reset()
1.110 + {
1.111 + iPage = 0;
1.112 + iLineArray.Reset();
1.113 + }
1.114 +
1.115 +
1.116 +void CScrollWindow::AppendL(const TDesC& aLine)
1.117 + {
1.118 + iTmpLine.Zero();
1.119 + iLineArray.AppendL(iTmpLine);
1.120 + TInt last = iLineArray.Count() - 1;
1.121 + iLineArray[last].Copy(aLine);
1.122 + }
1.123 +
1.124 +
1.125 +TLine* CScrollWindow::NewLineL()
1.126 + {
1.127 + iTmpLine.Zero();
1.128 + iLineArray.AppendL(iTmpLine);
1.129 + TInt last = iLineArray.Count() - 1;
1.130 + return &iLineArray[last];
1.131 + }
1.132 +
1.133 +
1.134 +void CScrollWindow::Update()
1.135 + {
1.136 + TInt line = iPage * KPageLength;
1.137 +
1.138 + TInt row = KStartRow_DriveInfo;
1.139 + do
1.140 + {
1.141 + iConsole.SetPos(0, row + line%KPageLength);
1.142 + if (line < iLineArray.Count())
1.143 + {
1.144 + iConsole.Printf(iLineArray[line]);
1.145 + }
1.146 + iConsole.ClearToEndOfLine();
1.147 + line++;
1.148 + }
1.149 + while (((line-1)%KPageLength) != (KPageLength - 1));
1.150 + iConsole.SetPos(0, KStartRow_DriveInfo + KPageLength);
1.151 + iConsole.Printf(KScrollWindowStatus, iPage + 1, iLineArray.Count()/KPageLength + 1);
1.152 + }
1.153 +
1.154 +void CScrollWindow::PageInc()
1.155 + {
1.156 + TInt lastPage = iLineArray.Count()/KPageLength;
1.157 + if (iPage == lastPage)
1.158 + {
1.159 + iPage = 0;
1.160 + }
1.161 + else
1.162 + {
1.163 + iPage++;
1.164 + }
1.165 + }
1.166 +
1.167 +
1.168 +void CScrollWindow::PageDec()
1.169 + {
1.170 + if (iPage == 0)
1.171 + {
1.172 + TInt lastPage = iLineArray.Count()/KPageLength;
1.173 + iPage = lastPage;
1.174 + }
1.175 + else
1.176 + {
1.177 + iPage--;
1.178 + }
1.179 + }
1.180 +
1.181 +
1.182 +
1.183 +CDisplay* CDisplay::NewLC(RFs& aFs, CConsoleBase& aConsole)
1.184 + {
1.185 + CDisplay* r = new (ELeave) CDisplay(aFs, aConsole);
1.186 + CleanupStack::PushL(r);
1.187 + r->ConstructL();
1.188 + return r;
1.189 + }
1.190 +
1.191 +
1.192 +void CDisplay::ConstructL()
1.193 + {
1.194 + iScrollWindow = CScrollWindow::NewL(iConsole);
1.195 + }
1.196 +
1.197 +
1.198 +CDisplay::CDisplay(RFs& aFs, CConsoleBase& aConsole)
1.199 +: iFs(aFs),
1.200 + iConsole(aConsole)
1.201 + {
1.202 + iConsole.ClearScreen();
1.203 + }
1.204 +
1.205 +
1.206 +CDisplay::~CDisplay()
1.207 + {
1.208 + delete iScrollWindow;
1.209 + }
1.210 +
1.211 +
1.212 +void CDisplay::Menu()
1.213 + {
1.214 + iConsole.SetPos(0, KStartRow_UserKeys);
1.215 + iConsole.Printf(KMsgUser1Keys);
1.216 + iConsole.SetPos(0, KStartRow_UserKeys + 1);
1.217 + iConsole.Printf(KMsgUser2Keys);
1.218 + iCursorPos = iConsole.CursorPos();
1.219 + }
1.220 +
1.221 +
1.222 +void CDisplay::DriveListL() const
1.223 +{
1.224 + TDriveList drivelist;
1.225 + TRAPD(err, iFs.DriveList(drivelist));
1.226 + if (err)
1.227 + {
1.228 + return;
1.229 + }
1.230 + // A TDriveList (the list of available drives), is an array of
1.231 + // 26 bytes. Each byte with a non zero value signifies that the
1.232 + // corresponding drive is available.
1.233 + TBuf<KDisplayWidth> iLineBuffer;
1.234 + iLineBuffer = KAvailDriveMsg;
1.235 + TChar driveLetter;
1.236 +
1.237 + for (TInt driveNumber = EDriveA; driveNumber <= EDriveZ;driveNumber++)
1.238 + {
1.239 + if (drivelist[driveNumber]) // if drive-list entry non-zero, drive is available
1.240 + {
1.241 + // overflow check
1.242 + if (iLineBuffer.Length() == iLineBuffer.MaxLength())
1.243 + {
1.244 + iLineBuffer[iLineBuffer.MaxLength() - 1] = '>';
1.245 + break;
1.246 + }
1.247 +
1.248 + User::LeaveIfError(iFs.DriveToChar(driveNumber,driveLetter));
1.249 +
1.250 + // The following line prints the drive letter followed by the hex value
1.251 + // of the integer indicating that drive's attributes
1.252 + RDebug::Print(KDriveAtts,TUint(driveLetter), drivelist[driveNumber]);
1.253 + iLineBuffer.Append(driveLetter);
1.254 +
1.255 + }
1.256 + }
1.257 +
1.258 + iConsole.SetPos(0, KStartRow_AvailableDrives);
1.259 + iConsole.Printf(iLineBuffer);
1.260 + iConsole.ClearToEndOfLine();
1.261 + CursorHome();
1.262 +}
1.263 +
1.264 +
1.265 +void CDisplay::DevicesNumber(TInt aDevicesNumber) const
1.266 + {
1.267 + iConsole.SetPos(0, KRow_DevicesNumber);
1.268 + iConsole.Printf(KMsg_DevicesAttached, aDevicesNumber);
1.269 + iConsole.ClearToEndOfLine();
1.270 + }
1.271 +
1.272 +
1.273 +void CDisplay::DriveMapL(const TDriveMap& aDriveMap) const
1.274 + {
1.275 + TChar letter;
1.276 +
1.277 + TInt i = 0;
1.278 +
1.279 + // Output to debug port
1.280 + for (; i < aDriveMap.Count(); i++)
1.281 + {
1.282 + TToken token = aDriveMap[i];
1.283 + if (token)
1.284 + {
1.285 + User::LeaveIfError(iFs.DriveToChar(i, letter));
1.286 + RDebug::Print(KDbgMsg_DriveMap_EntryLetter, TUint(letter), token);
1.287 + }
1.288 + }
1.289 +
1.290 + // Output to console
1.291 + TInt row = KStartRow_DriveMap;
1.292 + for (i = (aDriveMap.Count() -1); i >= 0 && row < (KStartRow_DriveMap + KMaxRows_DriveMap); i--)
1.293 + {
1.294 + TToken token = aDriveMap[i];
1.295 + if (token)
1.296 + {
1.297 + User::LeaveIfError(iFs.DriveToChar(i, letter));
1.298 + iConsole.SetPos(0, row);
1.299 + iConsole.Printf(KMsg_DriveMap_EntryLetter, TUint(letter), token);
1.300 + iConsole.ClearToEndOfLine();
1.301 + row++;
1.302 + }
1.303 + }
1.304 +
1.305 + for (; row < KStartRow_DriveMap + KMaxRows_DriveMap; row++)
1.306 + {
1.307 + iConsole.SetPos(0, row);
1.308 + iConsole.ClearToEndOfLine();
1.309 + }
1.310 + }
1.311 +
1.312 +
1.313 +void CDisplay::DeviceMapL(TInt aRow, TInt deviceIndex, const TDeviceMap& aDeviceMap) const
1.314 + {
1.315 + TChar letter;
1.316 + TInt drive;
1.317 +
1.318 + // Output to debug port
1.319 + RDebug::Printf("*** deviceIndex = %d", deviceIndex);
1.320 + for (TInt lunIndex = 0; lunIndex < 16; lunIndex++)
1.321 + {
1.322 + drive = aDeviceMap[lunIndex];
1.323 +
1.324 + if (drive == 0)
1.325 + break;
1.326 +
1.327 + User::LeaveIfError(iFs.DriveToChar(drive, letter));
1.328 + RDebug::Printf("*** drive=%d %c", drive, TUint(letter));
1.329 + }
1.330 +
1.331 + // Output to console
1.332 + if (aRow >= KMaxRows_DeviceMap)
1.333 + {
1.334 + return;
1.335 + }
1.336 + RDebug::Printf("-----> Device MAP %x", deviceIndex);
1.337 + TInt row = KStartRow_DeviceMap + aRow;
1.338 + iConsole.SetPos(0, row);
1.339 + iConsole.Printf(KMsg_DeviceMap_DriveList, deviceIndex);
1.340 +
1.341 + for (TInt lunIndex = 0; lunIndex < 16; lunIndex++)
1.342 + {
1.343 + drive = aDeviceMap[lunIndex];
1.344 +
1.345 + if (drive == 0)
1.346 + break;
1.347 +
1.348 + User::LeaveIfError(iFs.DriveToChar(drive, letter));
1.349 + iConsole.Printf(KMsg_DeviceMap_DriveLunEntry, TUint(letter));
1.350 + iConsole.ClearToEndOfLine();
1.351 + }
1.352 + }
1.353 +
1.354 +
1.355 +void CDisplay::DeviceMapClear(TInt aRow) const
1.356 + {
1.357 + TInt row = KStartRow_DeviceMap;
1.358 +
1.359 + if (aRow > KMaxRows_DeviceMap)
1.360 + return;
1.361 +
1.362 + for (row = KStartRow_DeviceMap + aRow; row < KStartRow_DeviceMap + KMaxRows_DeviceMap; row++)
1.363 + {
1.364 + iConsole.SetPos(0, row);
1.365 + iConsole.ClearToEndOfLine();
1.366 + }
1.367 + }
1.368 +
1.369 +
1.370 +void CDisplay::GetDriveInfoL(TChar aChar)
1.371 + {
1.372 + iScrollWindow->Reset();
1.373 +
1.374 + TDriveInfo driveInfo;
1.375 +
1.376 + TInt driveNumber;
1.377 + User::LeaveIfError(iFs.CharToDrive(aChar, driveNumber));
1.378 +
1.379 + TLine* line;
1.380 + line = iScrollWindow->NewLineL();
1.381 + _LIT(KDrive,"Drive=%d %C");
1.382 + line->Format(KDrive, driveNumber, TInt(aChar.GetUpperCase()));
1.383 +
1.384 + iFs.Drive(driveInfo, driveNumber);
1.385 + if (driveInfo.iDriveAtt == KDriveAbsent)
1.386 + {
1.387 + _LIT(KTxt_MappingDriveError, "Drive absent !");
1.388 + iScrollWindow->AppendL(KTxt_MappingDriveError);
1.389 + return;
1.390 + }
1.391 +
1.392 + FormatDriveInfoL(driveInfo);
1.393 +
1.394 + TVolumeInfo volumeInfo;
1.395 +
1.396 + TInt err = iFs.Volume(volumeInfo, driveNumber);
1.397 + if (err != KErrNotReady)
1.398 + // Volume() returns KErrNotReady if no volume present.
1.399 + // In this case, check next drive number
1.400 + {
1.401 + FormatVolumeInfoL(volumeInfo);
1.402 + }
1.403 + }
1.404 +
1.405 +
1.406 +void CDisplay::DriveInfo()
1.407 + {
1.408 + iScrollWindow->Update();
1.409 + CursorHome();
1.410 + }
1.411 +
1.412 +void CDisplay::FormatDriveInfoL(const TDriveInfo& aDriveInfo)
1.413 + {
1.414 + // Append battery, media and drive information to aBuffer
1.415 + // Define descriptor constants using the _LIT macro
1.416 + _LIT(KDriveInfo1, "iType=%02x %02x iDriveAtt=%04x");
1.417 + _LIT(KDriveInfo2, "iMediaAtt=%02x");
1.418 + _LIT(KConnectionBusInternal,"Connection Bus Internal");
1.419 + _LIT(KConnectionBusUsb,"Connection Bus USB");
1.420 + _LIT(KConnectionBusUnknown,"Connection Bus Unknown");
1.421 + _LIT(KNotPresent,"No media present");
1.422 + _LIT(KFloppy,"Media is floppy disk");
1.423 + _LIT(KHard,"Media is hard disk");
1.424 + _LIT(KCDROM,"Media is CD-ROM");
1.425 + _LIT(KRam,"Media is RAM");
1.426 + _LIT(KFlash,"Media is flash");
1.427 + _LIT(KRom,"Media is ROM");
1.428 + _LIT(KRemote,"Media is remote");
1.429 + _LIT(KExternal,"Media is external");
1.430 + _LIT(KNANDFlash,"Media is NAND flash");
1.431 + _LIT(KUnknown,"Media unknown");
1.432 + _LIT(KDriveAtts,"Drive attributes:");
1.433 + _LIT(KLocal," local");
1.434 + _LIT(KROMDrive," ROM");
1.435 + _LIT(KRedirected," redirected");
1.436 + _LIT(KSubstituted," substituted");
1.437 + _LIT(KInternal," internal");
1.438 + _LIT(KRemovable," removable");
1.439 + _LIT(KMediaAtts,"Media attributes:");
1.440 + _LIT(KDynamic," dynamic");
1.441 + _LIT(KDual," dual-density");
1.442 + _LIT(KFormattable," formattable");
1.443 + _LIT(KLockable," lockable");
1.444 + _LIT(KLocked," locked");
1.445 + _LIT(KHasPassword," has password");
1.446 + _LIT(KWriteProtected," write-protected");
1.447 +
1.448 + TLine* line;
1.449 + line = iScrollWindow->NewLineL();
1.450 + line->Format(KDriveInfo1, TInt(aDriveInfo.iType), TInt(aDriveInfo.iConnectionBusType), TInt(aDriveInfo.iDriveAtt));
1.451 +
1.452 + line = iScrollWindow->NewLineL();
1.453 + line->Format(KDriveInfo2, TInt(aDriveInfo.iMediaAtt));
1.454 +
1.455 + line = iScrollWindow->NewLineL();
1.456 + switch (aDriveInfo.iConnectionBusType)
1.457 + {
1.458 + case EConnectionBusInternal:
1.459 + line->Append(KConnectionBusInternal);
1.460 + break;
1.461 + case EConnectionBusUsb:
1.462 + line->Append(KConnectionBusUsb);
1.463 + break;
1.464 + default:
1.465 + line->Append(KConnectionBusUnknown);
1.466 + }
1.467 +
1.468 + line = iScrollWindow->NewLineL();
1.469 + switch (aDriveInfo.iType)
1.470 + {
1.471 + case EMediaNotPresent:
1.472 + line->Append(KNotPresent);
1.473 + break;
1.474 + case EMediaFloppy:
1.475 + line->Append(KFloppy);
1.476 + break;
1.477 + case EMediaHardDisk:
1.478 + line->Append(KHard);
1.479 + break;
1.480 + case EMediaCdRom:
1.481 + line->Append(KCDROM);
1.482 + break;
1.483 + case EMediaRam:
1.484 + line->Append(KRam);
1.485 + break;
1.486 + case EMediaFlash:
1.487 + line->Append(KFlash);
1.488 + break;
1.489 + case EMediaRom:
1.490 + line->Append(KRom);
1.491 + break;
1.492 + case EMediaRemote:
1.493 + line->Append(KRemote);
1.494 + break;
1.495 + case EMediaNANDFlash:
1.496 + line->Append(KNANDFlash);
1.497 + break;
1.498 + default:
1.499 + line->Append(KUnknown);
1.500 + }
1.501 +
1.502 + // Drive Attributes
1.503 + line = iScrollWindow->NewLineL();
1.504 + line->Append(KDriveAtts);
1.505 + if (aDriveInfo.iDriveAtt & KDriveAttLocal)
1.506 + {
1.507 + line = iScrollWindow->NewLineL();
1.508 + line->Append(KLocal);
1.509 + }
1.510 + if (aDriveInfo.iDriveAtt & KDriveAttRom)
1.511 + {
1.512 + line = iScrollWindow->NewLineL();
1.513 + line->Append(KROMDrive);
1.514 + }
1.515 + if (aDriveInfo.iDriveAtt & KDriveAttRedirected)
1.516 + {
1.517 + line = iScrollWindow->NewLineL();
1.518 + line->Append(KRedirected);
1.519 + }
1.520 + if (aDriveInfo.iDriveAtt & KDriveAttSubsted)
1.521 + {
1.522 + line = iScrollWindow->NewLineL();
1.523 + line->Append(KSubstituted);
1.524 + }
1.525 + if (aDriveInfo.iDriveAtt & KDriveAttInternal)
1.526 + {
1.527 + line = iScrollWindow->NewLineL();
1.528 + line->Append(KInternal);
1.529 + }
1.530 + if (aDriveInfo.iDriveAtt & KDriveAttRemovable)
1.531 + {
1.532 + line = iScrollWindow->NewLineL();
1.533 + line->Append(KRemovable);
1.534 + }
1.535 + if (aDriveInfo.iDriveAtt & KDriveAttExternal)
1.536 + {
1.537 + line = iScrollWindow->NewLineL();
1.538 + line->Append(KExternal);
1.539 + }
1.540 +
1.541 + // Media Attributes
1.542 + line = iScrollWindow->NewLineL();
1.543 + line->Append(KMediaAtts);
1.544 + if (aDriveInfo.iMediaAtt & KMediaAttVariableSize)
1.545 + {
1.546 + line = iScrollWindow->NewLineL();
1.547 + line->Append(KDynamic);
1.548 + }
1.549 + if (aDriveInfo.iMediaAtt & KMediaAttDualDensity)
1.550 + {
1.551 + line = iScrollWindow->NewLineL();
1.552 + line->Append(KDual);
1.553 + }
1.554 + if (aDriveInfo.iMediaAtt & KMediaAttFormattable)
1.555 + {
1.556 + line = iScrollWindow->NewLineL();
1.557 + line->Append(KFormattable);
1.558 + }
1.559 + if (aDriveInfo.iMediaAtt & KMediaAttWriteProtected)
1.560 + {
1.561 + line = iScrollWindow->NewLineL();
1.562 + line->Append(KWriteProtected);
1.563 + }
1.564 + if (aDriveInfo.iMediaAtt & KMediaAttLockable)
1.565 + {
1.566 + line = iScrollWindow->NewLineL();
1.567 + line->Append(KLockable);
1.568 + }
1.569 +
1.570 + if (aDriveInfo.iMediaAtt & KMediaAttLocked)
1.571 + {
1.572 + line = iScrollWindow->NewLineL();
1.573 + line->Append(KLocked);
1.574 + }
1.575 + if (aDriveInfo.iMediaAtt & KMediaAttHasPassword)
1.576 + {
1.577 + line = iScrollWindow->NewLineL();
1.578 + line->Append(KHasPassword);
1.579 + }
1.580 + }
1.581 +
1.582 +void CDisplay::FormatVolumeInfoL(const TVolumeInfo& aVolumeInfo)
1.583 + {
1.584 + // Append volume information to line
1.585 + _LIT(KUID, "Unique ID: 0x%08X");
1.586 + _LIT(KSize, "Size: 0x%LX bytes");
1.587 + _LIT(KFree, "Free space: 0x%LX bytes");
1.588 + _LIT(KVolName, "Volume name: %S");
1.589 + TLine* line;
1.590 + line = iScrollWindow->NewLineL();
1.591 + line->Format(KUID, aVolumeInfo.iUniqueID);
1.592 + line = iScrollWindow->NewLineL();
1.593 + line->Format(KSize, aVolumeInfo.iSize);
1.594 + line = iScrollWindow->NewLineL();
1.595 + line->Format(KFree, aVolumeInfo.iFree);
1.596 + line = iScrollWindow->NewLineL();
1.597 + line->Format(KVolName, &aVolumeInfo.iName);
1.598 +
1.599 + }
1.600 +
1.601 +
1.602 +void CDisplay::UpTime(TUint aUpTime) const
1.603 + {
1.604 + TUint totalMins = aUpTime/60;
1.605 + TUint totalHrs = totalMins/60;
1.606 + iConsole.SetPos(0, KStartRow_UpTime);
1.607 + iConsole.Printf(KMsg_UpTime, totalHrs, totalMins%60, aUpTime%60);
1.608 + CursorHome();
1.609 + }
1.610 +
1.611 +void CDisplay::MemoryFree(TInt aBytes) const
1.612 + {
1.613 + iConsole.SetPos(0, KStartRow_MemoryFree);
1.614 + iConsole.Printf(KMsg_MemoryFree, aBytes);
1.615 + CursorHome();
1.616 + }
1.617 +
1.618 +
1.619 +//////////////////////////////////////////////////////////////////////////////
1.620 +//
1.621 +// CMessageKeyProcessor
1.622 +//
1.623 +//////////////////////////////////////////////////////////////////////////////
1.624 +CMessageKeyProcessor::CMessageKeyProcessor(CDisplay& aDisplay, RUsbOtgSession& aUsbOtgSession)
1.625 +: CActive(CActive::EPriorityUserInput),
1.626 + iDisplay(aDisplay),
1.627 + iUsbOtgSession(aUsbOtgSession)
1.628 + {
1.629 + }
1.630 +
1.631 +CMessageKeyProcessor* CMessageKeyProcessor::NewLC(CDisplay& aDisplay, RUsbOtgSession& aUsbOtgSession)
1.632 + {
1.633 + CMessageKeyProcessor* self=new (ELeave) CMessageKeyProcessor(aDisplay, aUsbOtgSession);
1.634 + CleanupStack::PushL(self);
1.635 + self->ConstructL();
1.636 + return self;
1.637 + }
1.638 +
1.639 +
1.640 +void CMessageKeyProcessor::ConstructL()
1.641 + {
1.642 + // Add to active scheduler
1.643 + CActiveScheduler::Add(this);
1.644 + RequestCharacter();
1.645 + }
1.646 +
1.647 +
1.648 +CMessageKeyProcessor::~CMessageKeyProcessor()
1.649 + {
1.650 + // Make sure we're cancelled
1.651 + Cancel();
1.652 + }
1.653 +
1.654 +void CMessageKeyProcessor::DoCancel()
1.655 + {
1.656 + iDisplay.ReadCancel();
1.657 + }
1.658 +
1.659 +void CMessageKeyProcessor::RunL()
1.660 + {
1.661 + // Handle completed request
1.662 + ProcessKeyPressL(iDisplay.KeyCode());
1.663 + }
1.664 +
1.665 +void CMessageKeyProcessor::RequestCharacter()
1.666 + {
1.667 + // A request is issued to the CConsoleBase to accept a
1.668 + // character from the keyboard.
1.669 + iDisplay.Read(iStatus);
1.670 + SetActive();
1.671 + }
1.672 +
1.673 +void CMessageKeyProcessor::ProcessKeyPressL(TKeyCode aKeyCode)
1.674 + {
1.675 + TBool done = HandleKeyL(aKeyCode);
1.676 +
1.677 + if (done)
1.678 + {
1.679 + CActiveScheduler::Stop();
1.680 + return;
1.681 + }
1.682 +
1.683 + RequestCharacter();
1.684 + }
1.685 +
1.686 +
1.687 +TBool CMessageKeyProcessor::HandleKeyL(TKeyCode aKeyCode)
1.688 + {
1.689 + TBool done = EFalse;
1.690 + if (TChar(aKeyCode).IsAlpha())
1.691 + {
1.692 + iDisplay.GetDriveInfoL(aKeyCode);
1.693 + iDisplay.DriveInfo();
1.694 + return done;
1.695 + }
1.696 +
1.697 + switch (aKeyCode)
1.698 + {
1.699 + case EKeyF5:
1.700 + {
1.701 + // Update USB status
1.702 + iUsbOtgSession.DeviceInserted();
1.703 + iDisplay.DriveListL();
1.704 + }
1.705 + break;
1.706 +
1.707 + case EKeyUpArrow:
1.708 + case EKeyPageUp:
1.709 + iDisplay.PageDec();
1.710 + iDisplay.DriveInfo();
1.711 + break;
1.712 + case EKeyDownArrow:
1.713 + case EKeyPageDown:
1.714 + iDisplay.PageInc();
1.715 + iDisplay.DriveInfo();
1.716 + break;
1.717 + case EKeyEscape:
1.718 + done = ETrue;
1.719 + break;
1.720 + default:
1.721 + break;
1.722 + }
1.723 + return done;
1.724 + }
1.725 +
1.726 +