- Timestamp:
- Oct 24, 2006 5:13:30 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp
r692 r788 7 7 8 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 9 34 #include <pj/os.h> 10 35 … … 13 38 #include <e32cons.h> // Console 14 39 15 16 // Constants17 18 _LIT(KTextConsoleTitle, "Console");19 _LIT(KTextFailed, " failed, leave code = %d");20 _LIT(KTextPressAnyKey, " [press any key]\n");21 40 22 41 … … 29 48 30 49 LOCAL_C void MainL() 31 50 { 32 51 // 33 52 // add your program code here, example code below 34 53 // 35 54 test_main(); 36 } 55 CActiveScheduler::Stop(); 56 } 57 58 class MyScheduler : public CActiveScheduler 59 { 60 public: 61 MyScheduler() 62 {} 63 64 void Error(TInt aError) const; 65 }; 66 67 void MyScheduler::Error(TInt aError) const 68 { 69 int i = 0; 70 } 71 72 class ProgramStarter : public CActive 73 { 74 public: 75 static ProgramStarter *NewL(); 76 void Start(); 77 78 protected: 79 ProgramStarter(); 80 void ConstructL(); 81 virtual void RunL(); 82 virtual void DoCancel(); 83 TInt RunError(TInt aError); 84 85 private: 86 RTimer timer_; 87 }; 88 89 ProgramStarter::ProgramStarter() 90 : CActive(EPriorityNormal) 91 { 92 } 93 94 void ProgramStarter::ConstructL() 95 { 96 timer_.CreateLocal(); 97 CActiveScheduler::Add(this); 98 } 99 100 ProgramStarter *ProgramStarter::NewL() 101 { 102 ProgramStarter *self = new (ELeave) ProgramStarter; 103 CleanupStack::PushL(self); 104 105 self->ConstructL(); 106 107 CleanupStack::Pop(self); 108 return self; 109 } 110 111 void ProgramStarter::Start() 112 { 113 timer_.After(iStatus, 0); 114 SetActive(); 115 } 116 117 void ProgramStarter::RunL() 118 { 119 MainL(); 120 } 121 122 void ProgramStarter::DoCancel() 123 { 124 } 125 126 TInt ProgramStarter::RunError(TInt aError) 127 { 128 PJ_UNUSED_ARG(aError); 129 return KErrNone; 130 } 37 131 38 132 … … 40 134 { 41 135 // Create active scheduler (to run active objects) 42 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();136 CActiveScheduler* scheduler = new (ELeave) MyScheduler; 43 137 CleanupStack::PushL(scheduler); 44 138 CActiveScheduler::Install(scheduler); 45 139 46 MainL(); 140 ProgramStarter *starter = ProgramStarter::NewL(); 141 starter->Start(); 142 143 CActiveScheduler::Start(); 47 144 48 145 // Delete active scheduler 49 CleanupStack::PopAndDestroy(scheduler); 146 //CActiveScheduler::Install(NULL); 147 scheduler->Stop(); 148 //delete scheduler; 50 149 } 51 150 52 151 53 152 // Global Functions 153 154 static void log_writer(int level, const char *buf, int len) 155 { 156 wchar_t buf16[PJ_LOG_MAX_SIZE]; 157 158 pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16)); 159 160 TPtrC16 aBuf((const TUint16*)buf16, (TInt)len); 161 console->Write(aBuf); 162 } 163 54 164 55 165 GLDEF_C TInt E32Main() … … 60 170 61 171 // Create output console 62 TRAPD(createError, console = Console::NewL( KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));172 TRAPD(createError, console = Console::NewL(_L("Console"), TSize(KConsFullScreen,KConsFullScreen))); 63 173 if (createError) 64 174 return createError; 175 176 pj_log_set_log_func(&log_writer); 65 177 66 178 // Run application code inside TRAP harness, wait keypress when terminated 67 179 TRAPD(mainError, DoStartL()); 68 180 if (mainError) 69 console->Printf( KTextFailed, mainError);70 console->Printf( KTextPressAnyKey);181 console->Printf(_L(" failed, leave code = %d"), mainError); 182 console->Printf(_L(" [press any key]\n")); 71 183 console->Getch(); 72 184 … … 76 188 return KErrNone; 77 189 } 190 191 #endif /* if 0 */ 192
Note: See TracChangeset
for help on using the changeset viewer.