Index: pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp
===================================================================
--- pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp	(revision 692)
+++ pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp	(revision 788)
@@ -7,4 +7,29 @@
 
 #include "test.h"
+#include <stdlib.h>
+#include <pj/errno.h>
+#include <pj/os.h>
+#include <pj/log.h>
+#include <pj/unicode.h>
+#include <stdio.h>
+
+#include <e32std.h>
+
+#if 0
+int main()
+{
+    int err = 0;
+    int exp = 0;
+
+    err = test_main();
+    //err = test_main();
+
+    if (err)
+	return err;
+    return exp;
+    //return 0;
+}
+
+#else
 #include <pj/os.h>
 
@@ -13,10 +38,4 @@
 #include <e32cons.h>            // Console
 
-
-//  Constants
-
-_LIT(KTextConsoleTitle, "Console");
-_LIT(KTextFailed, " failed, leave code = %d");
-_LIT(KTextPressAnyKey, " [press any key]\n");
 
 
@@ -29,10 +48,85 @@
 
 LOCAL_C void MainL()
-    {
+{
     //
     // add your program code here, example code below
     //
     test_main();
-    }
+    CActiveScheduler::Stop();
+}
+
+class MyScheduler : public CActiveScheduler
+{
+public:
+    MyScheduler()
+    {}
+
+    void Error(TInt aError) const;
+};
+
+void MyScheduler::Error(TInt aError) const
+{
+    int i = 0;
+}
+
+class ProgramStarter : public CActive
+{
+public:
+    static ProgramStarter *NewL();
+    void Start();
+
+protected:
+    ProgramStarter();
+    void ConstructL();
+    virtual void RunL();
+    virtual void DoCancel();
+    TInt RunError(TInt aError);
+
+private:
+    RTimer timer_;
+};
+
+ProgramStarter::ProgramStarter()
+: CActive(EPriorityNormal)
+{
+}
+
+void ProgramStarter::ConstructL()
+{
+    timer_.CreateLocal();
+    CActiveScheduler::Add(this);
+}
+
+ProgramStarter *ProgramStarter::NewL()
+{
+    ProgramStarter *self = new (ELeave) ProgramStarter;
+    CleanupStack::PushL(self);
+
+    self->ConstructL();
+
+    CleanupStack::Pop(self);
+    return self;
+}
+
+void ProgramStarter::Start()
+{
+    timer_.After(iStatus, 0);
+    SetActive();
+}
+
+void ProgramStarter::RunL()
+{
+    MainL();
+}
+
+void ProgramStarter::DoCancel()
+{
+}
+
+TInt ProgramStarter::RunError(TInt aError)
+{
+    PJ_UNUSED_ARG(aError);
+    return KErrNone;
+}
 
 
@@ -40,16 +134,32 @@
     {
     // Create active scheduler (to run active objects)
-    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+    CActiveScheduler* scheduler = new (ELeave) MyScheduler;
     CleanupStack::PushL(scheduler);
     CActiveScheduler::Install(scheduler);
 
-    MainL();
+    ProgramStarter *starter = ProgramStarter::NewL();
+    starter->Start();
+
+    CActiveScheduler::Start();
 
     // Delete active scheduler
-    CleanupStack::PopAndDestroy(scheduler);
+    //CActiveScheduler::Install(NULL);
+    scheduler->Stop();
+    //delete scheduler;
     }
 
 
 //  Global Functions
+
+static void log_writer(int level, const char *buf, int len)
+{
+    wchar_t buf16[PJ_LOG_MAX_SIZE];
+
+    pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16));
+
+    TPtrC16 aBuf((const TUint16*)buf16, (TInt)len);
+    console->Write(aBuf);
+}
+
 
 GLDEF_C TInt E32Main()
@@ -60,13 +170,15 @@
 
     // Create output console
-    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
+    TRAPD(createError, console = Console::NewL(_L("Console"), TSize(KConsFullScreen,KConsFullScreen)));
     if (createError)
         return createError;
+
+    pj_log_set_log_func(&log_writer);
 
     // Run application code inside TRAP harness, wait keypress when terminated
     TRAPD(mainError, DoStartL());
     if (mainError)
-        console->Printf(KTextFailed, mainError);
-    console->Printf(KTextPressAnyKey);
+        console->Printf(_L(" failed, leave code = %d"), mainError);
+    console->Printf(_L(" [press any key]\n"));
     console->Getch();
     
@@ -76,2 +188,5 @@
     return KErrNone;
     }
+
+#endif	/* if 0 */
+
