|
1 // Copyright (c) 2000-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 "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 // |
|
15 |
|
16 |
|
17 #ifndef __CommonFiles_H |
|
18 #define __CommonFiles_H |
|
19 |
|
20 #include <e32cons.h> |
|
21 |
|
22 // public |
|
23 LOCAL_D CConsoleBase* console; // write all your messages to this |
|
24 LOCAL_C void doExampleL(); // code this function for the real example |
|
25 |
|
26 // private |
|
27 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example |
|
28 |
|
29 GLDEF_C TInt E32Main() // main function called by E32 |
|
30 { |
|
31 _LIT(KSymbianEx,"SymbianEx"); |
|
32 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
33 TRAPD(error,callExampleL()); // more initialization, then do example |
|
34 __ASSERT_ALWAYS(!error,User::Panic(KSymbianEx,error)); |
|
35 delete cleanup; // destroy clean-up stack |
|
36 return 0; // and return |
|
37 } |
|
38 |
|
39 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack |
|
40 { |
|
41 _LIT(KStatus1,"Symbian OS Example Code (comms)"); |
|
42 _LIT(KStatus2,"failed: leave code=%d"); |
|
43 _LIT(KStatus3,"ok"); |
|
44 _LIT(KStatus4," [press any key]"); |
|
45 |
|
46 console=Console::NewL(KStatus1,TSize(KConsFullScreen,KConsFullScreen)); |
|
47 //console=Console::NewL(KStatus1, TSize(KDefaultConsWidth,KDefaultConsHeight)); |
|
48 CleanupStack::PushL(console); |
|
49 TRAPD(error,doExampleL()); // perform example function |
|
50 if (error) console->Printf(KStatus2, error); |
|
51 else console->Printf(KStatus3); |
|
52 console->Printf(KStatus4); |
|
53 console->Getch(); // get and ignore character |
|
54 CleanupStack::Pop(); // close console |
|
55 } |
|
56 |
|
57 #endif |