Changeset 4492 for pjproject/trunk/pjsip-apps/src/pjsua/symbian
- Timestamp:
- Apr 23, 2013 10:59:52 AM (11 years ago)
- 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 102 102 SOURCEPATH ..\.. 103 103 104 SOURCE pjsua_ cli.c pjsua_legacy.c105 SOURCE pjsua_app.c pjsua_ common.c pjsua_config.c104 SOURCE pjsua_app_cli.c pjsua_app_legacy.c 105 SOURCE pjsua_app.c pjsua_app_common.c pjsua_app_config.c -
pjproject/trunk/pjsip-apps/src/pjsua/symbian/src/pjsuaAppUi.cpp
r4477 r4492 24 24 25 25 #include "../../pjsua_app.h" 26 #include "../../pjsua_app_config.h" 26 27 27 28 /* Global vars */ 28 29 static CpjsuaAppUi *appui = NULL; 29 30 static pj_ioqueue_t *app_ioqueue = NULL; 30 static int restart_argc = 0; 31 static char **restart_argv = NULL; 31 static int start_argc = 0; 32 static char **start_argv = NULL; 33 34 static pj_status_t InitSymbSocket(); 35 static void DestroySymbSocket(); 32 36 33 37 /* Helper funtions to init/restart/destroy the pjsua */ 34 static void LibInitL(); 35 static void LibDestroyL(); 36 static void LibRestartL(); 38 static void PjsuaInitL(); 39 static void PjsuaDestroyL(); 37 40 38 41 /* 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);42 static void PjsuaOnStarted(pj_status_t status, const char* title); 43 static void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv); 44 static void PjsuaOnConfig(pjsua_app_config *cfg); 42 45 43 46 /* Helper class to schedule function execution */ … … 209 212 Cba()->MakeVisible(EFalse); 210 213 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 213 224 } 214 225 … … 216 227 void CpjsuaAppUi::PrepareToExit() 217 228 { 218 TRAPD(result, LibDestroyL()); 229 TRAPD(result, PjsuaDestroyL()); 230 DestroySymbSocket(); 231 CloseSTDLIB(); 219 232 CAknViewAppUi::PrepareToExit(); 220 233 } … … 232 245 233 246 /* Called when pjsua is started */ 234 void lib_on_started(pj_status_t status, const char* title) 235 { 247 void 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 236 259 appui->PutMsg(title); 237 260 } 238 261 239 262 /* Called when pjsua is stopped */ 240 pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv)263 void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv) 241 264 { 242 265 if (restart) { 243 restart_argc = argc;244 restart_argv = argv;266 start_argc = argc; 267 start_argv = argv; 245 268 246 269 // Schedule Lib Init 247 MyTimer::NewL(100, & LibRestartL);270 MyTimer::NewL(100, &PjsuaInitL); 248 271 } else { 249 272 /* Destroy & quit GUI, e.g: clean up window, resources */ 250 273 appui->Exit(); 251 274 } 252 253 return PJ_FALSE;254 275 } 255 276 … … 257 278 * We need to override some settings here. 258 279 */ 259 void lib_on_config_init(pjsua_app_config *cfg)280 void PjsuaOnConfig(pjsua_app_config *cfg) 260 281 { 261 282 /* Disable threading */ … … 272 293 } 273 294 274 void LibInitL() 295 // Set Symbian OS parameters in pjlib. 296 // This must be done before pj_init() is called. 297 pj_status_t InitSymbSocket() 275 298 { 276 299 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;285 300 TInt err; 286 301 287 302 // Initialize RSocketServ 288 303 if ((err=aSocketServer.Connect(32)) != KErrNone) { 289 status = PJ_STATUS_FROM_OS(err); 290 goto on_return; 304 return PJ_STATUS_FROM_OS(err); 291 305 } 292 306 … … 294 308 if ((err=aConn.Open(aSocketServer)) != KErrNone) { 295 309 aSocketServer.Close(); 296 status = PJ_STATUS_FROM_OS(err); 297 goto on_return; 310 return PJ_STATUS_FROM_OS(err); 298 311 } 299 312 if ((err=aConn.Start()) != KErrNone) { 300 313 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 308 318 pj_bzero(&sym_params, sizeof(sym_params)); 309 319 sym_params.rsocketserv = &aSocketServer; 310 320 sym_params.rconnection = &aConn; 311 321 pj_symbianos_set_params(&sym_params); 312 322 323 return PJ_SUCCESS; 324 } 325 326 327 void DestroySymbSocket() 328 { 329 aConn.Close(); 330 aSocketServer.Close(); 331 } 332 333 334 void PjsuaInitL() 335 { 336 pjsua_app_cfg_t app_cfg; 337 pj_status_t status; 338 339 PjsuaDestroyL(); 340 313 341 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; 319 347 320 348 appui->PutMsg("Initializing.."); 321 status = app_init(&app_cfg);349 status = pjsua_app_init(&app_cfg); 322 350 if (status != PJ_SUCCESS) 323 351 goto on_return; 324 352 325 353 appui->PutMsg("Starting.."); 326 status = app_run(PJ_FALSE);354 status = pjsua_app_run(PJ_FALSE); 327 355 if (status != PJ_SUCCESS) 328 356 goto on_return; … … 333 361 } 334 362 335 void LibDestroyL()363 void PjsuaDestroyL() 336 364 { 337 365 if (app_ioqueue) { … … 339 367 app_ioqueue = NULL; 340 368 } 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.