kerneltest/f32test/shostmassstorage/msman/app/cdisplay.cpp
changeset 43 96e5fb8b040d
child 33 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 43:96e5fb8b040d
       
     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
       
   413     _LIT(KDriveInfo1, "iType=%02x    iDriveAtt=%02x");
       
   414     _LIT(KDriveInfo2, "iBattery=%02x iMediaAtt=%02x");
       
   415     _LIT(KBatLow,"Battery low");
       
   416     _LIT(KBatGood,"Battery good");
       
   417     _LIT(KBatNotSupported,"Battery not supported");
       
   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");
       
   426     _LIT(KNANDFlash,"Media is NAND flash");
       
   427     _LIT(KUnknown,"Media unknownl");
       
   428     _LIT(KDriveAtts,"Drive attributes:");
       
   429     _LIT(KLocal," local");
       
   430     _LIT(KROMDrive," ROM");
       
   431     _LIT(KRedirected," redirected");
       
   432     _LIT(KSubstituted," substituted");
       
   433     _LIT(KInternal," internal");
       
   434     _LIT(KRemovable," removable");
       
   435     _LIT(KMediaAtts,"Media attributes:");
       
   436     _LIT(KDynamic," dynamic");
       
   437     _LIT(KDual," dual-density");
       
   438     _LIT(KFormattable," formattable");
       
   439     _LIT(KLockable," lockable");
       
   440     _LIT(KLocked," locked");
       
   441     _LIT(KHasPassword," has password");
       
   442     _LIT(KWriteProtected," write-protected");
       
   443 
       
   444     TLine* line;
       
   445     line = iScrollWindow->NewLineL();
       
   446     line->Format(KDriveInfo1, TInt(aDriveInfo.iType), TInt(aDriveInfo.iDriveAtt));
       
   447 
       
   448     line = iScrollWindow->NewLineL();
       
   449     line->Format(KDriveInfo2, TInt(aDriveInfo.iBattery), TInt(aDriveInfo.iMediaAtt));
       
   450 
       
   451     line = iScrollWindow->NewLineL();
       
   452     switch (aDriveInfo.iBattery)
       
   453         {
       
   454         case EBatLow:
       
   455             line->Append(KBatLow);
       
   456             break;
       
   457         case EBatGood:
       
   458             line->Append(KBatGood);
       
   459             break;
       
   460         default:
       
   461             line->Append(KBatNotSupported);
       
   462         }
       
   463 
       
   464     line = iScrollWindow->NewLineL();
       
   465     switch (aDriveInfo.iType)
       
   466             {
       
   467         case EMediaNotPresent:
       
   468             line->Append(KNotPresent);
       
   469             break;
       
   470         case EMediaFloppy:
       
   471             line->Append(KFloppy);
       
   472             break;
       
   473         case EMediaHardDisk:
       
   474             line->Append(KHard);
       
   475             break;
       
   476         case EMediaCdRom:
       
   477             line->Append(KCDROM);
       
   478             break;
       
   479         case EMediaRam:
       
   480             line->Append(KRam);
       
   481             break;
       
   482         case EMediaFlash:
       
   483             line->Append(KFlash);
       
   484             break;
       
   485         case EMediaRom:
       
   486             line->Append(KRom);
       
   487             break;
       
   488         case EMediaRemote:
       
   489             line->Append(KRemote);
       
   490             break;
       
   491         case EMediaNANDFlash:
       
   492             line->Append(KNANDFlash);
       
   493             break;
       
   494         default:
       
   495             line->Append(KUnknown);
       
   496 
       
   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             }
       
   532 
       
   533         // Media Attributes
       
   534         line = iScrollWindow->NewLineL();
       
   535         line->Append(KMediaAtts);
       
   536         if (aDriveInfo.iMediaAtt & KMediaAttVariableSize)
       
   537             {
       
   538             line = iScrollWindow->NewLineL();
       
   539             line->Append(KDynamic);
       
   540             }
       
   541         if (aDriveInfo.iMediaAtt & KMediaAttDualDensity)
       
   542             {
       
   543             line = iScrollWindow->NewLineL();
       
   544             line->Append(KDual);
       
   545             }
       
   546         if (aDriveInfo.iMediaAtt & KMediaAttFormattable)
       
   547             {
       
   548             line = iScrollWindow->NewLineL();
       
   549             line->Append(KFormattable);
       
   550             }
       
   551         if (aDriveInfo.iMediaAtt & KMediaAttWriteProtected)
       
   552             {
       
   553             line = iScrollWindow->NewLineL();
       
   554             line->Append(KWriteProtected);
       
   555             }
       
   556         if (aDriveInfo.iMediaAtt & KMediaAttLockable)
       
   557             {
       
   558             line = iScrollWindow->NewLineL();
       
   559             line->Append(KLockable);
       
   560             }
       
   561 
       
   562         if (aDriveInfo.iMediaAtt & KMediaAttLocked)
       
   563             {
       
   564             line = iScrollWindow->NewLineL();
       
   565             line->Append(KLocked);
       
   566             }
       
   567         if (aDriveInfo.iMediaAtt & KMediaAttHasPassword)
       
   568             {
       
   569             line = iScrollWindow->NewLineL();
       
   570             line->Append(KHasPassword);
       
   571             }
       
   572     }
       
   573 
       
   574 void CDisplay::FormatVolumeInfoL(const TVolumeInfo& aVolumeInfo)
       
   575     {
       
   576     // Append volume information to line
       
   577     _LIT(KUID,  "Unique ID:  0x%08X");
       
   578     _LIT(KSize, "Size:       0x%LX bytes");
       
   579     _LIT(KFree, "Free space: 0x%LX bytes");
       
   580     _LIT(KVolName, "Volume name: %S");
       
   581     TLine* line;
       
   582     line = iScrollWindow->NewLineL();
       
   583     line->Format(KUID, aVolumeInfo.iUniqueID);
       
   584     line = iScrollWindow->NewLineL();
       
   585     line->Format(KSize, aVolumeInfo.iSize);
       
   586     line = iScrollWindow->NewLineL();
       
   587     line->Format(KFree, aVolumeInfo.iFree);
       
   588     line = iScrollWindow->NewLineL();
       
   589     line->Format(KVolName, &aVolumeInfo.iName);
       
   590 
       
   591     }
       
   592 
       
   593 
       
   594 void CDisplay::UpTime(TUint aUpTime) const
       
   595     {
       
   596     TUint totalMins = aUpTime/60;
       
   597     TUint totalHrs = totalMins/60;
       
   598     iConsole.SetPos(0, KStartRow_UpTime);
       
   599     iConsole.Printf(KMsg_UpTime, totalHrs, totalMins%60, aUpTime%60);
       
   600     CursorHome();
       
   601     }
       
   602 
       
   603 void CDisplay::MemoryFree(TInt aBytes) const
       
   604     {
       
   605 	iConsole.SetPos(0, KStartRow_MemoryFree);
       
   606 	iConsole.Printf(KMsg_MemoryFree, aBytes);
       
   607     CursorHome();
       
   608     }
       
   609 
       
   610 
       
   611 //////////////////////////////////////////////////////////////////////////////
       
   612 //
       
   613 // CMessageKeyProcessor
       
   614 //
       
   615 //////////////////////////////////////////////////////////////////////////////
       
   616 CMessageKeyProcessor::CMessageKeyProcessor(CDisplay& aDisplay, RUsbOtgSession& aUsbOtgSession)
       
   617 :   CActive(CActive::EPriorityUserInput),
       
   618     iDisplay(aDisplay),
       
   619     iUsbOtgSession(aUsbOtgSession)
       
   620 	{
       
   621 	}
       
   622 
       
   623 CMessageKeyProcessor* CMessageKeyProcessor::NewLC(CDisplay& aDisplay, RUsbOtgSession& aUsbOtgSession)
       
   624 	{
       
   625 	CMessageKeyProcessor* self=new (ELeave) CMessageKeyProcessor(aDisplay, aUsbOtgSession);
       
   626 	CleanupStack::PushL(self);
       
   627 	self->ConstructL();
       
   628 	return self;
       
   629 	}
       
   630 
       
   631 
       
   632 void CMessageKeyProcessor::ConstructL()
       
   633 	{
       
   634 	// Add to active scheduler
       
   635 	CActiveScheduler::Add(this);
       
   636 	RequestCharacter();
       
   637 	}
       
   638 
       
   639 
       
   640 CMessageKeyProcessor::~CMessageKeyProcessor()
       
   641 	{
       
   642 	// Make sure we're cancelled
       
   643 	Cancel();
       
   644 	}
       
   645 
       
   646 void CMessageKeyProcessor::DoCancel()
       
   647 	{
       
   648 	iDisplay.ReadCancel();
       
   649 	}
       
   650 
       
   651 void CMessageKeyProcessor::RunL()
       
   652 	{
       
   653 	  // Handle completed request
       
   654 	ProcessKeyPressL(iDisplay.KeyCode());
       
   655 	}
       
   656 
       
   657 void CMessageKeyProcessor::RequestCharacter()
       
   658 	{
       
   659 	// A request is issued to the CConsoleBase to accept a
       
   660 	// character from the keyboard.
       
   661 	iDisplay.Read(iStatus);
       
   662 	SetActive();
       
   663 	}
       
   664 
       
   665 void CMessageKeyProcessor::ProcessKeyPressL(TKeyCode aKeyCode)
       
   666 	{
       
   667     TBool done = HandleKeyL(aKeyCode);
       
   668 
       
   669     if (done)
       
   670         {
       
   671         CActiveScheduler::Stop();
       
   672         return;
       
   673         }
       
   674 
       
   675     RequestCharacter();
       
   676 	}
       
   677 
       
   678 
       
   679 TBool CMessageKeyProcessor::HandleKeyL(TKeyCode aKeyCode)
       
   680     {
       
   681     TBool done = EFalse;
       
   682     if (TChar(aKeyCode).IsAlpha())
       
   683         {
       
   684         iDisplay.GetDriveInfoL(aKeyCode);
       
   685         iDisplay.DriveInfo();
       
   686         return done;
       
   687         }
       
   688 
       
   689     switch (aKeyCode)
       
   690         {
       
   691         case EKeyF5:
       
   692             {
       
   693             // Update USB status
       
   694             iUsbOtgSession.DeviceInserted();
       
   695             iDisplay.DriveListL();
       
   696             }
       
   697             break;
       
   698 
       
   699         case EKeyUpArrow:
       
   700         case EKeyPageUp:
       
   701             iDisplay.PageDec();
       
   702             iDisplay.DriveInfo();
       
   703             break;
       
   704         case EKeyDownArrow:
       
   705         case EKeyPageDown:
       
   706             iDisplay.PageInc();
       
   707             iDisplay.DriveInfo();
       
   708             break;
       
   709         case EKeyEscape:
       
   710             done = ETrue;
       
   711             break;
       
   712         default:
       
   713             break;
       
   714         }
       
   715     return done;
       
   716     }
       
   717 
       
   718