Ignore:
Timestamp:
May 3, 2007 7:56:21 PM (17 years ago)
Author:
bennylp
Message:

Misc Symbian fixes, looks good

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/symbian_ua/main_symbian.cpp

    r1244 r1248  
    2525//  Global Variables 
    2626CConsoleBase* console; 
    27 static CActiveSchedulerWait *asw; 
    2827 
    2928 
    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///////////////////////////////////// 
    5630class MyTask : public CActive 
    5731{ 
    5832public: 
    59     static MyTask *NewL(); 
     33    static MyTask *NewL(CActiveSchedulerWait *asw); 
     34    ~MyTask(); 
    6035    void Start(); 
    6136 
    6237protected: 
    63     MyTask(); 
     38    MyTask(CActiveSchedulerWait *asw); 
    6439    void ConstructL(); 
    6540    virtual void RunL(); 
    6641    virtual void DoCancel(); 
    67     TInt RunError(TInt aError); 
    6842 
    6943private: 
    7044    RTimer timer_; 
     45    CActiveSchedulerWait *asw_; 
    7146}; 
    7247 
    73 MyTask::MyTask() 
    74 : CActive(EPriorityNormal) 
     48MyTask::MyTask(CActiveSchedulerWait *asw) 
     49: CActive(EPriorityNormal), asw_(asw) 
    7550{ 
     51} 
     52 
     53MyTask::~MyTask()  
     54{ 
     55    timer_.Close(); 
    7656} 
    7757 
     
    8262} 
    8363 
    84 MyTask *MyTask::NewL() 
     64MyTask *MyTask::NewL(CActiveSchedulerWait *asw) 
    8565{ 
    86     MyTask *self = new (ELeave) MyTask; 
     66    MyTask *self = new (ELeave) MyTask(asw); 
    8767    CleanupStack::PushL(self); 
    8868 
     
    10181void MyTask::RunL() 
    10282{ 
    103     MainL(); 
     83    int rc = ua_main(); 
     84    asw_->AsyncStop(); 
    10485} 
    10586 
     
    10889} 
    10990 
    110 TInt MyTask::RunError(TInt aError) 
    111 { 
    112     PJ_UNUSED_ARG(aError); 
    113     return KErrNone; 
    114 } 
    115  
    116  
    11791LOCAL_C void DoStartL() 
    11892{ 
    119     // Create active scheduler (to run active objects) 
    120     MyScheduler* scheduler = new (ELeave) MyScheduler; 
     93    CActiveScheduler *scheduler = new (ELeave) CActiveScheduler; 
    12194    CleanupStack::PushL(scheduler); 
    12295    CActiveScheduler::Install(scheduler); 
    12396 
    124     MyTask *task = MyTask::NewL(); 
     97    CActiveSchedulerWait *asw = new CActiveSchedulerWait; 
     98    CleanupStack::PushL(asw); 
     99     
     100    MyTask *task = MyTask::NewL(asw); 
    125101    task->Start(); 
    126102 
    127     asw = new CActiveSchedulerWait; 
    128103    asw->Start(); 
    129104     
     105    delete task; 
     106     
     107    CleanupStack::Pop(asw); 
    130108    delete asw; 
     109     
     110    CActiveScheduler::Install(NULL); 
    131111    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; 
    171113} 
    172114 
     
    177119GLDEF_C TInt E32Main() 
    178120{ 
    179     TMyTrapHandler th; 
    180      
    181     th.Install(); 
    182      
    183121    // Create cleanup stack 
    184     //__UHEAP_MARK; 
     122    __UHEAP_MARK; 
    185123    CTrapCleanup* cleanup = CTrapCleanup::New(); 
    186124 
     
    193131 
    194132    console->Printf(_L("[press any key to close]\n")); 
    195     console->Getch(); 
     133    //console->Getch(); 
    196134     
    197135    delete console; 
    198136    delete cleanup; 
    199     //__UHEAP_MARKEND; 
    200      
    201     th.Uninstall(); 
     137 
     138    CloseSTDLIB();     
     139    __UHEAP_MARKEND; 
    202140    return KErrNone; 
    203141} 
Note: See TracChangeset for help on using the changeset viewer.