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