Changeset 2481 for pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
- Timestamp:
- Mar 2, 2009 3:48:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
r2394 r2481 442 442 public: 443 443 ConsoleUI(CConsoleBase *con); 444 ~ConsoleUI(); 444 445 445 446 // Run console UI … … 467 468 } 468 469 470 ConsoleUI::~ConsoleUI() 471 { 472 Stop(); 473 } 474 469 475 // Run console UI 470 476 void ConsoleUI::Run() … … 477 483 void ConsoleUI::Stop() 478 484 { 479 DoCancel();485 Cancel(); 480 486 } 481 487 … … 731 737 732 738 739 // Class CConnMon to monitor network connection (RConnection). Whenever 740 // the connection is down, it will notify PJLIB and restart PJSUA-LIB. 741 class CConnMon : public CActive { 742 public: 743 static CConnMon* NewL(RConnection &conn, RSocketServ &sserver) { 744 CConnMon *self = new (ELeave) CConnMon(conn, sserver); 745 CleanupStack::PushL(self); 746 self->ConstructL(); 747 CleanupStack::Pop(self); 748 return self; 749 } 750 751 void Start() { 752 conn_.ProgressNotification(nif_progress_, iStatus); 753 SetActive(); 754 } 755 756 void Stop() { 757 Cancel(); 758 } 759 760 ~CConnMon() { Stop(); } 761 762 private: 763 CConnMon(RConnection &conn, RSocketServ &sserver) : 764 CActive(EPriorityHigh), 765 conn_(conn), 766 sserver_(sserver) 767 { 768 CActiveScheduler::Add(this); 769 } 770 771 void ConstructL() {} 772 773 void DoCancel() { 774 conn_.CancelProgressNotification(); 775 } 776 777 void RunL() { 778 int stage = nif_progress_().iStage; 779 780 if (stage == KLinkLayerClosed) { 781 pj_status_t status; 782 TInt err; 783 784 // Tell pjlib that connection is down. 785 pj_symbianos_set_connection_status(PJ_FALSE); 786 787 PJ_LOG(3, (THIS_FILE, "RConnection closed, restarting PJSUA..")); 788 789 // Destroy pjsua 790 pjsua_destroy(); 791 PJ_LOG(3, (THIS_FILE, "PJSUA destroyed.")); 792 793 // Reopen the connection 794 err = conn_.Open(sserver_); 795 if (err == KErrNone) 796 err = conn_.Start(); 797 if (err != KErrNone) { 798 CActiveScheduler::Stop(); 799 return; 800 } 801 802 // Reinit Symbian OS param before pj_init() 803 pj_symbianos_params sym_params; 804 pj_bzero(&sym_params, sizeof(sym_params)); 805 sym_params.rsocketserv = &sserver_; 806 sym_params.rconnection = &conn_; 807 pj_symbianos_set_params(&sym_params); 808 809 // Reinit pjsua 810 status = app_startup(); 811 if (status != PJ_SUCCESS) { 812 pjsua_perror(THIS_FILE, "app_startup() error", status); 813 CActiveScheduler::Stop(); 814 return; 815 } 816 817 PJ_LOG(3, (THIS_FILE, "PJSUA restarted.")); 818 PrintMenu(); 819 } 820 821 Start(); 822 } 823 824 RConnection& conn_; 825 RSocketServ& sserver_; 826 TNifProgressBuf nif_progress_; 827 }; 828 733 829 //////////////////////////////////////////////////////////////////////////// 734 830 int ua_main() … … 773 869 } 774 870 871 775 872 // Run the UI 776 873 ConsoleUI *con = new ConsoleUI(console); … … 779 876 PrintMenu(); 780 877 878 // Init & start connection monitor 879 CConnMon *connmon = CConnMon::NewL(aConn, aSocketServer); 880 connmon->Start(); 881 781 882 CActiveScheduler::Start(); 782 883 884 delete connmon; 783 885 delete con; 784 886
Note: See TracChangeset
for help on using the changeset viewer.