- Timestamp:
- May 3, 2007 7:56:21 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/symbian_ua/main_symbian.cpp
r1244 r1248 25 25 // Global Variables 26 26 CConsoleBase* console; 27 static CActiveSchedulerWait *asw;28 27 29 28 30 // Local Functions 31 32 LOCAL_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 42 class MyScheduler : public CActiveScheduler 43 { 44 public: 45 MyScheduler() 46 {} 47 48 void Error(TInt aError) const; 49 }; 50 51 void MyScheduler::Error(TInt aError) const 52 { 53 PJ_UNUSED_ARG(aError); 54 } 55 29 ///////////////////////////////////// 56 30 class MyTask : public CActive 57 31 { 58 32 public: 59 static MyTask *NewL(); 33 static MyTask *NewL(CActiveSchedulerWait *asw); 34 ~MyTask(); 60 35 void Start(); 61 36 62 37 protected: 63 MyTask( );38 MyTask(CActiveSchedulerWait *asw); 64 39 void ConstructL(); 65 40 virtual void RunL(); 66 41 virtual void DoCancel(); 67 TInt RunError(TInt aError);68 42 69 43 private: 70 44 RTimer timer_; 45 CActiveSchedulerWait *asw_; 71 46 }; 72 47 73 MyTask::MyTask( )74 : CActive(EPriorityNormal) 48 MyTask::MyTask(CActiveSchedulerWait *asw) 49 : CActive(EPriorityNormal), asw_(asw) 75 50 { 51 } 52 53 MyTask::~MyTask() 54 { 55 timer_.Close(); 76 56 } 77 57 … … 82 62 } 83 63 84 MyTask *MyTask::NewL( )64 MyTask *MyTask::NewL(CActiveSchedulerWait *asw) 85 65 { 86 MyTask *self = new (ELeave) MyTask ;66 MyTask *self = new (ELeave) MyTask(asw); 87 67 CleanupStack::PushL(self); 88 68 … … 101 81 void MyTask::RunL() 102 82 { 103 MainL(); 83 int rc = ua_main(); 84 asw_->AsyncStop(); 104 85 } 105 86 … … 108 89 } 109 90 110 TInt MyTask::RunError(TInt aError)111 {112 PJ_UNUSED_ARG(aError);113 return KErrNone;114 }115 116 117 91 LOCAL_C void DoStartL() 118 92 { 119 // Create active scheduler (to run active objects) 120 MyScheduler* scheduler = new (ELeave) MyScheduler; 93 CActiveScheduler *scheduler = new (ELeave) CActiveScheduler; 121 94 CleanupStack::PushL(scheduler); 122 95 CActiveScheduler::Install(scheduler); 123 96 124 MyTask *task = MyTask::NewL(); 97 CActiveSchedulerWait *asw = new CActiveSchedulerWait; 98 CleanupStack::PushL(asw); 99 100 MyTask *task = MyTask::NewL(asw); 125 101 task->Start(); 126 102 127 asw = new CActiveSchedulerWait;128 103 asw->Start(); 129 104 105 delete task; 106 107 CleanupStack::Pop(asw); 130 108 delete asw; 109 110 CActiveScheduler::Install(NULL); 131 111 CleanupStack::Pop(scheduler); 132 } 133 134 135 //////////////////////////////////////////////////////////////////////////// 136 137 class TMyTrapHandler : public TTrapHandler 138 { 139 public: 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 146 private: 147 TTrapHandler *prev_; 148 }; 149 150 void TMyTrapHandler::Install() { 151 prev_ = User::SetTrapHandler(this); 152 } 153 154 void TMyTrapHandler::Uninstall() { 155 User::SetTrapHandler(prev_); 156 } 157 158 IMPORT_C void TMyTrapHandler::Trap() 159 { 160 prev_->Trap(); 161 } 162 163 IMPORT_C void TMyTrapHandler::UnTrap() 164 { 165 prev_->UnTrap(); 166 } 167 168 IMPORT_C void TMyTrapHandler::Leave(TInt aValue) 169 { 170 prev_->Leave(aValue); 112 delete scheduler; 171 113 } 172 114 … … 177 119 GLDEF_C TInt E32Main() 178 120 { 179 TMyTrapHandler th;180 181 th.Install();182 183 121 // Create cleanup stack 184 //__UHEAP_MARK;122 __UHEAP_MARK; 185 123 CTrapCleanup* cleanup = CTrapCleanup::New(); 186 124 … … 193 131 194 132 console->Printf(_L("[press any key to close]\n")); 195 console->Getch();133 //console->Getch(); 196 134 197 135 delete console; 198 136 delete cleanup; 199 //__UHEAP_MARKEND; 200 201 th.Uninstall();137 138 CloseSTDLIB(); 139 __UHEAP_MARKEND; 202 140 return KErrNone; 203 141 }
Note: See TracChangeset
for help on using the changeset viewer.