diff --git a/linphone/console/commands.c b/linphone/console/commands.c index 43f929ec7..57af71117 100644 --- a/linphone/console/commands.c +++ b/linphone/console/commands.c @@ -1208,13 +1208,14 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){ linphone_proxy_config_enable_register(cfg,TRUE); if (elem) linphone_proxy_config_done(cfg); else linphone_core_add_proxy_config(lc,cfg); + linphone_core_set_default_proxy(lc,cfg); return 1; } static int lpc_cmd_unregister(LinphoneCore *lc, char *args){ LinphoneProxyConfig *cfg=NULL; linphone_core_get_default_proxy(lc,&cfg); - if (cfg) { + if (cfg && linphone_proxy_config_is_registered(cfg)) { linphone_proxy_config_edit(cfg); linphone_proxy_config_enable_register(cfg,FALSE); linphone_proxy_config_done(cfg); @@ -1242,35 +1243,36 @@ static int lpc_cmd_status(LinphoneCore *lc, char *args){ if (strstr(args,"register")){ if (cfg){ if (linphone_proxy_config_is_registered(cfg)){ - linphonec_out("identity=%s duration=%s", + linphonec_out("identity=%s duration=%i\n", linphone_proxy_config_get_identity(cfg), linphone_proxy_config_get_expires(cfg)); }else if (linphone_proxy_config_register_enabled(cfg)){ - linphonec_out("registered=-1"); - }else linphonec_out("registered=0"); - }else linphonec_out("registered=0"); + linphonec_out("registered=-1\n"); + }else linphonec_out("registered=0\n"); + }else linphonec_out("registered=0\n"); }else if (strstr(args,"autoanswer")){ if (cfg && linphone_proxy_config_is_registered(cfg)) - linphonec_out("autoanswer=%i",linphonec_get_autoanswer()); - else linphonec_out("unregistered"); + linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer()); + else linphonec_out("unregistered\n"); }else if (strstr(args,"hook")){ gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL); if (!cfg || !linphone_proxy_config_is_registered(cfg)){ - linphonec_out("unregistered"); + linphonec_out("unregistered\n"); + return 1; } switch(call_state){ case GSTATE_CALL_OUT_INVITE: - linphonec_out("hook=dialing"); + linphonec_out("hook=dialing\n"); break; case GSTATE_CALL_IDLE: - linphonec_out("hook=offhook"); + linphonec_out("hook=offhook\n"); break; case GSTATE_CALL_OUT_CONNECTED: - linphonec_out("hook=%s duration=%i", linphonec_get_callee(), + linphonec_out("hook=%s duration=%i\n", linphonec_get_callee(), linphone_core_get_current_call_duration(lc)); break; case GSTATE_CALL_IN_CONNECTED: - linphonec_out("hook=answered duration=%i" , + linphonec_out("hook=answered duration=%i\n" , linphone_core_get_current_call_duration(lc)); default: break; diff --git a/linphone/console/shell.c b/linphone/console/shell.c index 382b11745..1543c8a86 100644 --- a/linphone/console/shell.c +++ b/linphone/console/shell.c @@ -75,11 +75,16 @@ static int send_command(const char *command, const char * port, char *reply, int static void print_usage(void){ fprintf(stderr,"Usage:\nlinphonecsh [arguments]\n" "where action is one of\n" - "\tinit : spawn a linphonec daemon (first step to make other actions)\n" - "\t\tfollowed by the arguments sent to linphonec\n" - "\tgeneric : sends a generic command to the running linphonec daemon\n" - "\t\tfollowed by the generic command surrounded by quotes, for example \"call sip:joe@example.net\"\n" - "\tregister : register with specified proxy\n"); + "\tinit\t\t: spawn a linphonec daemon (first step to make other actions)\n" + "\t\t\tfollowed by the arguments sent to linphonec\n" + "\tgeneric\t\t: sends a generic command to the running linphonec daemon\n" + "\t\t\tfollowed by the generic command surrounded by quotes,\n\t\t\t for example \"call sip:joe@example.net\"\n" + "\tregister\t: register; arguments are \n\t\t\t--host \n\t\t\t--username \n\t\t\t--password \n" + "\tunregister\t: unregister\n" + "\tdial\t\t: dial \n" + "\tstatus\t\t: can be 'status register', 'status autoanswer' or 'status hook'\n" + "\texit\t\t: make the linphonec daemon to exit.\n" + ); exit(-1); } @@ -93,6 +98,8 @@ static void spawn_linphonec(int argc, char *argv[]){ args[j++]="linphonec"; args[j++]="--tcp"; args[j++]=DEFAULT_TCP_PORT; + args[j++]="-c"; + args[j++]="/dev/null"; for(i=0;irid); ms_return_if_fail(cfg!=NULL); cfg->auth_pending=FALSE; - cfg->registered=TRUE; gstate_new_state(lc, GSTATE_REG_OK, NULL); osip_message_get_expires(ev->request,0,&h); - if (h!=NULL && atoi(h->hvalue)!=0) + if (h!=NULL && atoi(h->hvalue)!=0){ + cfg->registered=TRUE; linphone_proxy_config_register_again_with_updated_contact(cfg,ev->request,ev->response); + }else cfg->registered=FALSE; } static bool_t comes_from_local_if(osip_message_t *msg){