- Timestamp:
- Mar 2, 2009 3:50:12 PM (16 years ago)
- Location:
- pjproject/branches/1.0
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.0/pjlib/include/pj/os.h
r2394 r2482 395 395 PJ_DECL(pj_status_t) pj_symbianos_set_params(pj_symbianos_params *prm); 396 396 397 /** 398 * Notify PJLIB that the access point connection has been down or unusable 399 * and PJLIB should not try to access the Symbian socket API (especially ones 400 * that send packets). Sending packet when RConnection is reconnected to 401 * different access point may cause the WaitForRequest() for the function to 402 * block indefinitely. 403 * 404 * @param up If set to PJ_FALSE it will cause PJLIB to not try 405 * to access socket API, and error will be returned 406 * immediately instead. 407 */ 408 PJ_DECL(void) pj_symbianos_set_connection_status(pj_bool_t up); 397 409 398 410 /** -
pjproject/branches/1.0/pjlib/src/pj/addr_resolv_symbian.cpp
r2394 r2482 72 72 PJ_ASSERT_RETURN(name && count && ai, PJ_EINVAL); 73 73 74 // Return failure if access point is marked as down by app. 75 PJ_SYMBIAN_CHECK_CONNECTION(); 76 74 77 // Get resolver for the specified address family 75 78 RHostResolver &resv = PjSymbianOS::Instance()->GetResolver(af); -
pjproject/branches/1.0/pjlib/src/pj/ioqueue_symbian.cpp
r2394 r2482 636 636 TRequestStatus reqStatus; 637 637 638 // Return failure if access point is marked as down by app. 639 PJ_SYMBIAN_CHECK_CONNECTION(); 640 638 641 // Convert address 639 642 status = PjSymbianOS::pj2Addr(*(const pj_sockaddr*)addr, addrlen, … … 748 751 PJ_ASSERT_RETURN((flags & PJ_IOQUEUE_ALWAYS_ASYNC)==0, PJ_EINVAL); 749 752 753 // Return failure if access point is marked as down by app. 754 PJ_SYMBIAN_CHECK_CONNECTION(); 755 750 756 // Clear flag 751 757 flags &= ~PJ_IOQUEUE_ALWAYS_ASYNC; … … 786 792 PJ_ASSERT_RETURN((flags & PJ_IOQUEUE_ALWAYS_ASYNC)==0, PJ_EINVAL); 787 793 794 // Return failure if access point is marked as down by app. 795 PJ_SYMBIAN_CHECK_CONNECTION(); 796 788 797 // Convert address 789 798 status = PjSymbianOS::pj2Addr(*(const pj_sockaddr*)addr, addrlen, -
pjproject/branches/1.0/pjlib/src/pj/os_core_symbian.cpp
r2394 r2482 152 152 153 153 PjSymbianOS::PjSymbianOS() 154 : isSocketServInitialized_(false), isResolverInitialized_(false), 154 : isConnectionUp_(false), 155 isSocketServInitialized_(false), isResolverInitialized_(false), 155 156 console_(NULL), selectTimeoutTimer_(NULL), 156 157 appSocketServ_(NULL), appConnection_(NULL), appHostResolver_(NULL), … … 230 231 } 231 232 233 isConnectionUp_ = true; 234 232 235 return KErrNone; 233 236 … … 240 243 void PjSymbianOS::Shutdown() 241 244 { 245 isConnectionUp_ = false; 246 242 247 if (isResolverInitialized_) { 243 248 hostResolver_.Close(); … … 253 258 } 254 259 255 if (console_) { 256 delete console_; 257 console_ = NULL; 258 } 259 260 if (selectTimeoutTimer_) { 261 delete selectTimeoutTimer_; 262 selectTimeoutTimer_ = NULL; 263 } 260 delete console_; 261 console_ = NULL; 262 263 delete selectTimeoutTimer_; 264 selectTimeoutTimer_ = NULL; 265 266 appSocketServ_ = NULL; 267 appConnection_ = NULL; 268 appHostResolver_ = NULL; 269 appHostResolver6_ = NULL; 264 270 } 265 271 … … 304 310 PjSymbianOS::Instance()->SetParameters(prm); 305 311 return PJ_SUCCESS; 312 } 313 314 315 /* Set connection status */ 316 PJ_DEF(void) pj_symbianos_set_connection_status(pj_bool_t up) 317 { 318 PjSymbianOS::Instance()->SetConnectionStatus(up != 0); 306 319 } 307 320 -
pjproject/branches/1.0/pjlib/src/pj/os_symbian.h
r2394 r2482 314 314 } 315 315 316 // 317 // Return true if the access point connection is up 318 // 319 bool IsConnectionUp() const 320 { 321 return isConnectionUp_; 322 } 323 324 // 325 // Set access point connection status 326 // 327 void SetConnectionStatus(bool up) 328 { 329 isConnectionUp_ = up; 330 } 316 331 317 332 // … … 354 369 355 370 private: 371 bool isConnectionUp_; 372 356 373 bool isSocketServInitialized_; 357 374 RSocketServ socketServ_; … … 375 392 }; 376 393 394 // This macro is used to check the access point connection status and return 395 // failure if the AP connection is down or unusable. See the documentation 396 // of pj_symbianos_set_connection_status() for more info 397 #define PJ_SYMBIAN_CHECK_CONNECTION() \ 398 PJ_SYMBIAN_CHECK_CONNECTION2(PJ_ECANCELLED) 399 400 #define PJ_SYMBIAN_CHECK_CONNECTION2(retval) \ 401 do { \ 402 if (!PjSymbianOS::Instance()->IsConnectionUp()) \ 403 return retval; \ 404 } while (0); 377 405 378 406 #endif /* __OS_SYMBIAN_H__ */ -
pjproject/branches/1.0/pjlib/src/pj/sock_symbian.cpp
r2394 r2482 464 464 THostName tmpName; 465 465 466 // Return empty hostname if access point is marked as down by app. 467 PJ_SYMBIAN_CHECK_CONNECTION2(&hostname); 468 466 469 resv.GetHostName(tmpName, reqStatus); 467 470 User::WaitForRequest(reqStatus); … … 489 492 PJ_ASSERT_RETURN(p_sock!=NULL, PJ_EINVAL); 490 493 494 // Return failure if access point is marked as down by app. 495 PJ_SYMBIAN_CHECK_CONNECTION(); 496 491 497 /* Set proto if none is specified. */ 492 498 if (proto == 0) { … … 643 649 PJ_ASSERT_RETURN(sock && buf && len, PJ_EINVAL); 644 650 651 // Return failure if access point is marked as down by app. 652 PJ_SYMBIAN_CHECK_CONNECTION(); 653 645 654 CPjSocket *pjSock = (CPjSocket*)sock; 646 655 RSocket &rSock = pjSock->Socket(); … … 679 688 PJ_ASSERT_RETURN(sock && buf && len, PJ_EINVAL); 680 689 690 // Return failure if access point is marked as down by app. 691 PJ_SYMBIAN_CHECK_CONNECTION(); 692 681 693 CPjSocket *pjSock = (CPjSocket*)sock; 682 694 RSocket &rSock = pjSock->Socket(); … … 717 729 PJ_ASSERT_RETURN(sock && buf && len, PJ_EINVAL); 718 730 PJ_ASSERT_RETURN(*len > 0, PJ_EINVAL); 731 732 // Return failure if access point is marked as down by app. 733 PJ_SYMBIAN_CHECK_CONNECTION(); 719 734 720 735 CPjSocket *pjSock = (CPjSocket*)sock; … … 771 786 PJ_ASSERT_RETURN(*len > 0, PJ_EINVAL); 772 787 PJ_ASSERT_RETURN(*fromlen >= (int)sizeof(pj_sockaddr_in), PJ_EINVAL); 788 789 // Return failure if access point is marked as down by app. 790 PJ_SYMBIAN_CHECK_CONNECTION(); 773 791 774 792 CPjSocket *pjSock = (CPjSocket*)sock; … … 869 887 PJ_EINVAL); 870 888 889 // Return failure if access point is marked as down by app. 890 PJ_SYMBIAN_CHECK_CONNECTION(); 891 871 892 CPjSocket *pjSock = (CPjSocket*)sock; 872 893 RSocket &rSock = pjSock->Socket(); -
pjproject/branches/1.0/pjsip-apps/src/symbian_ua/ua.cpp
r2394 r2482 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 -
pjproject/branches/1.0/pjsip/src/pjsua-lib/pjsua_core.c
r2394 r2482 836 836 837 837 do { 838 while (pjsua_handle_events(10) > 0) 839 ; 838 int i; 839 i = msec / 10; 840 while (pjsua_handle_events(10) > 0 && i > 0) 841 --i; 840 842 pj_gettimeofday(&now); 841 843 } while (PJ_TIME_VAL_LT(now, timeout));
Note: See TracChangeset
for help on using the changeset viewer.