]> sjero.net Git - linphone/blobdiff - console/commands.c
Aac-eld add missing header according to RFC3640 3.3.6
[linphone] / console / commands.c
index 84639ada82f874d3da82ea41a1d1dcefdeb86fb1..67b2446f45ae806fa1ae969c7a172062aa62c27e 100644 (file)
@@ -103,6 +103,8 @@ static int lpc_cmd_states(LinphoneCore *lc, char *args);
 static int lpc_cmd_identify(LinphoneCore *lc, char *args);
 static int lpc_cmd_ringback(LinphoneCore *lc, char *args);
 static int lpc_cmd_conference(LinphoneCore *lc, char *args);
+static int lpc_cmd_zrtp_verified(LinphoneCore *lc, char *args);
+static int lpc_cmd_zrtp_unverified(LinphoneCore *lc, char *args);
 
 /* Command handler helpers */
 static void linphonec_proxy_add(LinphoneCore *lc);
@@ -204,7 +206,7 @@ static LPC_COMMAND commands[] = {
        { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
                "'autoanswer'       \t: show current autoanswer mode\n"
                "'autoanswer enable'\t: enable autoanswer mode\n"
-               "'autoanswer disable'\t: disable autoanswer mode \n"},
+               "'autoanswer disable'\t: disable autoanswer mode��\n"},
        { "proxy", lpc_cmd_proxy, "Manage proxies",
                "'proxy list' : list all proxy setups.\n"
                "'proxy add' : add a new proxy setup.\n"
@@ -242,6 +244,8 @@ static LPC_COMMAND commands[] = {
                "'firewall none'   : use direct connection.\n"
                "'firewall nat'    : use nat address given with the 'nat' command.\n"
                "'firewall stun'   : use stun server given with the 'stun' command.\n"
+               "'firewall ice'    : use ice.\n"
+               "'firewall upnp'   : use uPnP IGD.\n"
        },
        { "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
        { "friend", lpc_cmd_friend, "Manage friends",
@@ -348,6 +352,12 @@ static LPC_COMMAND advanced_commands[] = {
        { "redirect", lpc_cmd_redirect, "Redirect an incoming call",
                "'redirect <redirect-uri>'\t: Redirect all pending incoming calls to the <redirect-uri>\n"
        },
+       { "zrtp-set-verified", lpc_cmd_zrtp_verified,"Set ZRTP SAS verified.",
+               "'Set ZRTP SAS verified'\n"
+       },
+       { "zrtp-set-unverified", lpc_cmd_zrtp_unverified,"Set ZRTP SAS not verified.",
+               "'Set ZRTP SAS not verified'\n"
+       },
        {       NULL,NULL,NULL,NULL}
 };
 
@@ -632,7 +642,7 @@ lpc_cmd_transfer(LinphoneCore *lc, char *args)
                char arg1[256]={0};
                char arg2[266]={0};
                long id2=0;
-               int n=sscanf(args,"%s %s %li",arg1,arg2,&id2);
+               int n=sscanf(args,"%255s %265s %li",arg1,arg2,&id2);
                if (n==1 || isalpha(*arg1)){
                        call=linphone_core_get_current_call(lc);
                        if (call==NULL && ms_list_size(linphone_core_get_calls(lc))==1){
@@ -842,6 +852,20 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
                {
                        linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall);
                }
+               else if (strcmp(args,"upnp")==0) 
+               {
+                       linphone_core_set_firewall_policy(lc,LinphonePolicyUseUpnp);
+               }
+               else if (strcmp(args,"ice")==0)
+               {
+                       setting = linphone_core_get_stun_server(lc);
+                       if ( ! setting )
+                       {
+                               linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
+                               return 1;
+                       }
+                       linphone_core_set_firewall_policy(lc,LinphonePolicyUseIce);
+               }
                else if (strcmp(args,"stun")==0)
                {
                        setting = linphone_core_get_stun_server(lc);
@@ -875,6 +899,12 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
                case LinphonePolicyUseNatAddress:
                        linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
                        break;
+               case LinphonePolicyUseIce:
+                       linphonec_out("Using ice with stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
+                       break;
+               case LinphonePolicyUseUpnp:
+                       linphonec_out("Using uPnP IGD protocol\n");
+                       break;
        }
        return 1;
 }
@@ -1890,7 +1920,7 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){
                return 1;
        }
        passwd[0]=proxy[0]=identity[0]='\0';
-       sscanf(args,"%s %s %s",identity,proxy,passwd);
+       sscanf(args,"%511s %511s %511s",identity,proxy,passwd);
        if (proxy[0]=='\0' || identity[0]=='\0'){
                linphonec_out("Missing parameters, see help register\n");
                return 1;
@@ -1941,7 +1971,7 @@ static int lpc_cmd_duration(LinphoneCore *lc, char *args){
        for(;elem!=NULL;elem=elem->next){
                if (elem->next==NULL){
                        cl=(LinphoneCallLog*)elem->data;
-                       linphonec_out("%i seconds\n",cl->duration);
+                       linphonec_out("%i seconds\n",linphone_call_log_get_duration(cl));
                }
        }
        return 1;
@@ -2046,7 +2076,7 @@ static int lpc_cmd_param(LinphoneCore *lc, char *args)
        if (args == NULL) {
                return 0;
        }
-       switch (sscanf(args,"%s %s %s",section,param,value)) {
+       switch (sscanf(args,"%19s %19s %49s",section,param,value)) {
                // case 1 might show all current settings under a section
                case 2:
                        string = lp_config_get_string(linphone_core_get_config(lc), section, param, "(undef)");
@@ -2078,7 +2108,7 @@ static int lpc_cmd_speak(LinphoneCore *lc, char *args){
        
     if (!args) return 0;
        memset(voice,0,sizeof(voice));
-       sscanf(args,"%s63",voice);
+       sscanf(args,"%63s",voice);
        sentence=args+strlen(voice);
        wavfile=tempnam("/tmp/","linphonec-espeak-");
        snprintf(cl,sizeof(cl),"espeak -v %s -s 100 -w %s --stdin",voice,wavfile);
@@ -2329,7 +2359,7 @@ static int _lpc_cmd_video_window(LinphoneCore *lc, char *args, bool_t is_preview
        VideoParams *params=is_preview ? &lpc_preview_params : &lpc_video_params;
 
        if (!args) return 0;
-       err=sscanf(args,"%s %i %i",subcommand,&a,&b);
+       err=sscanf(args,"%63s %i %i",subcommand,&a,&b);
        if (err>=1){
                if (strcmp(subcommand,"pos")==0){
                        if (err<3) return 0;
@@ -2480,13 +2510,15 @@ static int lpc_cmd_camera(LinphoneCore *lc, char *args){
                const LinphoneCallParams *cp=linphone_call_get_current_params (call);
                if (args){
                        linphone_call_enable_camera(call,activated);
-                       if ((activated && !linphone_call_params_video_enabled (cp))){
-                               /*update the call to add the video stream*/
-                               LinphoneCallParams *ncp=linphone_call_params_copy(cp);
-                               linphone_call_params_enable_video(ncp,TRUE);
-                               linphone_core_update_call(lc,call,ncp);
-                               linphone_call_params_destroy (ncp);
-                               linphonec_out("Trying to bring up video stream...\n");
+                       if (linphone_call_get_state(call)==LinphoneCallStreamsRunning){
+                               if ((activated && !linphone_call_params_video_enabled (cp))){
+                                       /*update the call to add the video stream*/
+                                       LinphoneCallParams *ncp=linphone_call_params_copy(cp);
+                                       linphone_call_params_enable_video(ncp,TRUE);
+                                       linphone_core_update_call(lc,call,ncp);
+                                       linphone_call_params_destroy (ncp);
+                                       linphonec_out("Trying to bring up video stream...\n");
+                               }
                        }
                }
                if (linphone_call_camera_enabled (call))
@@ -2552,6 +2584,20 @@ static int lpc_cmd_ringback(LinphoneCore *lc, char *args){
        return 1;
 }
 
+static int zrtp_set_verified(LinphoneCore *lc, char *args, bool_t verified){
+       LinphoneCall *call=linphone_core_get_current_call(lc);
+       if (linphone_call_params_get_media_encryption(linphone_call_get_current_params(call))==LinphoneMediaEncryptionZRTP){
+               linphone_call_set_authentication_token_verified(call,verified);
+       }
+       return 1;
+}
+static int lpc_cmd_zrtp_verified(LinphoneCore *lc, char *args){
+       return zrtp_set_verified(lc,args,TRUE);
+}
+static int lpc_cmd_zrtp_unverified(LinphoneCore *lc, char *args){
+       return zrtp_set_verified(lc,args,FALSE);
+}
+
 /***************************************************************************
  *
  *  Command table management funx