Ignore:
Timestamp:
Apr 5, 2013 3:02:19 AM (7 years ago)
Author:
riza
Message:

Re #1643: Code restructure+add callback to support symbian gui app

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/main.c

    r4440 r4461  
    2727 * These are defined in pjsua_app.c. 
    2828 */ 
    29 extern pj_bool_t app_restart; 
    30 pj_status_t app_init(int argc, char *argv[]); 
    31 pj_status_t app_main(void); 
    32 pj_status_t app_destroy(); 
    33 pj_status_t receive_end_sig; 
    34 pj_thread_t *sig_thread; 
    35  
    36 #if defined(PJ_WIN32) && PJ_WIN32!=0 
    37 #include <windows.h> 
    38  
    39 static pj_thread_desc handler_desc; 
    40  
    41 static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) 
    42 {    
    43     switch (fdwCtrlType)  
    44     {  
    45         // Handle the CTRL+C signal.  
    46   
    47         case CTRL_C_EVENT:  
    48         case CTRL_CLOSE_EVENT:  
    49         case CTRL_BREAK_EVENT:  
    50         case CTRL_LOGOFF_EVENT:  
    51         case CTRL_SHUTDOWN_EVENT:  
    52             pj_thread_register("ctrlhandler", handler_desc, &sig_thread); 
    53             PJ_LOG(3,(THIS_FILE, "Ctrl-C detected, quitting..")); 
    54             receive_end_sig = PJ_TRUE; 
    55             app_destroy();           
    56             ExitProcess(1); 
    57             PJ_UNREACHED(return TRUE;) 
    58   
    59         default:  
    60   
    61             return FALSE;  
    62     }  
    63 } 
    64  
    65 static void setup_signal_handler(void) 
    66 { 
    67     SetConsoleCtrlHandler(&CtrlHandler, TRUE); 
    68 } 
    69  
    70 static void setup_socket_signal() 
    71 { 
    72 } 
    73  
    74 #else 
    75 #include <signal.h> 
    76  
    77 static void setup_signal_handler(void) 
    78 { 
    79 } 
    80  
    81 static void setup_socket_signal() 
    82 { 
    83     signal(SIGPIPE, SIG_IGN); 
    84 } 
    85  
    86 #endif 
    87  
    88 static int main_func(int argc, char *argv[]) 
    89 { 
    90     receive_end_sig = PJ_FALSE; 
    91     setup_socket_signal(); 
    92  
    93     do { 
    94         app_restart = PJ_FALSE; 
    95  
    96         if (app_init(argc, argv) != PJ_SUCCESS) 
    97             return 1; 
    98  
    99         setup_signal_handler(); 
    100  
    101         app_main(); 
    102         if (!receive_end_sig) { 
    103             app_destroy(); 
    104  
    105             /* This is on purpose */ 
    106             app_destroy(); 
    107         } else { 
    108             pj_thread_join(sig_thread); 
    109         } 
    110     } while (app_restart); 
    111  
    112     return 0; 
    113 } 
     29int main_func(int argc, char *argv[]); 
    11430 
    11531int main(int argc, char *argv[]) 
Note: See TracChangeset for help on using the changeset viewer.