summaryrefslogtreecommitdiff
path: root/pjsip-apps/src
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2009-03-02 15:48:45 +0000
committerNanang Izzuddin <nanang@teluu.com>2009-03-02 15:48:45 +0000
commitc205201320f80d9e25e554566da5b7f11203f871 (patch)
tree9c36ccb99099beae87670633c72e63358c95df80 /pjsip-apps/src
parent33e9dc9f2613a86b0fcfea7d669d1b83934d45fd (diff)
Ticket #732:
- Added new Symbian specific API in PJLIB, pj_symbianos_set_connection_status(), to let PJLIB knows the connection status. - Added connection status checks before Symbian socket operations. - Added loop limiter in Symbian busy_sleep() to avoid the possibility of infinite loop. - Added sample of connection monitor in Symbian sample application (ua.cpp). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2481 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src')
-rw-r--r--pjsip-apps/src/symbian_ua/ua.cpp104
1 files changed, 103 insertions, 1 deletions
diff --git a/pjsip-apps/src/symbian_ua/ua.cpp b/pjsip-apps/src/symbian_ua/ua.cpp
index 442b0521..11adb154 100644
--- a/pjsip-apps/src/symbian_ua/ua.cpp
+++ b/pjsip-apps/src/symbian_ua/ua.cpp
@@ -441,6 +441,7 @@ class ConsoleUI : public CActive
{
public:
ConsoleUI(CConsoleBase *con);
+ ~ConsoleUI();
// Run console UI
void Run();
@@ -466,6 +467,11 @@ ConsoleUI::ConsoleUI(CConsoleBase *con)
CActiveScheduler::Add(this);
}
+ConsoleUI::~ConsoleUI()
+{
+ Stop();
+}
+
// Run console UI
void ConsoleUI::Run()
{
@@ -476,7 +482,7 @@ void ConsoleUI::Run()
// Stop console UI
void ConsoleUI::Stop()
{
- DoCancel();
+ Cancel();
}
// Cancel asynchronous read.
@@ -730,6 +736,96 @@ static void SelectIAP()
#endif
+// Class CConnMon to monitor network connection (RConnection). Whenever
+// the connection is down, it will notify PJLIB and restart PJSUA-LIB.
+class CConnMon : public CActive {
+public:
+ static CConnMon* NewL(RConnection &conn, RSocketServ &sserver) {
+ CConnMon *self = new (ELeave) CConnMon(conn, sserver);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+ void Start() {
+ conn_.ProgressNotification(nif_progress_, iStatus);
+ SetActive();
+ }
+
+ void Stop() {
+ Cancel();
+ }
+
+ ~CConnMon() { Stop(); }
+
+private:
+ CConnMon(RConnection &conn, RSocketServ &sserver) :
+ CActive(EPriorityHigh),
+ conn_(conn),
+ sserver_(sserver)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+ void ConstructL() {}
+
+ void DoCancel() {
+ conn_.CancelProgressNotification();
+ }
+
+ void RunL() {
+ int stage = nif_progress_().iStage;
+
+ if (stage == KLinkLayerClosed) {
+ pj_status_t status;
+ TInt err;
+
+ // Tell pjlib that connection is down.
+ pj_symbianos_set_connection_status(PJ_FALSE);
+
+ PJ_LOG(3, (THIS_FILE, "RConnection closed, restarting PJSUA.."));
+
+ // Destroy pjsua
+ pjsua_destroy();
+ PJ_LOG(3, (THIS_FILE, "PJSUA destroyed."));
+
+ // Reopen the connection
+ err = conn_.Open(sserver_);
+ if (err == KErrNone)
+ err = conn_.Start();
+ if (err != KErrNone) {
+ CActiveScheduler::Stop();
+ return;
+ }
+
+ // Reinit Symbian OS param before pj_init()
+ pj_symbianos_params sym_params;
+ pj_bzero(&sym_params, sizeof(sym_params));
+ sym_params.rsocketserv = &sserver_;
+ sym_params.rconnection = &conn_;
+ pj_symbianos_set_params(&sym_params);
+
+ // Reinit pjsua
+ status = app_startup();
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "app_startup() error", status);
+ CActiveScheduler::Stop();
+ return;
+ }
+
+ PJ_LOG(3, (THIS_FILE, "PJSUA restarted."));
+ PrintMenu();
+ }
+
+ Start();
+ }
+
+ RConnection& conn_;
+ RSocketServ& sserver_;
+ TNifProgressBuf nif_progress_;
+};
+
////////////////////////////////////////////////////////////////////////////
int ua_main()
{
@@ -772,14 +868,20 @@ int ua_main()
return status;
}
+
// Run the UI
ConsoleUI *con = new ConsoleUI(console);
con->Run();
PrintMenu();
+ // Init & start connection monitor
+ CConnMon *connmon = CConnMon::NewL(aConn, aSocketServer);
+ connmon->Start();
+
CActiveScheduler::Start();
+ delete connmon;
delete con;
// Dump memory statistics