Index: pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp
===================================================================
--- pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp	(revision 2378)
+++ pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp	(revision 2379)
@@ -526,5 +526,5 @@
 
     // Cancel pending async object
-    if (key->cbObj && key->cbObj->IsActive()) {
+    if (key->cbObj) {
 	key->cbObj->Cancel();
     }
Index: pjproject/trunk/pjlib/src/pj/os_core_symbian.cpp
===================================================================
--- pjproject/trunk/pjlib/src/pj/os_core_symbian.cpp	(revision 2378)
+++ pjproject/trunk/pjlib/src/pj/os_core_symbian.cpp	(revision 2379)
@@ -90,6 +90,5 @@
 CPjTimeoutTimer::~CPjTimeoutTimer()
 {
-    if (IsActive())
-	Cancel();
+    Cancel();
     timer_.Close();
 }
@@ -116,6 +115,5 @@
 void CPjTimeoutTimer::StartTimer(TUint miliSeconds)
 {
-    if (IsActive())
-	Cancel();
+    Cancel();
 
     hasTimedOut_ = PJ_FALSE;
@@ -330,5 +328,5 @@
     err = os->Initialize();
     if (err != KErrNone)
-    	return status;
+    	return PJ_RETURN_OS_ERROR(err);
     
     /* Initialize exception ID for the pool. 
@@ -453,5 +451,5 @@
     
     if (priority==-1)
-    	priority = CActive::EPriorityStandard;
+    	priority = EPriorityNull;
     
     if (ms_timeout >= 0) {
@@ -464,6 +462,5 @@
         bool timer_is_active = timer->IsActive();
     
-        if (timer_is_active)
-            timer->Cancel();
+	timer->Cancel();
         
         delete timer;
@@ -623,9 +620,5 @@
 {
     User::After(msec*1000);
-    
-    TInt aError;
-    while (CActiveScheduler::RunIfReady(aError, EPriorityMuchLess))
-    	;
-    
+
     return PJ_SUCCESS;
 }
Index: pjproject/trunk/pjlib/src/pj/os_symbian.h
===================================================================
--- pjproject/trunk/pjlib/src/pj/os_symbian.h	(revision 2378)
+++ pjproject/trunk/pjlib/src/pj/os_symbian.h	(revision 2379)
@@ -348,5 +348,5 @@
     {
 	TInt aError;
-	User::WaitForAnyRequest();
+	CActiveScheduler::Current()->WaitForAnyRequest();
 	CActiveScheduler::RunIfReady(aError, aPriority);
     }
Index: pjproject/trunk/pjlib/src/pj/sock_symbian.cpp
===================================================================
--- pjproject/trunk/pjlib/src/pj/sock_symbian.cpp	(revision 2378)
+++ pjproject/trunk/pjlib/src/pj/sock_symbian.cpp	(revision 2379)
@@ -102,6 +102,5 @@
 {
     if (sockReader_) {
-	if (sockReader_->IsActive())
-	    sockReader_->Cancel();
+	sockReader_->Cancel();
 	delete sockReader_;
 	sockReader_ = NULL;
Index: pjproject/trunk/pjlib/src/pj/timer_symbian.cpp
===================================================================
--- pjproject/trunk/pjlib/src/pj/timer_symbian.cpp	(revision 2378)
+++ pjproject/trunk/pjlib/src/pj/timer_symbian.cpp	(revision 2379)
@@ -79,6 +79,5 @@
 CPjTimerEntry::~CPjTimerEntry() 
 {
-    if (IsActive())
-	Cancel();
+    Cancel();
     rtimer_.Close();
 }
Index: pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/sound_port.c	(revision 2378)
+++ pjproject/trunk/pjmedia/src/pjmedia/sound_port.c	(revision 2379)
@@ -372,6 +372,4 @@
 {
     pjmedia_snd_port *snd_port;
-    pj_status_t status;
-    unsigned ptime;
 
     PJ_ASSERT_RETURN(pool && p_port, PJ_EINVAL);
@@ -390,15 +388,17 @@
     
 #if PJMEDIA_SOUND_USE_DELAYBUF
-    ptime = samples_per_frame * 1000 / (clock_rate * channel_count);
-
-    status = pjmedia_delay_buf_create(pool, "snd_buff", 
-				      clock_rate, samples_per_frame,
-				      channel_count,
-				      PJMEDIA_SOUND_BUFFER_COUNT * ptime,
-				      0, &snd_port->delay_buf);
-    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
-#else
-    PJ_UNUSED_ARG(status);
-    PJ_UNUSED_ARG(ptime);
+    do {
+	pj_status_t status;
+	unsigned ptime;
+    
+	ptime = samples_per_frame * 1000 / (clock_rate * channel_count);
+    
+	status = pjmedia_delay_buf_create(pool, "snd_buff", 
+					  clock_rate, samples_per_frame,
+					  channel_count,
+					  PJMEDIA_SOUND_BUFFER_COUNT * ptime,
+					  0, &snd_port->delay_buf);
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
+    } while (0);
 #endif
 
Index: pjproject/trunk/pjmedia/src/pjmedia/symbian_sound.cpp
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/symbian_sound.cpp	(revision 2378)
+++ pjproject/trunk/pjmedia/src/pjmedia/symbian_sound.cpp	(revision 2379)
@@ -298,5 +298,5 @@
 	// Wait until it's actually stopped
     	while (lastError_ == KRequestPending)
-	    pj_thread_sleep(100);
+	    pj_symbianos_poll(-1, 100);
     }
 
@@ -534,5 +534,5 @@
 	// Wait until it's actually stopped
     	while (lastError_ == KRequestPending)
-	    pj_thread_sleep(100);
+	    pj_symbianos_poll(-1, 100);
     }
     
Index: pjproject/trunk/pjmedia/src/pjmedia/transport_adapter_sample.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/transport_adapter_sample.c	(revision 2378)
+++ pjproject/trunk/pjmedia/src/pjmedia/transport_adapter_sample.c	(revision 2379)
@@ -1,3 +1,3 @@
-/* $Id:$ */
+/* $Id$ */
 /* 
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -132,5 +132,6 @@
     pj_ansi_strncpy(adapter->base.name, pool->obj_name, 
 		    sizeof(adapter->base.name));
-    adapter->base.type = PJMEDIA_TRANSPORT_TYPE_USER + 1;
+    adapter->base.type = (pjmedia_transport_type)
+			 (PJMEDIA_TRANSPORT_TYPE_USER + 1);
     adapter->base.op = &tp_adapter_op;
 
Index: pjproject/trunk/pjmedia/src/pjmedia/wav_player.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/wav_player.c	(revision 2378)
+++ pjproject/trunk/pjmedia/src/pjmedia/wav_player.c	(revision 2379)
@@ -264,5 +264,5 @@
     }
 
-    fport->fmt_tag = wave_hdr.fmt_hdr.fmt_tag;
+    fport->fmt_tag = (pjmedia_wave_fmt_tag)wave_hdr.fmt_hdr.fmt_tag;
     fport->bytes_per_sample = (pj_uint16_t) 
 			      (wave_hdr.fmt_hdr.bits_per_sample / 8);
Index: pjproject/trunk/pjsip-apps/src/symbian_ua/main_symbian.cpp
===================================================================
--- pjproject/trunk/pjsip-apps/src/symbian_ua/main_symbian.cpp	(revision 2378)
+++ pjproject/trunk/pjsip-apps/src/symbian_ua/main_symbian.cpp	(revision 2379)
@@ -29,69 +29,6 @@
 
 // Needed by APS
-TPtrC APP_UID = _L("A000000E");
+TPtrC APP_UID = _L("A000000D");
 
-
-////////////////////////////////////////////////////////////////////////////
-class MyTask : public CActive
-{
-public:
-    static MyTask *NewL(CActiveSchedulerWait *asw);
-    ~MyTask();
-    void Start();
-
-protected:
-    MyTask(CActiveSchedulerWait *asw);
-    void ConstructL();
-    virtual void RunL();
-    virtual void DoCancel();
-
-private:
-    RTimer timer_;
-    CActiveSchedulerWait *asw_;
-};
-
-MyTask::MyTask(CActiveSchedulerWait *asw)
-: CActive(EPriorityNormal), asw_(asw)
-{
-}
-
-MyTask::~MyTask() 
-{
-    timer_.Close();
-}
-
-void MyTask::ConstructL()
-{
-    timer_.CreateLocal();
-    CActiveScheduler::Add(this);
-}
-
-MyTask *MyTask::NewL(CActiveSchedulerWait *asw)
-{
-    MyTask *self = new (ELeave) MyTask(asw);
-    CleanupStack::PushL(self);
-
-    self->ConstructL();
-
-    CleanupStack::Pop(self);
-    return self;
-}
-
-void MyTask::Start()
-{
-    timer_.After(iStatus, 0);
-    SetActive();
-}
-
-void MyTask::RunL()
-{
-    ua_main();
-    asw_->AsyncStop();
-}
-
-void MyTask::DoCancel()
-{
-
-}
 
 ////////////////////////////////////////////////////////////////////////////
@@ -103,16 +40,5 @@
     CActiveScheduler::Install(scheduler);
 
-    CActiveSchedulerWait *asw = new CActiveSchedulerWait;
-    CleanupStack::PushL(asw);
-    
-    MyTask *task = MyTask::NewL(asw);
-    task->Start();
-
-    asw->Start();
-    
-    delete task;
-    
-    CleanupStack::Pop(asw);
-    delete asw;
+    ua_main();
     
     CActiveScheduler::Install(NULL);
Index: pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
===================================================================
--- pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp	(revision 2378)
+++ pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp	(revision 2379)
@@ -38,5 +38,5 @@
 // Account
 //
-#define HAS_SIP_ACCOUNT	1	// 0 to disable registration
+#define HAS_SIP_ACCOUNT	0	// 1 to enable registration
 #define SIP_DOMAIN	"pjsip.lab"
 #define SIP_USER	"400"
@@ -54,6 +54,6 @@
 // or STUN (for STUN see other settings below)
 //
-//#define NAMESERVER	NULL
-#define NAMESERVER	"192.168.0.2"
+#define NAMESERVER	NULL
+//#define NAMESERVER	"192.168.0.2"
 
 //
@@ -250,4 +250,6 @@
 
 
+//#include<e32debug.h>
+
 /* Logging callback */
 static void log_writer(int level, const char *buf, int len)
@@ -260,4 +262,5 @@
 
     TPtrC16 aBuf((const TUint16*)buf16, (TInt)len);
+    //RDebug::Print(aBuf);
     console->Write(aBuf);
     
@@ -436,5 +439,5 @@
 {
 public:
-    ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con);
+    ConsoleUI(CConsoleBase *con);
 
     // Run console UI
@@ -452,11 +455,10 @@
     
 private:
-    CActiveSchedulerWait *asw_;
     CConsoleBase *con_;
 };
 
 
-ConsoleUI::ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con) 
-: CActive(EPriorityStandard), asw_(asw), con_(con)
+ConsoleUI::ConsoleUI(CConsoleBase *con) 
+: CActive(EPriorityStandard), con_(con)
 {
     CActiveScheduler::Add(this);
@@ -509,5 +511,5 @@
     switch (kc) {
     case 'w':
-	    asw_->AsyncStop();
+	    CActiveScheduler::Stop();
 	    reschedule = PJ_FALSE;
 	    break;
@@ -686,12 +688,55 @@
 #include <es_sock.h>
 
+#if 0
+// Force network connection to use the first IAP, 
+// this is useful for debugging on emulator without GUI. 
+// Include commdb.lib & apengine.lib in symbian_ua.mmp file
+// if this is enabled.
+
+#include <apdatahandler.h>
+
+inline void ForceUseFirstIAP() 
+{
+    TUint32 rank = 1;
+    TUint32 bearers;
+    TUint32 prompt;
+    TUint32 iap;
+
+    CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
+    CleanupStack::PushL(commDb);
+
+    CApDataHandler* apDataHandler = CApDataHandler::NewLC(*commDb);
+    
+    TCommDbConnectionDirection direction = ECommDbConnectionDirectionOutgoing;
+    apDataHandler->GetPreferredIfDbIapTypeL(rank, direction, bearers, prompt, iap);
+    prompt = ECommDbDialogPrefDoNotPrompt;
+    apDataHandler->SetPreferredIfDbIapTypeL(rank, direction, bearers, (TCommDbDialogPref)prompt, iap, ETrue);
+    CleanupStack::PopAndDestroy(2); // apDataHandler, commDb
+}
+
+static void SelectIAP() 
+{
+    ForceUseFirstIAP();
+}
+
+#else
+
+static void SelectIAP() 
+{
+}
+
+#endif
+
+
 ////////////////////////////////////////////////////////////////////////////
 int ua_main() 
 {
-	RSocketServ aSocketServer;
-	RConnection aConn;
-	TInt err;
-	pj_symbianos_params sym_params;
+    RSocketServ aSocketServer;
+    RConnection aConn;
+    TInt err;
+    pj_symbianos_params sym_params;
     pj_status_t status;
+
+    SelectIAP();
     
     // Initialize RSocketServ
@@ -701,6 +746,6 @@
     // Open up a connection
     if ((err=aConn.Open(aSocketServer)) != KErrNone) {
-	    aSocketServer.Close();
-		return PJ_STATUS_FROM_OS(err);
+	aSocketServer.Close();
+	return PJ_STATUS_FROM_OS(err);
     }
     
@@ -723,23 +768,21 @@
     	aConn.Close();
     	aSocketServer.Close();
-	    return status;
+	return status;
     }
 
     // Run the UI
-    CActiveSchedulerWait *asw = new CActiveSchedulerWait;
-    ConsoleUI *con = new ConsoleUI(asw, console);
+    ConsoleUI *con = new ConsoleUI(console);
     
     con->Run();
-    
     PrintMenu();
-    asw->Start();
+
+    CActiveScheduler::Start();
     
     delete con;
-    delete asw;
 
     // Dump memory statistics
     PJ_LOG(3,(THIS_FILE, "Max heap usage: %u.%03uMB",
-    		  pjsua_var.cp.peak_used_size / 1000000,
-    		  (pjsua_var.cp.peak_used_size % 1000000)/1000));
+	      pjsua_var.cp.peak_used_size / 1000000,
+	      (pjsua_var.cp.peak_used_size % 1000000)/1000));
     
     // check max stack usage
@@ -747,5 +790,5 @@
 	pj_thread_t* this_thread = pj_thread_this();
 	if (!this_thread)
-		return status;
+	    return status;
 	
 	const char* max_stack_file;
@@ -754,6 +797,6 @@
 	
 	PJ_LOG(3,(THIS_FILE, "Max stack usage: %u at %s:%d", 
-			pj_thread_get_stack_max_usage(this_thread), 
-			max_stack_file, max_stack_line));
+		  pj_thread_get_stack_max_usage(this_thread), 
+		  max_stack_file, max_stack_line));
 #endif
 	
@@ -763,5 +806,5 @@
     // Close connection and socket server
     aConn.Close();
-	aSocketServer.Close();
+    aSocketServer.Close();
 	
     return status;
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 2378)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 2379)
@@ -828,11 +828,4 @@
 static void busy_sleep(unsigned msec)
 {
-#if defined(PJ_SYMBIAN) && PJ_SYMBIAN != 0
-    /* Ideally we shouldn't call pj_thread_sleep() and rather
-     * CActiveScheduler::WaitForAnyRequest() here, but that will
-     * drag in Symbian header and it doesn't look pretty.
-     */
-    pj_thread_sleep(msec);
-#else
     pj_time_val timeout, now;
 
@@ -846,5 +839,4 @@
 	pj_gettimeofday(&now);
     } while (PJ_TIME_VAL_LT(now, timeout));
-#endif
 }
 
@@ -1204,10 +1196,7 @@
 {
 #if defined(PJ_SYMBIAN) && PJ_SYMBIAN != 0
-    /* Ideally we shouldn't call pj_thread_sleep() and rather
-     * CActiveScheduler::WaitForAnyRequest() here, but that will
-     * drag in Symbian header and it doesn't look pretty.
-     */
-    pj_thread_sleep(msec_timeout);
-    return msec_timeout;
+
+    return pj_symbianos_poll(-1, msec_timeout);
+
 #else
 
@@ -1226,4 +1215,5 @@
 
     return count;
+    
 #endif
 }
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 2378)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 2379)
@@ -777,5 +777,5 @@
 	uapres->expires = -1;
 
-    st_code = 200;
+    st_code = (pjsip_status_code)200;
     reason = pj_str("OK");
     pjsua_msg_data_init(&msg_data);
