kerneltest/f32test/shostmassstorage/msman/app/cdisplay.cpp
branchCompilerCompatibility
changeset 77 c4d65d91ad0c
parent 62 4a8fed1c0ef6
equal deleted inserted replaced
74:741dcdf88ba9 77:c4d65d91ad0c
    29 #include "usbtypes.h"
    29 #include "usbtypes.h"
    30 #include "mdrivedisplay.h"
    30 #include "mdrivedisplay.h"
    31 #include "cdisplay.h"
    31 #include "cdisplay.h"
    32 
    32 
    33 // Display positions and test constants
    33 // Display positions and test constants
       
    34 
       
    35 // Available drives
       
    36 static const TInt KStartRow_AvailableDrives = 1;
       
    37 _LIT(KAvailDriveMsg, "Drives: ");
       
    38 
    34 // Number of attached devices
    39 // Number of attached devices
    35 static const TInt KRow_DevicesNumber = 13;
    40 static const TInt KRow_DevicesNumber = 2;
    36 _LIT(KMsg_DevicesAttached, "USB Devices Attached = %d");
    41 _LIT(KMsg_DevicesAttached, "USB Devices Attached = %d");
    37 
    42 
    38 // Device Map
    43 // Device Map
    39 static const TInt KStartRow_DeviceMap = KRow_DevicesNumber + 2;
    44 static const TInt KStartRow_DeviceMap = KRow_DevicesNumber + 2;
    40 static const TInt KMaxRows_DeviceMap = 4;
    45 static const TInt KMaxRows_DeviceMap = 4;
    41 _LIT(KMsg_DeviceMap_DriveList, "%d: ");          // [drive index]
    46 _LIT(KMsg_DeviceMap_DriveList, "%d: ");          // [drive index]
    42 _LIT(KMsg_DeviceMap_DriveLunEntry, "%c ");       // [drive letter]
    47 _LIT(KMsg_DeviceMap_DriveLunEntry, "%c ");       // [drive letter]
    43 
    48 
    44 
       
    45 // Drive Map
    49 // Drive Map
    46 static const TInt KStartRow_DriveMap = KStartRow_DeviceMap + KMaxRows_DeviceMap;
    50 static const TInt KStartRow_DriveMap = KStartRow_DeviceMap + KMaxRows_DeviceMap;
    47 static const TInt KMaxRows_DriveMap = 4;
    51 static const TInt KMaxRows_DriveMap = 4;
       
    52 
       
    53 // Drive info
       
    54 static const TInt KStartRow_MsgWindow = KStartRow_DriveMap + KMaxRows_DriveMap + 2;
       
    55 
    48 _LIT(KMsg_DriveMap_EntryLetter, "%c token = %d");           // [drive letter] [token]
    56 _LIT(KMsg_DriveMap_EntryLetter, "%c token = %d");           // [drive letter] [token]
    49 _LIT(KDbgMsg_DriveMap_EntryLetter, "*** %c token = %d");    // [drive letter] [token]
    57 _LIT(KDbgMsg_DriveMap_EntryLetter, "*** %c token = %d");    // [drive letter] [token]
       
    58                                                             
       
    59 static const TInt KRowScrollWindowStart = KStartRow_MsgWindow;    
    50 
    60 
    51 // System Status
    61 // System Status
    52 static const TInt KStartRow_UpTime = 28;
    62 static TPoint KPointSystemStatus(5, 0);
    53 _LIT(KMsg_UpTime, "up time     : %dh:%dm:%ds   ");	// use trailing space to overwrite any leftover chars in line
    63 _LIT(KMsg_UpTime, "up time     : %dh:%dm:%ds   ");	// use trailing space to overwrite any leftover chars in line
    54 
    64 
    55 static const TInt KStartRow_MemoryFree = 29;
    65 //static const TInt KStartRow_MemoryFree = 1 + KStartRow_SystemStatus;
       
    66 static TPoint KPointMemoryFree(5, 1);
    56 _LIT(KMsg_MemoryFree, "mem (bytes) : 0x%X");
    67 _LIT(KMsg_MemoryFree, "mem (bytes) : 0x%X");
    57 
    68 
    58 // User Keys
    69 // User Keys
    59 static const TInt KStartRow_UserKeys = 25;
    70 static const TPoint KPointUser1Keys(5,2);
    60 _LIT(KMsgUser1Keys, "[Esc]=Quit [A-Z]=DriveInfo");
    71 _LIT(KMsgUser1Keys, "[Esc]=Quit [A-Z]=DriveInfo");
    61 _LIT(KMsgUser2Keys, "[F5]=Hub update");
    72 static const TPoint KPointUser2Keys(5,3);
       
    73 _LIT(KMsgUser2Keys, "[F5|SPACE]=Hub update");
    62 
    74 
    63 
    75 
    64 // Scroll Window status
    76 // Scroll Window status
    65 _LIT(KScrollWindowStatus, "Page %d of %d");
    77 _LIT(KScrollWindowStatus, "Page %d of %d");
    66 
    78 
    67 // Available drives
       
    68 static const TInt KStartRow_AvailableDrives = 1;
       
    69 _LIT(KAvailDriveMsg, "Drives: ");
       
    70 
    79 
    71 _LIT(KDriveAtts,"DriveList %c: %02x ");
    80 _LIT(KDriveAtts,"DriveList %c: %02x ");
    72 
    81 
    73 // Drive info
       
    74 static const TInt KStartRow_MsgWindow = 3;
       
    75 static const TInt KStartRow_DriveInfo = KStartRow_MsgWindow;
       
    76 
    82 
    77 // ****************************************************************************
    83 // ****************************************************************************
    78 
    84 
    79 
    85 
    80 CScrollWindow* CScrollWindow::NewL(CConsoleBase& aConsole)
    86 CScrollWindow* CScrollWindow::NewL(CConsoleBase& aConsole, TInt aStartRow, TInt aEndRow)
    81     {
    87     {
    82 	CScrollWindow* r = new (ELeave) CScrollWindow(aConsole);
    88 	CScrollWindow* r = new (ELeave) CScrollWindow(aConsole, aStartRow, aEndRow);
    83 	CleanupStack::PushL(r);
    89 	CleanupStack::PushL(r);
    84 	r->ConstructL();
    90 	r->ConstructL();
    85     CleanupStack::Pop(r);
    91     CleanupStack::Pop(r);
    86 	return r;
    92 	return r;
    87     }
    93     }
    88 
    94 
    89 
    95 
    90 void CScrollWindow::ConstructL()
    96 void CScrollWindow::ConstructL()
    91     {
    97     {
    92 
    98     }
    93     }
    99 
    94 
   100 _LIT(KTxtPanic,"HUSBCONSAPP");
    95 
   101 
    96 CScrollWindow::CScrollWindow(CConsoleBase& aConsole)
   102 CScrollWindow::CScrollWindow(CConsoleBase& aConsole, TInt aStartRow, TInt aEndRow)
    97 :   iConsole(aConsole)
   103 :   iConsole(aConsole),
    98     {
   104     iStartRow(aStartRow),
       
   105     iEndRow(aEndRow),
       
   106     iPageLength(iEndRow - iStartRow)
       
   107     {
       
   108     __ASSERT_ALWAYS(iEndRow > iStartRow, User::Panic(KTxtPanic, -1));
    99     }
   109     }
   100 
   110 
   101 CScrollWindow::~CScrollWindow()
   111 CScrollWindow::~CScrollWindow()
   102     {
   112     {
   103     iLineArray.Close();
   113     iLineArray.Close();
   128     }
   138     }
   129 
   139 
   130 
   140 
   131 void CScrollWindow::Update()
   141 void CScrollWindow::Update()
   132     {
   142     {
   133     TInt line = iPage * KPageLength;
   143     TInt line = iPage * iPageLength;
   134 
   144 
   135     TInt row = KStartRow_DriveInfo;
   145     TInt row = iStartRow;
   136     do
   146     do
   137         {
   147         {
   138         iConsole.SetPos(0, row + line%KPageLength);
   148         iConsole.SetPos(0, row + line%iPageLength);
   139         if (line < iLineArray.Count())
   149         if (line < iLineArray.Count())
   140             {
   150             {
   141             iConsole.Printf(iLineArray[line]);
   151             iConsole.Printf(iLineArray[line]);
   142             }
   152             }
   143         iConsole.ClearToEndOfLine();
   153         iConsole.ClearToEndOfLine();
   144         line++;
   154         line++;
   145         }
   155         }
   146     while (((line-1)%KPageLength) != (KPageLength - 1));
   156     while (((line-1)%iPageLength) != (iPageLength - 1));
   147     iConsole.SetPos(0, KStartRow_DriveInfo + KPageLength);
   157 
   148     iConsole.Printf(KScrollWindowStatus, iPage + 1, iLineArray.Count()/KPageLength + 1);
   158     iConsole.SetPos(0, iStartRow + iPageLength);
       
   159     iConsole.Printf(KScrollWindowStatus, iPage + 1, iLineArray.Count()/iPageLength + 1);
   149     }
   160     }
   150 
   161 
   151 void CScrollWindow::PageInc()
   162 void CScrollWindow::PageInc()
   152     {
   163     {
   153     TInt lastPage = iLineArray.Count()/KPageLength;
   164     TInt lastPage = iLineArray.Count()/iPageLength;
   154     if (iPage == lastPage)
   165     if (iPage == lastPage)
   155         {
   166         {
   156         iPage = 0;
   167         iPage = 0;
   157         }
   168         }
   158     else
   169     else
   164 
   175 
   165 void CScrollWindow::PageDec()
   176 void CScrollWindow::PageDec()
   166     {
   177     {
   167     if (iPage == 0)
   178     if (iPage == 0)
   168         {
   179         {
   169         TInt lastPage = iLineArray.Count()/KPageLength;
   180         TInt lastPage = iLineArray.Count()/iPageLength;
   170         iPage = lastPage;
   181         iPage = lastPage;
   171         }
   182         }
   172     else
   183     else
   173         {
   184         {
   174         iPage--;
   185         iPage--;
   175         }
   186         }
   176     }
   187     }
   177 
       
   178 
   188 
   179 
   189 
   180 CDisplay* CDisplay::NewLC(RFs& aFs, CConsoleBase& aConsole)
   190 CDisplay* CDisplay::NewLC(RFs& aFs, CConsoleBase& aConsole)
   181     {
   191     {
   182 	CDisplay* r = new (ELeave) CDisplay(aFs, aConsole);
   192 	CDisplay* r = new (ELeave) CDisplay(aFs, aConsole);
   185 	return r;
   195 	return r;
   186     }
   196     }
   187 
   197 
   188 
   198 
   189 void CDisplay::ConstructL()
   199 void CDisplay::ConstructL()
   190     {
   200     {    
   191     iScrollWindow = CScrollWindow::NewL(iConsole);
   201     iScrollWindow = CScrollWindow::NewL(iConsole, KRowScrollWindowStart, iScreenSize.iHeight - iFooterY - 4);
   192     }
   202     }
   193 
   203 
   194 
   204 
   195 CDisplay::CDisplay(RFs& aFs, CConsoleBase& aConsole)
   205 CDisplay::CDisplay(RFs& aFs, CConsoleBase& aConsole)
   196 :   iFs(aFs),
   206 :   iFs(aFs),
   197     iConsole(aConsole)
   207     iConsole(aConsole)
   198     {
   208     {
   199     iConsole.ClearScreen();
   209     iConsole.ClearScreen();
       
   210     iScreenSize = iConsole.ScreenSize();
       
   211     // Origin of footer
       
   212     iPointFooter = TPoint(iFooterX, iScreenSize.iHeight - iFooterY - 2);
   200     }
   213     }
   201 
   214 
   202 
   215 
   203 CDisplay::~CDisplay()
   216 CDisplay::~CDisplay()
   204     {
   217     {
   206     }
   219     }
   207 
   220 
   208 
   221 
   209 void CDisplay::Menu()
   222 void CDisplay::Menu()
   210     {
   223     {
   211     iConsole.SetPos(0, KStartRow_UserKeys);
   224     SetFooterPos(KPointUser1Keys);
   212     iConsole.Printf(KMsgUser1Keys);
   225     iConsole.Printf(KMsgUser1Keys);
   213     iConsole.SetPos(0, KStartRow_UserKeys + 1);
   226     SetFooterPos(KPointUser2Keys);
   214     iConsole.Printf(KMsgUser2Keys);
   227     iConsole.Printf(KMsgUser2Keys);
   215     iCursorPos = iConsole.CursorPos();
   228     iCursorPos = iConsole.CursorPos();
   216     }
   229     }
   217 
   230 
   218 
   231 
   590     line->Format(KSize, aVolumeInfo.iSize);
   603     line->Format(KSize, aVolumeInfo.iSize);
   591     line = iScrollWindow->NewLineL();
   604     line = iScrollWindow->NewLineL();
   592     line->Format(KFree, aVolumeInfo.iFree);
   605     line->Format(KFree, aVolumeInfo.iFree);
   593     line = iScrollWindow->NewLineL();
   606     line = iScrollWindow->NewLineL();
   594     line->Format(KVolName, &aVolumeInfo.iName);
   607     line->Format(KVolName, &aVolumeInfo.iName);
   595 
       
   596     }
   608     }
   597 
   609 
   598 
   610 
   599 void CDisplay::UpTime(TUint aUpTime) const
   611 void CDisplay::UpTime(TUint aUpTime) const
   600     {
   612     {
   601     TUint totalMins = aUpTime/60;
   613     TUint totalMins = aUpTime/60;
   602     TUint totalHrs = totalMins/60;
   614     TUint totalHrs = totalMins/60;
   603     iConsole.SetPos(0, KStartRow_UpTime);
   615     
       
   616     SetFooterPos(KPointSystemStatus);    
   604     iConsole.Printf(KMsg_UpTime, totalHrs, totalMins%60, aUpTime%60);
   617     iConsole.Printf(KMsg_UpTime, totalHrs, totalMins%60, aUpTime%60);
   605     CursorHome();
   618     CursorHome();
   606     }
   619     }
   607 
   620 
   608 void CDisplay::MemoryFree(TInt aBytes) const
   621 void CDisplay::MemoryFree(TInt aBytes) const
   609     {
   622     {
   610 	iConsole.SetPos(0, KStartRow_MemoryFree);
   623     SetFooterPos(KPointMemoryFree);	
   611 	iConsole.Printf(KMsg_MemoryFree, aBytes);
   624 	iConsole.Printf(KMsg_MemoryFree, aBytes);
   612     CursorHome();
   625     CursorHome();
   613     }
   626     }
   614 
   627 
   615 
   628 
   682 
   695 
   683 
   696 
   684 TBool CMessageKeyProcessor::HandleKeyL(TKeyCode aKeyCode)
   697 TBool CMessageKeyProcessor::HandleKeyL(TKeyCode aKeyCode)
   685     {
   698     {
   686     TBool done = EFalse;
   699     TBool done = EFalse;
       
   700 
   687     if (TChar(aKeyCode).IsAlpha())
   701     if (TChar(aKeyCode).IsAlpha())
   688         {
   702         {
   689         iDisplay.GetDriveInfoL(aKeyCode);
   703         iDisplay.GetDriveInfoL(aKeyCode);
   690         iDisplay.DriveInfo();
   704         iDisplay.DriveInfo();
   691         return done;
   705         return done;
   692         }
   706         }
   693 
   707 
   694     switch (aKeyCode)
   708     switch (aKeyCode)
   695         {
   709         {
   696         case EKeyF5:
   710         case EKeyF5:
       
   711         case EKeySpace:
   697             {
   712             {
   698             // Update USB status
   713             // Update USB status
   699             iUsbOtgSession.DeviceInserted();
   714             iUsbOtgSession.DeviceInserted();
   700             iDisplay.DriveListL();
   715             iDisplay.DriveListL();
   701             }
   716             }
   702             break;
   717             break;
   703 
   718 
   704         case EKeyUpArrow:
   719         case EKeyUpArrow:
   705         case EKeyPageUp:
   720         case EKeyPageUp:
       
   721         case '[':
   706             iDisplay.PageDec();
   722             iDisplay.PageDec();
   707             iDisplay.DriveInfo();
   723             iDisplay.DriveInfo();
   708             break;
   724             break;
   709         case EKeyDownArrow:
   725         case EKeyDownArrow:
   710         case EKeyPageDown:
   726         case EKeyPageDown:
       
   727         case ']':
   711             iDisplay.PageInc();
   728             iDisplay.PageInc();
   712             iDisplay.DriveInfo();
   729             iDisplay.DriveInfo();
   713             break;
   730             break;
   714         case EKeyEscape:
   731         case EKeyEscape:
   715             done = ETrue;
   732             done = ETrue;