Ignore:
Timestamp:
Apr 23, 2013 10:59:52 AM (11 years ago)
Author:
nanang
Message:

Re #1655: Fixes on WM and Symbian due to latest pjsua framework changes.

Location:
pjproject/trunk/pjsip-apps/src/pjsua/symbian
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/symbian/group/pjsua.mmp

    r4477 r4492  
    102102SOURCEPATH              ..\.. 
    103103 
    104 SOURCE                  pjsua_cli.c pjsua_legacy.c 
    105 SOURCE                  pjsua_app.c pjsua_common.c pjsua_config.c 
     104SOURCE                  pjsua_app_cli.c pjsua_app_legacy.c 
     105SOURCE                  pjsua_app.c pjsua_app_common.c pjsua_app_config.c 
  • pjproject/trunk/pjsip-apps/src/pjsua/symbian/src/pjsuaAppUi.cpp

    r4477 r4492  
    2424 
    2525#include "../../pjsua_app.h" 
     26#include "../../pjsua_app_config.h" 
    2627 
    2728/* Global vars */ 
    2829static CpjsuaAppUi *appui = NULL; 
    2930static pj_ioqueue_t *app_ioqueue = NULL; 
    30 static int restart_argc = 0; 
    31 static char **restart_argv = NULL; 
     31static int start_argc = 0; 
     32static char **start_argv = NULL; 
     33 
     34static pj_status_t InitSymbSocket(); 
     35static void DestroySymbSocket(); 
    3236 
    3337/* Helper funtions to init/restart/destroy the pjsua */ 
    34 static void LibInitL(); 
    35 static void LibDestroyL(); 
    36 static void LibRestartL(); 
     38static void PjsuaInitL(); 
     39static void PjsuaDestroyL(); 
    3740 
    3841/* pjsua app callbacks */ 
    39 static void lib_on_started(pj_status_t status, const char* title); 
    40 static pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv); 
    41 static void lib_on_config_init(pjsua_app_config *cfg); 
     42static void PjsuaOnStarted(pj_status_t status, const char* title); 
     43static void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv); 
     44static void PjsuaOnConfig(pjsua_app_config *cfg); 
    4245 
    4346/* Helper class to schedule function execution */ 
     
    209212        Cba()->MakeVisible(EFalse); 
    210213 
    211         // Schedule Lib Init 
    212         MyTimer::NewL(100, &LibInitL); 
     214        if (InitSymbSocket() != PJ_SUCCESS) { 
     215            PutMsg("Failed to initialize Symbian network param."); 
     216        } else {         
     217            start_argc = pjsua_app_def_argc; 
     218            start_argv = (char**)pjsua_app_def_argv; 
     219 
     220            // Schedule Lib Init 
     221            MyTimer::NewL(100, &PjsuaInitL); 
     222        } 
     223         
    213224        } 
    214225 
     
    216227void CpjsuaAppUi::PrepareToExit() 
    217228{ 
    218     TRAPD(result, LibDestroyL()); 
     229    TRAPD(result, PjsuaDestroyL()); 
     230    DestroySymbSocket(); 
     231    CloseSTDLIB(); 
    219232    CAknViewAppUi::PrepareToExit(); 
    220233} 
     
    232245 
    233246/* Called when pjsua is started */ 
    234 void lib_on_started(pj_status_t status, const char* title) 
    235 { 
     247void PjsuaOnStarted(pj_status_t status, const char* title) 
     248{ 
     249    char err_msg[128]; 
     250 
     251    if (status != PJ_SUCCESS || title == NULL) { 
     252        char err_str[PJ_ERR_MSG_SIZE]; 
     253        pj_strerror(status, err_str, sizeof(err_str)); 
     254        pj_ansi_snprintf(err_msg, sizeof(err_msg), "%s: %s", 
     255                         (title?title:"App start error"), err_str); 
     256        title = err_msg; 
     257    } 
     258 
    236259    appui->PutMsg(title); 
    237260} 
    238261 
    239262/* Called when pjsua is stopped */ 
    240 pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv) 
     263void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv) 
    241264{ 
    242265    if (restart) { 
    243         restart_argc = argc; 
    244         restart_argv = argv; 
     266        start_argc = argc; 
     267        start_argv = argv; 
    245268 
    246269        // Schedule Lib Init 
    247         MyTimer::NewL(100, &LibRestartL); 
     270        MyTimer::NewL(100, &PjsuaInitL); 
    248271    } else { 
    249272        /* Destroy & quit GUI, e.g: clean up window, resources  */ 
    250273        appui->Exit(); 
    251274    } 
    252  
    253     return PJ_FALSE; 
    254275} 
    255276 
     
    257278 * We need to override some settings here. 
    258279 */ 
    259 void lib_on_config_init(pjsua_app_config *cfg) 
     280void PjsuaOnConfig(pjsua_app_config *cfg) 
    260281{ 
    261282    /* Disable threading */ 
     
    272293} 
    273294 
    274 void LibInitL() 
     295// Set Symbian OS parameters in pjlib. 
     296// This must be done before pj_init() is called. 
     297pj_status_t InitSymbSocket() 
    275298{ 
    276299    pj_symbianos_params sym_params; 
    277     char* argv[] = { 
    278         "", 
    279         "--use-cli", 
    280         "--cli-telnet-port=0", 
    281         "--no-cli-console" 
    282     }; 
    283     app_cfg_t app_cfg; 
    284     pj_status_t status; 
    285300    TInt err; 
    286  
     301     
    287302    // Initialize RSocketServ 
    288303    if ((err=aSocketServer.Connect(32)) != KErrNone) { 
    289         status = PJ_STATUS_FROM_OS(err); 
    290         goto on_return; 
     304        return PJ_STATUS_FROM_OS(err); 
    291305    } 
    292306     
     
    294308    if ((err=aConn.Open(aSocketServer)) != KErrNone) { 
    295309        aSocketServer.Close(); 
    296         status = PJ_STATUS_FROM_OS(err); 
    297         goto on_return; 
     310        return PJ_STATUS_FROM_OS(err); 
    298311    } 
    299312    if ((err=aConn.Start()) != KErrNone) { 
    300313        aConn.Close(); 
    301         aSocketServer.Close(); 
    302         status = PJ_STATUS_FROM_OS(err); 
    303         goto on_return; 
    304     } 
    305      
    306     // Set Symbian OS parameters in pjlib. 
    307     // This must be done before pj_init() is called. 
     314        aSocketServer.Close(); 
     315        return PJ_STATUS_FROM_OS(err); 
     316    } 
     317     
    308318    pj_bzero(&sym_params, sizeof(sym_params)); 
    309319    sym_params.rsocketserv = &aSocketServer; 
    310320    sym_params.rconnection = &aConn; 
    311321    pj_symbianos_set_params(&sym_params); 
    312  
     322     
     323    return PJ_SUCCESS; 
     324} 
     325 
     326 
     327void DestroySymbSocket() 
     328{ 
     329    aConn.Close(); 
     330    aSocketServer.Close(); 
     331} 
     332 
     333 
     334void PjsuaInitL() 
     335{ 
     336    pjsua_app_cfg_t app_cfg; 
     337    pj_status_t status; 
     338     
     339    PjsuaDestroyL(); 
     340     
    313341    pj_bzero(&app_cfg, sizeof(app_cfg)); 
    314     app_cfg.argc = PJ_ARRAY_SIZE(argv); 
    315     app_cfg.argv = argv; 
    316     app_cfg.on_started = &lib_on_started; 
    317     app_cfg.on_stopped = &lib_on_stopped; 
    318     app_cfg.on_config_init = &lib_on_config_init; 
     342    app_cfg.argc = start_argc; 
     343    app_cfg.argv = start_argv; 
     344    app_cfg.on_started = &PjsuaOnStarted; 
     345    app_cfg.on_stopped = &PjsuaOnStopped; 
     346    app_cfg.on_config_init = &PjsuaOnConfig; 
    319347 
    320348    appui->PutMsg("Initializing.."); 
    321     status = app_init(&app_cfg); 
     349    status = pjsua_app_init(&app_cfg); 
    322350    if (status != PJ_SUCCESS) 
    323351        goto on_return; 
    324352     
    325353    appui->PutMsg("Starting.."); 
    326     status = app_run(PJ_FALSE); 
     354    status = pjsua_app_run(PJ_FALSE); 
    327355    if (status != PJ_SUCCESS) 
    328356        goto on_return; 
     
    333361} 
    334362 
    335 void LibDestroyL() 
     363void PjsuaDestroyL() 
    336364{ 
    337365    if (app_ioqueue) { 
     
    339367        app_ioqueue = NULL; 
    340368    } 
    341     app_destroy(); 
    342     CloseSTDLIB(); 
    343 } 
    344  
    345 void LibRestartL() 
    346 { 
    347     app_cfg_t app_cfg; 
    348     pj_status_t status; 
    349      
    350     /* Destroy pjsua app first */ 
    351  
    352     if (app_ioqueue) { 
    353         pj_ioqueue_destroy(app_ioqueue); 
    354         app_ioqueue = NULL; 
    355     } 
    356     app_destroy(); 
    357  
    358     /* Reinit pjsua app */ 
    359      
    360     pj_bzero(&app_cfg, sizeof(app_cfg)); 
    361     app_cfg.argc = restart_argc; 
    362     app_cfg.argv = restart_argv; 
    363     app_cfg.on_started = &lib_on_started; 
    364     app_cfg.on_stopped = &lib_on_stopped; 
    365     app_cfg.on_config_init = &lib_on_config_init; 
    366  
    367     status = app_init(&app_cfg); 
    368     if (status != PJ_SUCCESS) { 
    369         appui->PutMsg("app_init() failed"); 
    370         return; 
    371     } 
    372          
    373     /* Run pjsua app */ 
    374  
    375     status = app_run(PJ_FALSE); 
    376     if (status != PJ_SUCCESS) { 
    377         appui->PutMsg("app_run() failed"); 
    378         return; 
    379     } 
    380 } 
     369    pjsua_app_destroy(); 
     370} 
Note: See TracChangeset for help on using the changeset viewer.