blob: 640fb2d4bbfe9d368c5bc2826af9c54ea437031b [file] [log] [blame]
Benny Prijonoba5926a2007-05-02 11:29:37 +00001//Auto-generated file. Please do not modify.
2//#include <e32cmn.h>
3
4//#pragma data_seg(".SYMBIAN")
5//__EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0)
6//#pragma data_seg()
7
8#include "ua.h"
9#include <stdlib.h>
10#include <pj/errno.h>
11#include <pj/os.h>
12#include <pj/log.h>
13#include <pj/unicode.h>
14#include <stdio.h>
15
16#include <e32std.h>
17
18#include <pj/os.h>
19
20#include <e32base.h>
21#include <e32std.h>
22
23
24
25// Global Variables
26CConsoleBase* console;
27static CActiveSchedulerWait *asw;
28
29
30// Local Functions
31
32LOCAL_C void MainL()
33{
34 //
35 // add your program code here, example code below
36 //
37 int rc = ua_main();
38
39 asw->AsyncStop();
40}
41
42class MyScheduler : public CActiveScheduler
43{
44public:
45 MyScheduler()
46 {}
47
48 void Error(TInt aError) const;
49};
50
51void MyScheduler::Error(TInt aError) const
52{
53 PJ_UNUSED_ARG(aError);
54}
55
56class MyTask : public CActive
57{
58public:
59 static MyTask *NewL();
60 void Start();
61
62protected:
63 MyTask();
64 void ConstructL();
65 virtual void RunL();
66 virtual void DoCancel();
67 TInt RunError(TInt aError);
68
69private:
70 RTimer timer_;
71};
72
73MyTask::MyTask()
74: CActive(EPriorityNormal)
75{
76}
77
78void MyTask::ConstructL()
79{
80 timer_.CreateLocal();
81 CActiveScheduler::Add(this);
82}
83
84MyTask *MyTask::NewL()
85{
86 MyTask *self = new (ELeave) MyTask;
87 CleanupStack::PushL(self);
88
89 self->ConstructL();
90
91 CleanupStack::Pop(self);
92 return self;
93}
94
95void MyTask::Start()
96{
97 timer_.After(iStatus, 0);
98 SetActive();
99}
100
101void MyTask::RunL()
102{
103 MainL();
104}
105
106void MyTask::DoCancel()
107{
108}
109
110TInt MyTask::RunError(TInt aError)
111{
112 PJ_UNUSED_ARG(aError);
113 return KErrNone;
114}
115
116
117LOCAL_C void DoStartL()
118{
119 // Create active scheduler (to run active objects)
120 MyScheduler* scheduler = new (ELeave) MyScheduler;
121 CleanupStack::PushL(scheduler);
122 CActiveScheduler::Install(scheduler);
123
124 MyTask *task = MyTask::NewL();
125 task->Start();
126
127 asw = new CActiveSchedulerWait;
128 asw->Start();
129
130 delete asw;
131 CleanupStack::Pop(scheduler);
132}
133
134
Benny Prijono5d542642007-05-02 18:54:19 +0000135////////////////////////////////////////////////////////////////////////////
136
137class TMyTrapHandler : public TTrapHandler
138{
139public:
140 void Install();
141 void Uninstall();
142 virtual IMPORT_C void Trap();
143 virtual IMPORT_C void UnTrap();
144 virtual IMPORT_C void Leave(TInt aValue);
145
146private:
147 TTrapHandler *prev_;
148};
149
150void TMyTrapHandler::Install() {
151 prev_ = User::SetTrapHandler(this);
152}
153
154void TMyTrapHandler::Uninstall() {
155 User::SetTrapHandler(prev_);
156}
157
158IMPORT_C void TMyTrapHandler::Trap()
159{
160 prev_->Trap();
161}
162
163IMPORT_C void TMyTrapHandler::UnTrap()
164{
165 prev_->UnTrap();
166}
167
168IMPORT_C void TMyTrapHandler::Leave(TInt aValue)
169{
170 prev_->Leave(aValue);
171}
172
173
174////////////////////////////////////////////////////////////////////////////
175
Benny Prijonoba5926a2007-05-02 11:29:37 +0000176// Global Functions
177GLDEF_C TInt E32Main()
178{
Benny Prijono5d542642007-05-02 18:54:19 +0000179 TMyTrapHandler th;
180
181 th.Install();
182
Benny Prijonoba5926a2007-05-02 11:29:37 +0000183 // Create cleanup stack
184 //__UHEAP_MARK;
185 CTrapCleanup* cleanup = CTrapCleanup::New();
186
187 // Create output console
188 TRAPD(createError, console = Console::NewL(_L("Console"), TSize(KConsFullScreen,KConsFullScreen)));
189 if (createError)
190 return createError;
191
192 TRAPD(startError, DoStartL());
193
194 console->Printf(_L("[press any key to close]\n"));
195 console->Getch();
196
197 delete console;
198 delete cleanup;
199 //__UHEAP_MARKEND;
Benny Prijono5d542642007-05-02 18:54:19 +0000200
201 th.Uninstall();
Benny Prijonoba5926a2007-05-02 11:29:37 +0000202 return KErrNone;
203}
204