Benny Prijono | f260e46 | 2007-04-30 21:03:32 +0000 | [diff] [blame] | 1 | //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 "test.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 | #if 0 |
| 19 | int main() |
| 20 | { |
| 21 | int err = 0; |
| 22 | int exp = 0; |
| 23 | |
| 24 | err = test_main(); |
| 25 | //err = test_main(); |
| 26 | |
| 27 | if (err) |
| 28 | return err; |
| 29 | return exp; |
| 30 | //return 0; |
| 31 | } |
| 32 | |
| 33 | #else |
| 34 | #include <pj/os.h> |
| 35 | |
| 36 | #include <e32base.h> |
| 37 | #include <e32std.h> |
| 38 | #include <e32cons.h> // Console |
| 39 | |
| 40 | |
| 41 | |
| 42 | // Global Variables |
| 43 | |
| 44 | LOCAL_D CConsoleBase* console; // write all messages to this |
| 45 | |
| 46 | |
| 47 | // Local Functions |
| 48 | |
| 49 | LOCAL_C void MainL() |
| 50 | { |
| 51 | // |
| 52 | // add your program code here, example code below |
| 53 | // |
Benny Prijono | a0c8b5c | 2007-05-12 15:03:23 +0000 | [diff] [blame] | 54 | test_main(); |
Benny Prijono | f260e46 | 2007-04-30 21:03:32 +0000 | [diff] [blame] | 55 | |
| 56 | console->Printf(_L(" [press any key]\n")); |
| 57 | console->Getch(); |
| 58 | |
| 59 | CActiveScheduler::Stop(); |
| 60 | } |
| 61 | |
| 62 | class MyScheduler : public CActiveScheduler |
| 63 | { |
| 64 | public: |
| 65 | MyScheduler() |
| 66 | {} |
| 67 | |
| 68 | void Error(TInt aError) const; |
| 69 | }; |
| 70 | |
| 71 | void MyScheduler::Error(TInt aError) const |
| 72 | { |
| 73 | PJ_UNUSED_ARG(aError); |
| 74 | } |
| 75 | |
| 76 | class ProgramStarter : public CActive |
| 77 | { |
| 78 | public: |
| 79 | static ProgramStarter *NewL(); |
| 80 | void Start(); |
| 81 | |
| 82 | protected: |
| 83 | ProgramStarter(); |
| 84 | void ConstructL(); |
| 85 | virtual void RunL(); |
| 86 | virtual void DoCancel(); |
| 87 | TInt RunError(TInt aError); |
| 88 | |
| 89 | private: |
| 90 | RTimer timer_; |
| 91 | }; |
| 92 | |
| 93 | ProgramStarter::ProgramStarter() |
| 94 | : CActive(EPriorityNormal) |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | void ProgramStarter::ConstructL() |
| 99 | { |
| 100 | timer_.CreateLocal(); |
| 101 | CActiveScheduler::Add(this); |
| 102 | } |
| 103 | |
| 104 | ProgramStarter *ProgramStarter::NewL() |
| 105 | { |
| 106 | ProgramStarter *self = new (ELeave) ProgramStarter; |
| 107 | CleanupStack::PushL(self); |
| 108 | |
| 109 | self->ConstructL(); |
| 110 | |
| 111 | CleanupStack::Pop(self); |
| 112 | return self; |
| 113 | } |
| 114 | |
| 115 | void ProgramStarter::Start() |
| 116 | { |
| 117 | timer_.After(iStatus, 0); |
| 118 | SetActive(); |
| 119 | } |
| 120 | |
| 121 | void ProgramStarter::RunL() |
| 122 | { |
| 123 | MainL(); |
| 124 | } |
| 125 | |
| 126 | void ProgramStarter::DoCancel() |
| 127 | { |
| 128 | } |
| 129 | |
| 130 | TInt ProgramStarter::RunError(TInt aError) |
| 131 | { |
| 132 | PJ_UNUSED_ARG(aError); |
| 133 | return KErrNone; |
| 134 | } |
| 135 | |
| 136 | |
| 137 | LOCAL_C void DoStartL() |
| 138 | { |
| 139 | // Create active scheduler (to run active objects) |
| 140 | CActiveScheduler* scheduler = new (ELeave) MyScheduler; |
| 141 | CleanupStack::PushL(scheduler); |
| 142 | CActiveScheduler::Install(scheduler); |
| 143 | |
| 144 | ProgramStarter *starter = ProgramStarter::NewL(); |
| 145 | starter->Start(); |
| 146 | |
| 147 | CActiveScheduler::Start(); |
| 148 | } |
| 149 | |
| 150 | |
| 151 | // Global Functions |
| 152 | |
| 153 | static void log_writer(int level, const char *buf, int len) |
| 154 | { |
| 155 | wchar_t buf16[PJ_LOG_MAX_SIZE]; |
| 156 | |
| 157 | PJ_UNUSED_ARG(level); |
| 158 | |
| 159 | pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16)); |
| 160 | |
| 161 | TPtrC16 aBuf((const TUint16*)buf16, (TInt)len); |
| 162 | console->Write(aBuf); |
| 163 | } |
| 164 | |
| 165 | |
| 166 | GLDEF_C TInt E32Main() |
| 167 | { |
| 168 | // Create cleanup stack |
| 169 | __UHEAP_MARK; |
| 170 | CTrapCleanup* cleanup = CTrapCleanup::New(); |
| 171 | |
| 172 | // Create output console |
| 173 | TRAPD(createError, console = Console::NewL(_L("Console"), TSize(KConsFullScreen,KConsFullScreen))); |
| 174 | if (createError) |
| 175 | return createError; |
| 176 | |
| 177 | pj_log_set_log_func(&log_writer); |
| 178 | |
| 179 | // Run application code inside TRAP harness, wait keypress when terminated |
| 180 | TRAPD(mainError, DoStartL()); |
| 181 | if (mainError) |
| 182 | console->Printf(_L(" failed, leave code = %d"), mainError); |
| 183 | console->Printf(_L(" [press any key]\n")); |
| 184 | console->Getch(); |
| 185 | |
| 186 | delete console; |
| 187 | delete cleanup; |
| 188 | __UHEAP_MARKEND; |
| 189 | return KErrNone; |
| 190 | } |
| 191 | |
| 192 | #endif /* if 0 */ |
| 193 | |