Commit 93e9f46b authored by smorlat's avatar smorlat

bugfixing.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@251 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 9d28bf4c
......@@ -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;
......
......@@ -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 <action> [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 <host>\n\t\t\t--username <username>\n\t\t\t--password <password>\n"
"\tunregister\t: unregister\n"
"\tdial\t\t: dial <sip uri or number>\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;i<argc;++i){
args[j++]=argv[i];
}
......@@ -189,7 +196,7 @@ static int dial_execute(int argc, char *argv[]){
static int status_execute(int argc, char *argv[]){
char cmd[512];
if (argc==1){
snprintf(cmd,sizeof(cmd),"call %s",argv[0]);
snprintf(cmd,sizeof(cmd),"status %s",argv[0]);
return send_generic_command(cmd,TRUE);
}else{
print_usage();
......@@ -227,7 +234,9 @@ int main(int argc, char *argv[]){
send_generic_command("duration",TRUE);
}else if (strcmp(argv[argi],"status")==0){
return status_execute(argc-argi-1,&argv[argi+1]);
}
}else if (strcmp(argv[argi],"exit")==0){
return send_generic_command("quit",TRUE);
}else print_usage();
}
return 0;
}
......@@ -930,11 +930,12 @@ void linphone_registration_success(LinphoneCore *lc,eXosip_event_t *ev){
cfg=linphone_core_get_proxy_config_from_rid(lc,ev->rid);
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){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment