|
1 // hello.cpp |
|
2 // |
|
3 // Copyright (c) 2005 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include "hello.h" |
|
14 |
|
15 |
|
16 CCommandBase* CCmdHello::NewLC() |
|
17 { |
|
18 CCmdHello* self = new(ELeave) CCmdHello(); |
|
19 CleanupStack::PushL(self); |
|
20 self->BaseConstructL(); |
|
21 return self; |
|
22 } |
|
23 |
|
24 CCmdHello::~CCmdHello() |
|
25 { |
|
26 } |
|
27 |
|
28 CCmdHello::CCmdHello() |
|
29 { |
|
30 } |
|
31 |
|
32 const TDesC& CCmdHello::Name() const |
|
33 { |
|
34 _LIT(KName, "hello"); |
|
35 return KName; |
|
36 } |
|
37 |
|
38 void CCmdHello::DoRunL() |
|
39 { |
|
40 _LIT(KHelloWorld, "Hello World!"); |
|
41 |
|
42 if (iColor) |
|
43 { |
|
44 CTextBuffer* buf = CTextBuffer::NewLC(16); |
|
45 TInt color = ConsoleAttributes::ERed; |
|
46 for (TInt i = 0; i < KHelloWorld().Length(); ++i) |
|
47 { |
|
48 buf->SetAttributesL(ConsoleAttributes::ENone, (ConsoleAttributes::TColor)color); |
|
49 buf->AppendL(KHelloWorld()[i]); |
|
50 ++color; |
|
51 if (color == ConsoleAttributes::EWhite) |
|
52 { |
|
53 color = ConsoleAttributes::ERed; |
|
54 } |
|
55 } |
|
56 buf->SetAttributesL(ConsoleAttributes::ENone); // Restore the colours to normal |
|
57 buf->Write(Stdout()); |
|
58 CleanupStack::PopAndDestroy(buf); |
|
59 } |
|
60 else |
|
61 { |
|
62 Write(KHelloWorld); |
|
63 } |
|
64 } |
|
65 |
|
66 void CCmdHello::OptionsL(RCommandOptionList& aOptions) |
|
67 { |
|
68 aOptions.AppendBoolL(iColor, _L("color")); |
|
69 } |
|
70 |
|
71 #ifdef EXE_BUILD |
|
72 EXE_BOILER_PLATE(CCmdHello) |
|
73 #endif |
|
74 |