1 /****************************************************************************
3 * $Id: commands.c,v 1.39 2008/07/03 15:08:34 smorlat Exp $
5 * Copyright (C) 2006-2009 Sandro Santilli <strk@keybit.net>
6 * Copyright (C) 2004 Simon MORLAT <simon.morlat@linphone.org>
8 ****************************************************************************
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 ****************************************************************************/
35 #include <linphonecore.h>
36 #include "linphonec.h"
46 /***************************************************************************
48 * Forward declarations
50 ***************************************************************************/
52 extern char *lpc_strip_blanks(char *input);
54 /* Command handlers */
55 static int lpc_cmd_help(LinphoneCore *, char *);
56 static int lpc_cmd_proxy(LinphoneCore *, char *);
57 static int lpc_cmd_call(LinphoneCore *, char *);
58 static int lpc_cmd_calls(LinphoneCore *, char *);
59 static int lpc_cmd_chat(LinphoneCore *, char *);
60 static int lpc_cmd_answer(LinphoneCore *, char *);
61 static int lpc_cmd_autoanswer(LinphoneCore *, char *);
62 static int lpc_cmd_terminate(LinphoneCore *, char *);
63 static int lpc_cmd_redirect(LinphoneCore *, char *);
64 static int lpc_cmd_call_logs(LinphoneCore *, char *);
65 static int lpc_cmd_ipv6(LinphoneCore *, char *);
66 static int lpc_cmd_transfer(LinphoneCore *, char *);
67 static int lpc_cmd_quit(LinphoneCore *, char *);
68 static int lpc_cmd_nat(LinphoneCore *, char *);
69 static int lpc_cmd_stun(LinphoneCore *, char *);
70 static int lpc_cmd_firewall(LinphoneCore *, char *);
71 static int lpc_cmd_friend(LinphoneCore *, char*);
72 static int lpc_cmd_soundcard(LinphoneCore *, char *);
73 static int lpc_cmd_webcam(LinphoneCore *, char *);
74 static int lpc_cmd_staticpic(LinphoneCore *, char *);
75 static int lpc_cmd_play(LinphoneCore *, char *);
76 static int lpc_cmd_record(LinphoneCore *, char *);
77 static int lpc_cmd_register(LinphoneCore *, char *);
78 static int lpc_cmd_unregister(LinphoneCore *, char *);
79 static int lpc_cmd_duration(LinphoneCore *lc, char *args);
80 static int lpc_cmd_status(LinphoneCore *lc, char *args);
81 static int lpc_cmd_ports(LinphoneCore *lc, char *args);
82 static int lpc_cmd_param(LinphoneCore *lc, char *args);
83 static int lpc_cmd_speak(LinphoneCore *lc, char *args);
84 static int lpc_cmd_acodec(LinphoneCore *lc, char *args);
85 static int lpc_cmd_vcodec(LinphoneCore *lc, char *args);
86 static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args);
87 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args);
88 static int lpc_cmd_echolimiter(LinphoneCore *lc, char *args);
89 static int lpc_cmd_pause(LinphoneCore *lc, char *args);
90 static int lpc_cmd_resume(LinphoneCore *lc, char *args);
91 static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args);
92 static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args);
93 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args);
95 static int lpc_cmd_camera(LinphoneCore *lc, char *args);
96 static int lpc_cmd_video_window(LinphoneCore *lc, char *args);
97 static int lpc_cmd_preview_window(LinphoneCore *lc, char *args);
98 static int lpc_cmd_snapshot(LinphoneCore *lc, char *args);
99 static int lpc_cmd_vfureq(LinphoneCore *lc, char *arg);
101 static int lpc_cmd_states(LinphoneCore *lc, char *args);
102 static int lpc_cmd_identify(LinphoneCore *lc, char *args);
103 static int lpc_cmd_ringback(LinphoneCore *lc, char *args);
105 /* Command handler helpers */
106 static void linphonec_proxy_add(LinphoneCore *lc);
107 static void linphonec_proxy_display(LinphoneProxyConfig *lc);
108 static void linphonec_proxy_list(LinphoneCore *lc);
109 static void linphonec_proxy_remove(LinphoneCore *lc, int index);
110 static int linphonec_proxy_use(LinphoneCore *lc, int index);
111 static void linphonec_proxy_show(LinphoneCore *lc,int index);
112 static void linphonec_friend_display(LinphoneFriend *fr);
113 static int linphonec_friend_list(LinphoneCore *lc, char *arg);
114 static void linphonec_display_command_help(LPC_COMMAND *cmd);
115 static int linphonec_friend_call(LinphoneCore *lc, unsigned int num);
117 static int linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr);
119 static int linphonec_friend_delete(LinphoneCore *lc, int num);
120 static int linphonec_friend_delete(LinphoneCore *lc, int num);
121 static void linphonec_codec_list(int type, LinphoneCore *lc);
122 static void linphonec_codec_enable(int type, LinphoneCore *lc, int index);
123 static void linphonec_codec_disable(int type, LinphoneCore *lc, int index);
127 /* Command table management */
128 static LPC_COMMAND *lpc_find_command(const char *name);
130 void linphonec_out(const char *fmt,...);
132 VideoParams lpc_video_params={-1,-1,-1,-1,0,TRUE};
133 VideoParams lpc_preview_params={-1,-1,-1,-1,0,TRUE};
135 /***************************************************************************
139 ***************************************************************************/
144 static LPC_COMMAND commands[] = {
145 { "help", lpc_cmd_help, "Print commands help.",
146 "'help <command>'\t: displays specific help for command.\n"
147 "'help advanced'\t: shows advanced commands.\n"
149 { "call", lpc_cmd_call, "Call a SIP uri or number",
151 "'call <sip-url or number> [options]' \t: initiate a call to the specified destination.\n"
153 "--audio-only : initiate the call without video.\n"
154 "--early-media : sends audio and video stream immediately when remote proposes early media.\n"
156 "'call <sip-url or number>' \t: initiate a call to the specified destination.\n"
159 { "calls", lpc_cmd_calls, "Show all the current calls with their id and status.",
162 { "chat", lpc_cmd_chat, "Chat with a SIP uri",
163 "'chat <sip-url> \"message\"' "
164 ": send a chat message \"message\" to the specified destination."
166 { "terminate", lpc_cmd_terminate, "Terminate a call",
167 "'terminate' : Terminate the current call\n"
168 "'terminate <call id>' : Terminate the call with supplied id\n"
169 "'terminate <all>' : Terminate all the current calls\n"
171 { "answer", lpc_cmd_answer, "Answer a call",
172 "'answer' : Answer the current incoming call\n"
173 "'answer <call id>' : Answer the call with given id\n"
175 { "pause", lpc_cmd_pause, "pause a call",
176 "'pause' : pause the current call\n"},
177 { "resume", lpc_cmd_resume, "resume a call",
178 "'resume' : resume the unique call\n"
179 "'resume <call id>' : hold off the call with given id\n"},
180 { "transfer", lpc_cmd_transfer,
181 "Transfer a call to a specified destination.",
182 "'transfer <sip-uri>' : transfers the current active call to the destination sip-uri\n"
183 "'transfer <call id> <sip-uri>': transfers the call with 'id' to the destination sip-uri\n"
184 "'transfer <call id1> --to-call <call id2>': transfers the call with 'id1' to the destination of call 'id2' (attended transfer)\n"
186 { "mute", lpc_cmd_mute_mic,
187 "Mute microphone and suspend voice transmission."},
189 { "camera", lpc_cmd_camera, "Send camera output for current call.",
190 "'camera on'\t: allow sending of local camera video to remote end.\n"
191 "'camera off'\t: disable sending of local camera's video to remote end.\n"},
193 { "unmute", lpc_cmd_unmute_mic,
194 "Unmute microphone and resume voice transmission."},
195 { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL },
197 { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
198 "'autoanswer' \t: show current autoanswer mode\n"
199 "'autoanswer enable'\t: enable autoanswer mode\n"
200 "'autoanswer disable'\t: disable autoanswer modeĀ \n"},
201 { "proxy", lpc_cmd_proxy, "Manage proxies",
202 "'proxy list' : list all proxy setups.\n"
203 "'proxy add' : add a new proxy setup.\n"
204 "'proxy remove <index>' : remove proxy setup with number index.\n"
205 "'proxy use <index>' : use proxy with number index as default proxy.\n"
206 "'proxy unuse' : don't use a default proxy.\n"
207 "'proxy show <index>' : show configuration and status of the proxy numbered by index.\n"
208 "'proxy show default' : show configuration and status of the default proxy.\n"
210 { "soundcard", lpc_cmd_soundcard, "Manage soundcards",
211 "'soundcard list' : list all sound devices.\n"
212 "'soundcard show' : show current sound devices configuration.\n"
213 "'soundcard use <index>' : select a sound device.\n"
214 "'soundcard use files' : use .wav files instead of soundcard\n"
216 { "webcam", lpc_cmd_webcam, "Manage webcams",
217 "'webcam list' : list all known devices.\n"
218 "'webcam use <index>' : select a video device.\n"
220 { "ipv6", lpc_cmd_ipv6, "Use IPV6",
221 "'ipv6 status' : show ipv6 usage status.\n"
222 "'ipv6 enable' : enable the use of the ipv6 network.\n"
223 "'ipv6 disable' : do not use ipv6 network."
225 { "nat", lpc_cmd_nat, "Set nat address",
226 "'nat' : show nat settings.\n"
227 "'nat <addr>' : set nat address.\n"
229 { "stun", lpc_cmd_stun, "Set stun server address",
230 "'stun' : show stun settings.\n"
231 "'stun <addr>' : set stun server address.\n"
233 { "firewall", lpc_cmd_firewall, "Set firewall policy",
234 "'firewall' : show current firewall policy.\n"
235 "'firewall none' : use direct connection.\n"
236 "'firewall nat' : use nat address given with the 'nat' command.\n"
237 "'firewall stun' : use stun server given with the 'stun' command.\n"
239 { "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
240 { "friend", lpc_cmd_friend, "Manage friends",
241 "'friend list [<pattern>]' : list friends.\n"
242 "'friend call <index>' : call a friend.\n"
243 "'friend add <name> <addr>' : add friend, <name> must be quoted to include\n"
244 " spaces, <addr> has \"sip:\" added if it isn't\n"
245 " there. Don't use '<' '>' around <addr>.\n"
246 "'friend delete <index>' : remove friend, 'all' removes all\n"
248 { "play", lpc_cmd_play, "play a wav file",
249 "This command has two roles:\n"
250 "Plays a file instead of capturing from soundcard - only available in file mode (see 'help soundcard')\n"
251 "Specifies a wav file to be played to play music to far end when putting it on hold (pause)\n"
252 "'play <wav file>' : play a wav file."
254 { "record", lpc_cmd_record, "record to a wav file",
255 "This feature is available only in file mode (see 'help soundcard')\n"
256 "'record <wav file>' : record into wav file."
258 { "quit", lpc_cmd_quit, "Exit linphonec", NULL },
259 { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
263 static LPC_COMMAND advanced_commands[] = {
264 { "codec", lpc_cmd_acodec, "Audio codec configuration",
265 "'codec list' : list audio codecs\n"
266 "'codec enable <index>' : enable available audio codec\n"
267 "'codec disable <index>' : disable audio codec" },
268 { "vcodec", lpc_cmd_vcodec, "Video codec configuration",
269 "'vcodec list' : list video codecs\n"
270 "'vcodec enable <index>' : enable available video codec\n"
271 "'vcodec disable <index>' : disable video codec" },
272 { "ec", lpc_cmd_echocancellation, "Echo cancellation",
273 "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
274 "'ec off' : turn echo cancellation (EC) off\n"
275 "'ec show' : show EC status" },
276 { "el", lpc_cmd_echolimiter, "Echo limiter",
277 "'el on turns on echo limiter (automatic half duplex, for cases where echo canceller cannot work)\n"
278 "'el off' : turn echo limiter off\n"
279 "'el show' : show echo limiter status" },
280 { "nortp-on-audio-mute", lpc_cmd_rtp_no_xmit_on_audio_mute,
281 "Set the rtp_no_xmit_on_audio_mute configuration parameter",
282 " If set to 1 then rtp transmission will be muted when\n"
283 " audio is muted , otherwise rtp is always sent."},
285 { "vwindow", lpc_cmd_video_window, "Control video display window",
286 "'vwindow show': shows video window\n"
287 "'vwindow hide': hides video window\n"
288 "'vwindow pos <x> <y>': Moves video window to x,y pixel coordinates\n"
289 "'vwindow size <width> <height>': Resizes video window\n"
290 "'vwindow id <window id>': embeds video display into supplied window id."
292 { "pwindow", lpc_cmd_preview_window, "Control local camera video display (preview window)",
293 "'pwindow show': shows the local camera video display\n"
294 "'pwindow hide': hides the local camera video display\n"
295 "'pwindow pos <x> <y>': Moves preview window to x,y pixel coordinates\n"
296 "'pwindow size <width> <height>': Resizes preview window\n"
297 "'pwindow id <window id>': embeds preview display into supplied window id.\n"
298 "'pwindow integrated': integrate preview display within the video window of current call.\n"
299 "'pwindow standalone': use standalone window for preview display."
301 { "snapshot", lpc_cmd_snapshot, "Take a snapshot of currently received video stream",
302 "'snapshot <file path>': take a snapshot and records it in jpeg format into the supplied path\n"
304 { "vfureq", lpc_cmd_vfureq, "Request the other side to send VFU for the current call"},
306 { "states", lpc_cmd_states, "Show internal states of liblinphone, registrations and calls, according to linphonecore.h definitions",
307 "'states global': shows global state of liblinphone \n"
308 "'states calls': shows state of calls\n"
309 "'states proxies': shows state of proxy configurations"
311 { "register", lpc_cmd_register, "Register in one line to a proxy" , "register <sip identity> <sip proxy> <password>"},
312 { "unregister", lpc_cmd_unregister, "Unregister from default proxy", NULL },
313 { "status", lpc_cmd_status, "Print various status information",
314 "'status register' \t: print status concerning registration\n"
315 "'status autoanswer'\t: tell whether autoanswer mode is enabled\n"
316 "'status hook' \t: print hook status\n" },
317 { "ports", lpc_cmd_ports, "Network ports configuration",
318 "'ports' \t: prints current used ports.\n"
319 "'ports sip <port number>'\t: Sets the sip port.\n" },
320 { "param", lpc_cmd_param, "parameter set or read as normally given in .linphonerc",
321 "'param <section> <parameter> [<value>]' \t: reads [sets] given parameter.\n"
322 "NOTES: - changes may become effective after (re)establishing a sip connection.\n"
323 " - upon exit, .linphonerc will reflect the updated state.\n" },
324 { "speak", lpc_cmd_speak, "Speak a sentence using espeak TTS engine",
325 "This feature is available only in file mode. (see 'help soundcard')\n"
326 "'speak <voice name> <sentence>' : speak a text using the specified espeak voice.\n"
327 "Example for english voice: 'speak default Hello my friend !'"
329 { "staticpic", lpc_cmd_staticpic, "Manage static pictures when nowebcam",
330 "'staticpic set' : Set path to picture that should be used.\n"
331 "'staticpic fps' : Get/set frames per seconds for picture emission.\n"
333 { "identify", lpc_cmd_identify, "Returns the user-agent string of far end",
334 "'identify' \t: returns remote user-agent string for current call.\n"
335 "'identify <id>' \t: returns remote user-agent string for call with supplied id.\n"
337 { "ringback", lpc_cmd_ringback, "Specifies a ringback tone to be played to remote end during incoming calls",
338 "'ringback <path of mono .wav file>'\t: Specifies a ringback tone to be played to remote end during incoming calls\n"
339 "'ringback disable'\t: Disable playing of ringback tone to callers\n"
341 { "redirect", lpc_cmd_redirect, "Redirect an incoming call",
342 "'redirect <redirect-uri>'\t: Redirect all pending incoming calls to the <redirect-uri>\n"
344 { NULL,NULL,NULL,NULL}
349 /***************************************************************************
353 ***************************************************************************/
356 * Main command dispatcher.
357 * WARNING: modifies second argument!
359 * Always return 1 currently.
362 linphonec_parse_command_line(LinphoneCore *lc, char *cl)
368 /* Isolate first word and args */
369 while(*ptr && !isspace(*ptr)) ++ptr;
373 /* set args to first nonblank */
375 while(*args && isspace(*args)) ++args;
379 if ( isdigit(*cl) || *cl == '#' || *cl == '*' )
381 while ( isdigit(*cl) || *cl == '#' || *cl == '*' )
383 linphone_core_send_dtmf(lc, *cl);
384 linphone_core_play_dtmf (lc,*cl,100);
385 ms_sleep(1); // be nice
389 // discard spurious trailing chars
393 /* Handle other kind of commands */
394 cmd=lpc_find_command(cl);
397 linphonec_out("'%s': Cannot understand this.\n", cl);
401 if ( ! cmd->func(lc, args) )
403 linphonec_out("Syntax error.\n");
404 linphonec_display_command_help(cmd);
411 * Generator function for command completion.
412 * STATE let us know whether to start from scratch;
413 * without any state (STATE==0), then we start at the
417 linphonec_command_generator(const char *text, int state)
419 static int index, len, adv;
429 * Return the next name which partially matches
430 * from the commands list
433 while ((name=commands[index].name))
435 ++index; /* so next call get next command */
437 if (strncmp(name, text, len) == 0)
439 return ortp_strdup(name);
446 while ((name=advanced_commands[index].name))
448 ++index; /* so next call get next command */
450 if (strncmp(name, text, len) == 0)
452 return ortp_strdup(name);
460 /***************************************************************************
464 ***************************************************************************/
467 lpc_cmd_help(LinphoneCore *lc, char *arg)
474 linphonec_out("Commands are:\n");
475 linphonec_out("---------------------------\n");
477 while (commands[i].help)
479 linphonec_out("%10.10s\t%s\n", commands[i].name,
484 linphonec_out("---------------------------\n");
485 linphonec_out("Type 'help <command>' for more details or\n");
486 linphonec_out(" 'help advanced' to list additional commands.\n");
491 if (strcmp(arg,"advanced")==0){
492 linphonec_out("Advanced commands are:\n");
493 linphonec_out("---------------------------\n");
495 while (advanced_commands[i].help)
497 linphonec_out("%10.10s\t%s\n", advanced_commands[i].name,
498 advanced_commands[i].help);
502 linphonec_out("---------------------------\n");
503 linphonec_out("Type 'help <command>' for more details.\n");
508 cmd=lpc_find_command(arg);
511 linphonec_out("No such command.\n");
515 linphonec_display_command_help(cmd);
520 static char callee_name[256]={0};
521 static char caller_name[256]={0};
523 static const char *get_call_status(LinphoneCall *call){
524 switch(linphone_call_get_state(call)){
525 case LinphoneCallPaused:
526 if (linphone_call_get_refer_to (call)!=NULL){
527 return "Paused (transfered)";
532 case LinphoneCallPausedByRemote:
533 return "Paused by remote";
535 case LinphoneCallIncomingReceived:
538 case LinphoneCallOutgoingInit:
539 case LinphoneCallOutgoingProgress:
540 return "Dialing out";
542 case LinphoneCallOutgoingEarlyMedia:
543 case LinphoneCallOutgoingRinging:
544 return "Remote ringing";
547 if (linphone_call_has_transfer_pending(call)){
548 return "Running (transfer pending)";
556 lpc_cmd_call(LinphoneCore *lc, char *args)
558 if ( ! args || ! *args )
564 LinphoneCallParams *cp=linphone_core_create_default_call_parameters (lc);
566 if ( linphone_core_in_call(lc) )
568 linphonec_out("Terminate or hold on the current call first.\n");
571 opt1=strstr(args,"--audio-only");
572 opt2=strstr(args,"--early-media");
575 linphone_call_params_enable_video (cp,FALSE);
579 linphone_call_params_enable_early_media_sending(cp,TRUE);
581 if ( NULL == (call=linphone_core_invite_with_params(lc, args,cp)) )
583 linphonec_out("Error from linphone_core_invite.\n");
587 snprintf(callee_name,sizeof(callee_name),"%s",args);
589 linphone_call_params_destroy(cp);
595 lpc_cmd_calls(LinphoneCore *lc, char *args){
596 const MSList *calls = linphone_core_get_calls(lc);
599 const MSList *p_calls = calls;
600 linphonec_out("ID\t\tDestination\t\t\t\tStatus\n---------------------------------------------------------------------\n");
601 while(p_calls != NULL)
603 LinphoneCall *call=(LinphoneCall*)p_calls->data;
604 char *tmp=linphone_call_get_remote_address_as_string(call);
605 linphonec_out("%li\t%s\t\t\t%s\r\n",
606 (long)linphone_call_get_user_pointer (call),
608 get_call_status(call));
609 p_calls = p_calls->next;
614 linphonec_out("No active call.\n");
621 lpc_cmd_chat(LinphoneCore *lc, char *args)
629 /* Isolate first and second arg */
630 while(*ptr && !isspace(*ptr)) ++ptr;
635 while(*arg2 && isspace(*arg2)) ++arg2;
639 /* missing one parameter */
642 LinphoneChatRoom *cr = linphone_core_create_chat_room(lc,arg1);
643 linphone_chat_room_send_message(cr,arg2);
644 linphone_chat_room_destroy(cr);
649 const char *linphonec_get_callee(){
653 const char *linphonec_get_caller(){
657 void linphonec_set_caller(const char *caller){
658 snprintf(caller_name,sizeof(caller_name)-1,"%s",caller);
662 lpc_cmd_transfer(LinphoneCore *lc, char *args)
667 const char *refer_to=NULL;
671 int n=sscanf(args,"%s %s %li",arg1,arg2,&id2);
672 if (n==1 || isalpha(*arg1)){
673 call=linphone_core_get_current_call(lc);
674 if (call==NULL && ms_list_size(linphone_core_get_calls(lc))==1){
675 call=(LinphoneCall*)linphone_core_get_calls(lc)->data;
679 linphonec_out("No active call, please specify a call id among the ones listed by 'calls' command.\n");
682 linphone_core_transfer_call(lc, call, refer_to);
685 refer_to=args+strlen(arg1)+1;
686 call=linphonec_get_call(id);
687 if (call==NULL) return 0;
688 linphone_core_transfer_call(lc, call, refer_to);
691 call=linphonec_get_call(id);
692 call2=linphonec_get_call(id2);
693 if (call==NULL || call2==NULL) return 0;
694 if (strcmp(arg2,"--to-call")!=0){
697 linphonec_out("Performing attended transfer of call %i to call %i",id,id2);
698 linphone_core_transfer_call_to_another (lc,call,call2);
701 linphonec_out("Transfer command requires at least one argument\n");
708 lpc_cmd_terminate(LinphoneCore *lc, char *args)
710 if (linphone_core_get_calls(lc)==NULL){
711 linphonec_out("No active calls\n");
716 if ( -1 == linphone_core_terminate_call(lc, NULL) ){
717 linphonec_out("Could not stop the active call.\n");
722 if(strcmp(args,"all")==0){
723 linphonec_out("We are going to stop all the calls.\n");
724 linphone_core_terminate_all_calls(lc);
727 /*the argument is a linphonec call id */
729 LinphoneCall *call=linphonec_get_call(id);
731 if (linphone_core_terminate_call(lc,call)==-1){
732 linphonec_out("Could not stop the call with id %li\n",id);
742 lpc_cmd_redirect(LinphoneCore *lc, char *args){
746 if ((elem=linphone_core_get_calls(lc))==NULL){
747 linphonec_out("No active calls.\n");
751 LinphoneCall *call=(LinphoneCall*)elem->data;
752 if (linphone_call_get_state(call)==LinphoneCallIncomingReceived){
753 linphone_core_redirect_call(lc,call,args);
755 /*as the redirection closes the call, we need to re-check the call list that is invalidated.*/
756 elem=linphone_core_get_calls(lc);
757 }else elem=elem->next;
760 linphonec_out("There is no pending incoming call to redirect.");
766 lpc_cmd_answer(LinphoneCore *lc, char *args){
769 int nb=ms_list_size(linphone_core_get_calls(lc));
771 //if just one call is present answer the only one in passing NULL to the linphone_core_accept_call ...
772 if ( -1 == linphone_core_accept_call(lc, NULL) )
774 linphonec_out("Fail to accept incoming call\n");
777 linphonec_out("There are no calls to answer.\n");
779 linphonec_out("Multiple calls in progress, please specify call id.\n");
785 if (sscanf(args,"%li",&id)==1){
786 LinphoneCall *call=linphonec_get_call (id);
787 if (linphone_core_accept_call (lc,call)==-1){
788 linphonec_out("Fail to accept call %i\n",id);
797 lpc_cmd_autoanswer(LinphoneCore *lc, char *args)
801 if ( linphonec_get_autoanswer() ) {
802 linphonec_out("Auto answer is enabled. Use 'autoanswer disable' to disable.\n");
804 linphonec_out("Auto answer is disabled. Use 'autoanswer enable' to enable.\n");
809 if (strstr(args,"enable")){
810 linphonec_set_autoanswer(TRUE);
811 linphonec_out("Auto answer enabled.\n");
812 }else if (strstr(args,"disable")){
813 linphonec_set_autoanswer(FALSE);
814 linphonec_out("Auto answer disabled.\n");
820 lpc_cmd_quit(LinphoneCore *lc, char *args)
822 linphonec_main_loop_exit();
827 lpc_cmd_nat(LinphoneCore *lc, char *args)
832 if ( args ) args=lpc_strip_blanks(args);
836 linphone_core_set_nat_address(lc, args);
837 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS); */
840 nat = linphone_core_get_nat_address(lc);
841 use = linphone_core_get_firewall_policy(lc)==LinphonePolicyUseNatAddress;
842 linphonec_out("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
848 lpc_cmd_stun(LinphoneCore *lc, char *args)
853 if ( args ) args=lpc_strip_blanks(args);
857 linphone_core_set_stun_server(lc, args);
858 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN); */
861 stun = linphone_core_get_stun_server(lc);
862 use = linphone_core_get_firewall_policy(lc)==LinphonePolicyUseStun;
863 linphonec_out("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
869 lpc_cmd_firewall(LinphoneCore *lc, char *args)
871 const char* setting=NULL;
873 if ( args ) args=lpc_strip_blanks(args);
877 if (strcmp(args,"none")==0)
879 linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall);
881 else if (strcmp(args,"stun")==0)
883 setting = linphone_core_get_stun_server(lc);
886 linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
889 linphone_core_set_firewall_policy(lc,LinphonePolicyUseStun);
891 else if (strcmp(args,"nat")==0)
893 setting = linphone_core_get_nat_address(lc);
896 linphonec_out("No nat address is defined, use 'nat <address>' first");
899 linphone_core_set_firewall_policy(lc,LinphonePolicyUseNatAddress);
903 switch(linphone_core_get_firewall_policy(lc))
905 case LinphonePolicyNoFirewall:
906 linphonec_out("No firewall\n");
908 case LinphonePolicyUseStun:
909 linphonec_out("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
911 case LinphonePolicyUseNatAddress:
912 linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
919 /* Helper function for processing freind names */
921 lpc_friend_name(char **args, char **name)
923 /* Use space as a terminator unless quoted */
924 if (('"' == **args) || ('\'' == **args)){
929 while ((delim != *end) && ('\0' != *end)) end++;
931 fprintf(stderr, "Mismatched quotes\n");
938 *name = strsep(args, " ");
940 if (NULL == *args) { /* Means there was no separator */
941 fprintf(stderr, "Either name or address is missing\n");
944 if (NULL == *name) return 0;
951 lpc_cmd_friend(LinphoneCore *lc, char *args)
955 if ( args ) args=lpc_strip_blanks(args);
957 if ( ! args || ! *args ) return 0;
959 if ( !strncmp(args, "list", 4) )
961 return linphonec_friend_list(lc, args+4);
964 else if ( !strncmp(args, "call", 4) )
967 if ( ! *args ) return 0;
968 friend_num = strtol(args, NULL, 10);
970 if ( errno == ERANGE ) {
971 linphonec_out("Invalid friend number\n");
974 #endif /*_WIN32_WCE*/
975 linphonec_friend_call(lc, friend_num);
978 else if ( !strncmp(args, "delete", 6) )
981 if ( ! *args ) return 0;
982 while (*args == ' ') args++;
983 if ( ! *args ) return 0;
984 if (!strncmp(args, "all", 3))
990 friend_num = strtol(args, NULL, 10);
992 if ( errno == ERANGE ) {
993 linphonec_out("Invalid friend number\n");
996 #endif /*_WIN32_WCE*/
998 linphonec_friend_delete(lc, friend_num);
1001 else if ( !strncmp(args, "add", 3) )
1006 char *addr_p = addr;
1010 if ( ! *args ) return 0;
1011 while (*args == ' ') args++;
1012 if ( ! *args ) return 0;
1014 if (!lpc_friend_name(&args, &name)) return 0;
1016 while (*args == ' ') args++;
1017 if ( ! *args ) return 0;
1018 if (isdigit(*args)) {
1019 strcpy (addr, "sip:");
1020 addr_p = addr + strlen("sip:");
1022 addr_orig = strsep(&args, " ");
1023 if (1 >= strlen(addr_orig)) {
1024 fprintf(stderr, "A single-digit address is not valid\n");
1027 strcpy(addr_p, addr_orig);
1028 linphonec_friend_add(lc, name, addr);
1030 LinphoneFriend *new_friend;
1031 new_friend = linphone_friend_new_with_addr(args);
1032 linphone_core_add_friend(lc, new_friend);
1039 static int lpc_cmd_play(LinphoneCore *lc, char *args){
1040 if ( args ) args=lpc_strip_blanks(args);
1041 if ( ! args || ! *args ) return 0;
1042 linphone_core_set_play_file(lc,args);
1046 static int lpc_cmd_record(LinphoneCore *lc, char *args){
1047 if ( args ) args=lpc_strip_blanks(args);
1048 if ( ! args || ! *args ) return 0;
1049 linphone_core_set_record_file(lc,args);
1057 lpc_cmd_proxy(LinphoneCore *lc, char *args)
1064 if ( ! arg1 ) return 0;
1066 /* Isolate first and second arg */
1067 while(*ptr && !isspace(*ptr)) ++ptr;
1072 while(*arg2 && isspace(*arg2)) ++arg2;
1075 if (strcmp(arg1,"add")==0)
1077 #ifdef HAVE_READLINE
1078 rl_inhibit_completion=1;
1080 linphonec_proxy_add(lc);
1081 #ifdef HAVE_READLINE
1082 rl_inhibit_completion=0;
1085 else if (strcmp(arg1,"list")==0)
1087 linphonec_proxy_list(lc);
1089 else if (strcmp(arg1,"remove")==0)
1091 linphonec_proxy_remove(lc,atoi(arg2));
1093 else if (strcmp(arg1,"use")==0)
1095 if ( arg2 && *arg2 )
1097 proxynum=atoi(arg2);
1098 if ( linphonec_proxy_use(lc, proxynum) )
1099 linphonec_out("Default proxy set to %d.\n", proxynum);
1103 proxynum=linphone_core_get_default_proxy(lc, NULL);
1104 if ( proxynum == -1 ) linphonec_out("No default proxy.\n");
1105 else linphonec_out("Current default proxy is %d.\n", proxynum);
1107 }else if (strcmp(arg1, "unuse")==0){
1108 linphone_core_set_default_proxy(lc, NULL);
1109 linphonec_out("Use no proxy.\n");
1112 else if (strcmp(arg1, "show")==0)
1116 if (strstr(arg2,"default"))
1118 proxynum=linphone_core_get_default_proxy(lc, NULL);
1119 if ( proxynum < 0 ) {
1120 linphonec_out("No default proxy defined\n");
1123 linphonec_proxy_show(lc,proxynum);
1127 linphonec_proxy_show(lc, atoi(arg2));
1130 else return 0; /* syntax error */
1135 return 0; /* syntax error */
1142 lpc_cmd_call_logs(LinphoneCore *lc, char *args)
1144 const MSList *elem=linphone_core_get_call_logs(lc);
1145 for (;elem!=NULL;elem=ms_list_next(elem))
1147 LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
1148 char *str=linphone_call_log_to_str(cl);
1149 linphonec_out("%s\n",str);
1156 lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
1160 return 0; /* syntax error */
1163 if (strcmp(arg1,"status")==0)
1165 linphonec_out("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
1167 else if (strcmp(arg1,"enable")==0)
1169 linphone_core_enable_ipv6(lc,TRUE);
1170 linphonec_out("ipv6 use enabled.\n");
1172 else if (strcmp(arg1,"disable")==0)
1174 linphone_core_enable_ipv6(lc,FALSE);
1175 linphonec_out("ipv6 use disabled.\n");
1179 return 0; /* syntax error */
1184 static int devname_to_index(LinphoneCore *lc, const char *devname){
1187 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
1188 if (strcmp(devname,*p)==0) return i;
1193 static const char *index_to_devname(LinphoneCore *lc, int index){
1196 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
1197 if (i==index) return *p;
1202 static int lpc_cmd_soundcard(LinphoneCore *lc, char *args)
1210 if (!args) return 0; /* syntax error */
1212 /* Isolate first and second arg */
1213 while(*ptr && !isspace(*ptr)) ++ptr;
1218 while(*arg2 && isspace(*arg2)) ++arg2;
1221 if (strcmp(arg1, "list")==0)
1223 dev=linphone_core_get_sound_devices(lc);
1224 for(i=0; dev[i]!=NULL; ++i){
1225 linphonec_out("%i: %s\n",i,dev[i]);
1230 if (strcmp(arg1, "show")==0)
1232 linphonec_out("Ringer device: %s\n",
1233 linphone_core_get_ringer_device(lc));
1234 linphonec_out("Playback device: %s\n",
1235 linphone_core_get_playback_device(lc));
1236 linphonec_out("Capture device: %s\n",
1237 linphone_core_get_capture_device(lc));
1241 if (strcmp(arg1, "use")==0 && arg2)
1243 if (strcmp(arg2, "files")==0)
1245 linphonec_out("Using wav files instead of soundcard.\n");
1246 linphone_core_use_files(lc,TRUE);
1250 dev=linphone_core_get_sound_devices(lc);
1251 index=atoi(arg2); /* FIXME: handle not-a-number */
1252 for(i=0;dev[i]!=NULL;i++)
1254 if (i!=index) continue;
1256 linphone_core_set_ringer_device(lc,dev[i]);
1257 linphone_core_set_playback_device(lc,dev[i]);
1258 linphone_core_set_capture_device(lc,dev[i]);
1259 linphonec_out("Using sound device %s\n",dev[i]);
1262 linphonec_out("No such sound device\n");
1265 if (strcmp(arg1, "capture")==0)
1267 const char *devname=linphone_core_get_capture_device(lc);
1269 linphonec_out("Using capture device #%i (%s)\n",
1270 devname_to_index(lc,devname),devname);
1272 index=atoi(arg2); /* FIXME: handle not-a-number */
1273 devname=index_to_devname(lc,index);
1275 linphone_core_set_capture_device(lc,devname);
1276 linphonec_out("Using capture sound device %s\n",devname);
1279 linphonec_out("No such sound device\n");
1283 if (strcmp(arg1, "playback")==0)
1285 const char *devname=linphone_core_get_playback_device(lc);
1287 linphonec_out("Using playback device #%i (%s)\n",
1288 devname_to_index(lc,devname),devname);
1290 index=atoi(arg2); /* FIXME: handle not-a-number */
1291 devname=index_to_devname(lc,index);
1293 linphone_core_set_playback_device(lc,devname);
1294 linphonec_out("Using playback sound device %s\n",devname);
1297 linphonec_out("No such sound device\n");
1301 if (strcmp(arg1, "ring")==0)
1303 const char *devname=linphone_core_get_ringer_device(lc);
1305 linphonec_out("Using ring device #%i (%s)\n",
1306 devname_to_index(lc,devname),devname);
1308 index=atoi(arg2); /* FIXME: handle not-a-number */
1309 devname=index_to_devname(lc,index);
1311 linphone_core_set_ringer_device(lc,devname);
1312 linphonec_out("Using ring sound device %s\n",devname);
1315 linphonec_out("No such sound device\n");
1319 return 0; /* syntax error */
1322 static int lpc_cmd_webcam(LinphoneCore *lc, char *args)
1330 if (!args) return 0; /* syntax error */
1332 /* Isolate first and second arg */
1333 while(*ptr && !isspace(*ptr)) ++ptr;
1338 while(*arg2 && isspace(*arg2)) ++arg2;
1341 if (strcmp(arg1, "list")==0)
1343 dev=linphone_core_get_video_devices(lc);
1344 for(i=0; dev[i]!=NULL; ++i){
1345 linphonec_out("%i: %s\n",i,dev[i]);
1350 if (strcmp(arg1, "use")==0 && arg2)
1352 dev=linphone_core_get_video_devices(lc);
1353 index=atoi(arg2); /* FIXME: handle not-a-number */
1354 for(i=0;dev[i]!=NULL;i++)
1356 if (i!=index) continue;
1358 linphone_core_set_video_device(lc, dev[i]);
1359 linphonec_out("Using video device %s\n",dev[i]);
1362 linphonec_out("No such video device\n");
1365 return 0; /* syntax error */
1369 lpc_cmd_staticpic(LinphoneCore *lc, char *args)
1375 if (!args) return 0; /* Syntax error */
1377 /* Isolate first and second arg */
1378 while(*ptr && !isspace(*ptr)) ++ptr;
1383 while(*arg2 && isspace(*arg2)) ++arg2;
1386 if (strcmp(arg1, "set")==0 && arg2) {
1387 linphone_core_set_static_picture(lc, arg2);
1391 if (strcmp(arg1, "fps")==0) {
1393 float fps = atof(arg2); /* FIXME: Handle not-a-float */
1394 linphone_core_set_static_picture_fps(lc, fps);
1398 fps = linphone_core_get_static_picture_fps(lc);
1399 linphonec_out("Current FPS %f\n", fps);
1404 return 0; /* Syntax error */
1407 static int lpc_cmd_pause(LinphoneCore *lc, char *args){
1409 if(linphone_core_in_call(lc))
1411 linphone_core_pause_call(lc,linphone_core_get_current_call(lc));
1414 linphonec_out("you can only pause when a call is in process\n");
1418 static int lpc_cmd_resume(LinphoneCore *lc, char *args){
1420 if(linphone_core_in_call(lc))
1422 linphonec_out("There is already a call in process pause or stop it first");
1428 int n = sscanf(args, "%li", &id);
1430 LinphoneCall *call=linphonec_get_call (id);
1432 if(linphone_core_resume_call(lc,call)==-1){
1433 linphonec_out("There was a problem to resume the call check the remote address you gave %s\n",args);
1441 const MSList *calls = linphone_core_get_calls(lc);
1442 int nbcalls=ms_list_size(calls);
1445 if(linphone_core_resume_call(lc,calls->data) < 0)
1447 linphonec_out("There was a problem to resume the unique call.\n");
1450 }else if (nbcalls==0){
1451 linphonec_out("There is no calls at this time.\n");
1454 linphonec_out("There are %i calls at this time, please specify call id as given with 'calls' command.\n");
1461 /***************************************************************************
1463 * Commands helper functions
1465 ***************************************************************************/
1469 linphonec_proxy_add(LinphoneCore *lc)
1471 bool_t enable_register=FALSE;
1472 LinphoneProxyConfig *cfg;
1474 linphonec_out("Adding new proxy setup. Hit ^D to abort.\n");
1481 char *input=linphonec_readline("Enter proxy sip address: ");
1485 linphonec_out("Aborted.\n");
1490 clean=lpc_strip_blanks(input);
1496 cfg=linphone_proxy_config_new();
1497 if (linphone_proxy_config_set_server_addr(cfg,clean)<0)
1499 linphonec_out("Invalid sip address (sip:sip.domain.tld).\n");
1501 linphone_proxy_config_destroy(cfg);
1509 * SIP Proxy identity
1513 char *input=linphonec_readline("Your identity for this proxy: ");
1517 linphonec_out("Aborted.\n");
1518 linphone_proxy_config_destroy(cfg);
1523 clean=lpc_strip_blanks(input);
1529 linphone_proxy_config_set_identity(cfg, clean);
1530 if ( ! linphone_proxy_config_get_identity (cfg))
1532 linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
1541 * SIP Proxy enable register
1545 char *input=linphonec_readline("Do you want to register on this proxy (yes/no): ");
1549 linphonec_out("Aborted.\n");
1550 linphone_proxy_config_destroy(cfg);
1555 clean=lpc_strip_blanks(input);
1561 if ( ! strcmp(clean, "yes") ) enable_register=TRUE;
1562 else if ( ! strcmp(clean, "no") ) enable_register=FALSE;
1564 linphonec_out("Please answer with 'yes' or 'no'\n");
1568 linphone_proxy_config_enableregister(cfg, enable_register);
1574 * SIP Proxy registration expiration
1576 if ( enable_register==TRUE )
1581 char *input=linphonec_readline("Specify register expiration time"
1582 " in seconds (default is 600): ");
1585 linphonec_out("Aborted.\n");
1586 linphone_proxy_config_destroy(cfg);
1590 expires=strtol(input, (char **)NULL, 10);
1591 if ( expires == LONG_MIN || expires == LONG_MAX )
1593 linphonec_out("Invalid value: %s\n", strerror(errno));
1598 linphone_proxy_config_expires(cfg, expires);
1599 linphonec_out("Expiration: %d seconds\n", linphone_proxy_config_get_expires (cfg));
1611 char *input=linphonec_readline("Specify route if needed: ");
1615 linphonec_out("Aborted.\n");
1616 linphone_proxy_config_destroy(cfg);
1621 clean=lpc_strip_blanks(input);
1624 linphonec_out("No route specified.\n");
1628 linphone_proxy_config_set_route(cfg, clean);
1629 if ( ! linphone_proxy_config_get_route(cfg) )
1631 linphonec_out("Invalid route.\n");
1641 * Final confirmation
1648 linphonec_out("--------------------------------------------\n");
1649 linphonec_proxy_display(cfg);
1650 linphonec_out("--------------------------------------------\n");
1651 input=linphonec_readline("Accept the above proxy configuration (yes/no) ?: ");
1655 linphonec_out("Aborted.\n");
1656 linphone_proxy_config_destroy(cfg);
1661 clean=lpc_strip_blanks(input);
1667 if ( ! strcmp(clean, "yes") ) break;
1668 else if ( ! strcmp(clean, "no") )
1670 linphonec_out("Declined.\n");
1671 linphone_proxy_config_destroy(cfg);
1676 linphonec_out("Please answer with 'yes' or 'no'\n");
1682 linphone_core_add_proxy_config(lc,cfg);
1684 /* automatically set the last entered proxy as the default one */
1685 linphone_core_set_default_proxy(lc,cfg);
1687 linphonec_out("Proxy added.\n");
1691 linphonec_proxy_display(LinphoneProxyConfig *cfg)
1693 const char *route=linphone_proxy_config_get_route(cfg);
1694 const char *identity=linphone_proxy_config_get_identity(cfg);
1695 linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n",
1696 linphone_proxy_config_get_addr(cfg),
1697 (route!=NULL)? route:"",
1698 (identity!=NULL)?identity:"",
1699 linphone_proxy_config_register_enabled (cfg)?"yes":"no",
1700 linphone_proxy_config_get_expires (cfg),
1701 linphone_proxy_config_is_registered(cfg) ? "yes" : "no");
1704 static void linphonec_proxy_show(LinphoneCore *lc, int index)
1708 for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){
1710 LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)elem->data;
1711 linphonec_proxy_display(cfg);
1715 linphonec_out("No proxy with index %i\n", index);
1719 linphonec_proxy_list(LinphoneCore *lc)
1721 const MSList *proxies;
1723 int def=linphone_core_get_default_proxy(lc,NULL);
1725 proxies=linphone_core_get_proxy_config_list(lc);
1726 for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){
1728 linphonec_out("****** Proxy %i - this is the default one - *******\n",n);
1730 linphonec_out("****** Proxy %i *******\n",n);
1731 linphonec_proxy_display((LinphoneProxyConfig*)proxies->data);
1733 if ( ! n ) linphonec_out("No proxies defined\n");
1737 linphonec_proxy_remove(LinphoneCore *lc, int index)
1739 const MSList *proxies;
1740 LinphoneProxyConfig *cfg;
1741 proxies=linphone_core_get_proxy_config_list(lc);
1742 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1744 linphonec_out("No such proxy.\n");
1747 linphone_core_remove_proxy_config(lc,cfg);
1748 linphonec_out("Proxy %s removed.\n", linphone_proxy_config_get_addr(cfg));
1752 linphonec_proxy_use(LinphoneCore *lc, int index)
1754 const MSList *proxies;
1755 LinphoneProxyConfig *cfg;
1756 proxies=linphone_core_get_proxy_config_list(lc);
1757 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1759 linphonec_out("No such proxy (try 'proxy list').");
1762 linphone_core_set_default_proxy(lc,cfg);
1767 linphonec_friend_display(LinphoneFriend *fr)
1769 LinphoneAddress *uri=linphone_address_clone(linphone_friend_get_address(fr));
1772 linphonec_out("name: %s\n", linphone_address_get_display_name(uri));
1773 linphone_address_set_display_name(uri,NULL);
1774 str=linphone_address_as_string(uri);
1775 linphonec_out("address: %s\n", str);
1779 linphonec_friend_list(LinphoneCore *lc, char *pat)
1781 const MSList *friend;
1785 pat=lpc_strip_blanks(pat);
1786 if (!*pat) pat = NULL;
1789 friend = linphone_core_get_friend_list(lc);
1790 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1793 const char *name = linphone_address_get_display_name(
1794 linphone_friend_get_address((LinphoneFriend*)friend->data));
1795 if (name && ! strstr(name, pat) ) continue;
1797 linphonec_out("****** Friend %i *******\n",n);
1798 linphonec_friend_display((LinphoneFriend*)friend->data);
1805 linphonec_friend_call(LinphoneCore *lc, unsigned int num)
1807 const MSList *friend = linphone_core_get_friend_list(lc);
1811 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1816 addr = linphone_address_as_string(linphone_friend_get_address((LinphoneFriend*)friend->data));
1817 ret=lpc_cmd_call(lc, addr);
1822 linphonec_out("No such friend %u\n", num);
1828 linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr)
1830 LinphoneFriend *newFriend;
1834 snprintf(url, PATH_MAX, "%s <%s>", name, addr);
1835 newFriend = linphone_friend_new_with_addr(url);
1836 linphone_core_add_friend(lc, newFriend);
1842 linphonec_friend_delete(LinphoneCore *lc, int num)
1844 const MSList *friend = linphone_core_get_friend_list(lc);
1847 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1851 linphone_core_remove_friend(lc, friend->data);
1859 for (i = 0 ; i < n ; i++)
1860 linphonec_friend_delete(lc, 0);
1864 linphonec_out("No such friend %u\n", num);
1869 linphonec_display_command_help(LPC_COMMAND *cmd)
1871 if ( cmd->doc ) linphonec_out ("%s\n", cmd->doc);
1872 else linphonec_out("%s\n", cmd->help);
1876 static int lpc_cmd_register(LinphoneCore *lc, char *args){
1880 LinphoneProxyConfig *cfg;
1885 /* it means that you want to register the default proxy */
1886 LinphoneProxyConfig *cfg=NULL;
1887 linphone_core_get_default_proxy(lc,&cfg);
1890 if(!linphone_proxy_config_is_registered(cfg)) {
1891 linphone_proxy_config_enable_register(cfg,TRUE);
1892 linphone_proxy_config_done(cfg);
1894 linphonec_out("default proxy already registered\n");
1897 linphonec_out("we do not have a default proxy\n");
1902 passwd[0]=proxy[0]=identity[0]='\0';
1903 sscanf(args,"%s %s %s",identity,proxy,passwd);
1904 if (proxy[0]=='\0' || identity[0]=='\0'){
1905 linphonec_out("Missing parameters, see help register\n");
1908 if (passwd[0]!='\0'){
1909 LinphoneAddress *from;
1910 LinphoneAuthInfo *info;
1911 if ((from=linphone_address_new(identity))!=NULL){
1913 snprintf(realm,sizeof(realm)-1,"\"%s\"",linphone_address_get_domain(from));
1914 info=linphone_auth_info_new(linphone_address_get_username(from),NULL,passwd,NULL,NULL);
1915 linphone_core_add_auth_info(lc,info);
1916 linphone_address_destroy(from);
1917 linphone_auth_info_destroy(info);
1920 elem=linphone_core_get_proxy_config_list(lc);
1922 cfg=(LinphoneProxyConfig*)elem->data;
1923 linphone_proxy_config_edit(cfg);
1925 else cfg=linphone_proxy_config_new();
1926 linphone_proxy_config_set_identity(cfg,identity);
1927 linphone_proxy_config_set_server_addr(cfg,proxy);
1928 linphone_proxy_config_enable_register(cfg,TRUE);
1929 if (elem) linphone_proxy_config_done(cfg);
1930 else linphone_core_add_proxy_config(lc,cfg);
1931 linphone_core_set_default_proxy(lc,cfg);
1935 static int lpc_cmd_unregister(LinphoneCore *lc, char *args){
1936 LinphoneProxyConfig *cfg=NULL;
1937 linphone_core_get_default_proxy(lc,&cfg);
1938 if (cfg && linphone_proxy_config_is_registered(cfg)) {
1939 linphone_proxy_config_edit(cfg);
1940 linphone_proxy_config_enable_register(cfg,FALSE);
1941 linphone_proxy_config_done(cfg);
1943 linphonec_out("unregistered\n");
1948 static int lpc_cmd_duration(LinphoneCore *lc, char *args){
1949 LinphoneCallLog *cl;
1950 const MSList *elem=linphone_core_get_call_logs(lc);
1951 for(;elem!=NULL;elem=elem->next){
1952 if (elem->next==NULL){
1953 cl=(LinphoneCallLog*)elem->data;
1954 linphonec_out("%i seconds\n",cl->duration);
1960 static int lpc_cmd_status(LinphoneCore *lc, char *args)
1962 LinphoneProxyConfig *cfg;
1964 if ( ! args ) return 0;
1965 linphone_core_get_default_proxy(lc,&cfg);
1966 if (strstr(args,"register"))
1970 if (linphone_proxy_config_is_registered(cfg)){
1971 linphonec_out("registered, identity=%s duration=%i\n",
1972 linphone_proxy_config_get_identity(cfg),
1973 linphone_proxy_config_get_expires(cfg));
1974 }else if (linphone_proxy_config_register_enabled(cfg)){
1975 linphonec_out("registered=-1\n");
1976 }else linphonec_out("registered=0\n");
1978 else linphonec_out("registered=0\n");
1980 else if (strstr(args,"autoanswer"))
1982 if (cfg && linphone_proxy_config_is_registered(cfg))
1983 linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer());
1984 else linphonec_out("unregistered\n");
1986 else if (strstr(args,"hook"))
1988 LinphoneCall *call=linphone_core_get_current_call (lc);
1989 LinphoneCallState call_state=LinphoneCallIdle;
1990 if (call) call_state=linphone_call_get_state(call);
1993 case LinphoneCallOutgoingInit:
1994 linphonec_out("hook=outgoing_init sip:%s\n",linphonec_get_callee());
1996 case LinphoneCallOutgoingProgress:
1997 linphonec_out("hook=dialing sip:%s\n",linphonec_get_callee());
1999 case LinphoneCallOutgoingRinging:
2000 linphonec_out("hook=ringing sip:%s\n",linphonec_get_callee());
2002 case LinphoneCallPaused:
2003 linphonec_out("hook=paused sip:%s\n",linphonec_get_callee());
2005 case LinphoneCallIdle:
2006 linphonec_out("hook=offhook\n");
2008 case LinphoneCallStreamsRunning:
2009 case LinphoneCallConnected:
2010 if (linphone_call_get_dir(call)==LinphoneCallOutgoing){
2011 linphonec_out("Call out, hook=%s duration=%i, muted=%s rtp-xmit-muted=%s\n", linphonec_get_callee(),
2012 linphone_core_get_current_call_duration(lc),
2013 linphone_core_is_mic_muted (lc) ? "yes" : "no",
2014 linphone_core_is_rtp_muted(lc) ? "yes" : "no");
2016 linphonec_out("hook=answered duration=%i %s\n" ,
2017 linphone_core_get_current_call_duration(lc), linphonec_get_caller());
2020 case LinphoneCallIncomingReceived:
2021 linphonec_out("Incoming call from %s\n",linphonec_get_caller());
2033 static int lpc_cmd_ports(LinphoneCore *lc, char *args)
2037 linphonec_out("sip port = %i\naudio rtp port = %i\nvideo rtp port = %i\n",
2038 linphone_core_get_sip_port(lc),
2039 linphone_core_get_audio_port(lc),
2040 linphone_core_get_video_port(lc));
2043 if (sscanf(args,"sip %i",&port)==1){
2044 linphonec_out("Setting sip port to %i\n",port);
2045 linphone_core_set_sip_port(lc,port);
2051 static int lpc_cmd_param(LinphoneCore *lc, char *args)
2053 char section[20], param[20], value[50];
2059 switch (sscanf(args,"%s %s %s",section,param,value)) {
2060 // case 1 might show all current settings under a section
2062 string = lp_config_get_string(linphone_core_get_config(lc), section, param, "(undef)");
2063 linphonec_out("current value: %s\n", string);
2066 if (lp_config_get_string(linphone_core_get_config(lc), section, param, NULL) != NULL) {
2067 lp_config_set_string(linphone_core_get_config(lc), section, param, value);
2068 // no indication of existence
2069 linphonec_out("updated value: %s\n", value);
2071 linphonec_out("only update of existing variables are allowed\n");
2080 static int lpc_cmd_speak(LinphoneCore *lc, char *args){
2089 if (!args) return 0;
2090 memset(voice,0,sizeof(voice));
2091 sscanf(args,"%s63",voice);
2092 sentence=args+strlen(voice);
2093 wavfile=tempnam("/tmp/","linphonec-espeak-");
2094 snprintf(cl,sizeof(cl),"espeak -v %s -s 100 -w %s --stdin",voice,wavfile);
2097 ms_error("Could not open pipe to espeak !");
2100 fprintf(file,"%s",sentence);
2101 status=pclose(file);
2102 if (WEXITSTATUS(status)==0){
2103 linphone_core_set_play_file(lc,wavfile);
2105 linphonec_out("espeak command failed.");
2108 linphonec_out("Sorry, this command is not implemented in windows version.");
2113 static int lpc_cmd_acodec(LinphoneCore *lc, char *args){
2114 return lpc_cmd_codec(AUDIO, lc, args);
2117 static int lpc_cmd_vcodec(LinphoneCore *lc, char *args){
2118 return lpc_cmd_codec(VIDEO, lc, args);
2121 static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args){
2126 if (!args) return 0;
2128 /* Isolate first and second arg */
2129 while(*ptr && !isspace(*ptr)) ++ptr;
2134 while(*arg2 && isspace(*arg2)) ++arg2;
2137 if (strcmp(arg1,"enable")==0)
2139 #ifdef HAVE_READLINE
2140 rl_inhibit_completion=1;
2142 if (!strcmp(arg2,"all")) linphonec_codec_enable(type,lc,-1);
2143 else linphonec_codec_enable(type,lc,atoi(arg2));
2144 #ifdef HAVE_READLINE
2145 rl_inhibit_completion=0;
2148 else if (strcmp(arg1,"list")==0)
2150 linphonec_codec_list(type,lc);
2152 else if (strcmp(arg1,"disable")==0)
2154 if (!strcmp(arg2,"all")) linphonec_codec_disable(type,lc,-1);
2155 else linphonec_codec_disable(type,lc,atoi(arg2));
2159 return 0; /* syntax error */
2165 static void linphonec_codec_list(int type, LinphoneCore *lc){
2168 const MSList *node=NULL;
2170 if (type == AUDIO) {
2171 node=linphone_core_get_audio_codecs(lc);
2172 } else if(type==VIDEO) {
2173 node=linphone_core_get_video_codecs(lc);
2176 for(;node!=NULL;node=ms_list_next(node)){
2177 pt=(PayloadType*)(node->data);
2178 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate,
2179 linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled");
2184 static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){
2187 const MSList *node=NULL;
2189 if (type == AUDIO) {
2190 node=linphone_core_get_audio_codecs(lc);
2191 } else if(type==VIDEO) {
2192 node=linphone_core_get_video_codecs(lc);
2195 for(;node!=NULL;node=ms_list_next(node)){
2196 if (index == sel_index || sel_index == -1) {
2197 pt=(PayloadType*)(node->data);
2198 linphone_core_enable_payload_type (lc,pt,TRUE);
2199 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled");
2205 static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){
2208 const MSList *node=NULL;
2210 if (type == AUDIO) {
2211 node=linphone_core_get_audio_codecs(lc);
2212 } else if(type==VIDEO) {
2213 node=linphone_core_get_video_codecs(lc);
2216 for(;node!=NULL;node=ms_list_next(node)){
2217 if (index == sel_index || sel_index == -1) {
2218 pt=(PayloadType*)(node->data);
2219 linphone_core_enable_payload_type (lc,pt,FALSE);
2220 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
2226 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
2230 LpConfig *config=linphone_core_get_config(lc);
2232 if (!args) return 0;
2234 /* Isolate first and second arg */
2235 while(*ptr && !isspace(*ptr)) ++ptr;
2240 while(*arg2 && isspace(*arg2)) ++arg2;
2243 if (strcmp(arg1,"on")==0){
2244 int delay, tail_len, frame_size;
2247 linphone_core_enable_echo_cancellation(lc,1);
2250 n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size);
2253 lp_config_set_int(config,"sound","ec_delay",delay);
2256 lp_config_set_int(config,"sound","ec_delay",delay);
2257 lp_config_set_int(config,"sound","ec_tail_len",tail_len);
2260 lp_config_set_int(config,"sound","ec_delay",delay);
2261 lp_config_set_int(config,"sound","ec_tail_len",tail_len);
2262 lp_config_set_int(config,"sound","ec_framesize",frame_size);
2266 else if (strcmp(arg1,"off")==0){
2267 linphone_core_enable_echo_cancellation(lc,0);
2269 else if (strcmp(arg1,"show")==0){
2270 linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",
2271 linphone_core_echo_cancellation_enabled(lc) ? "on" : "off",
2272 lp_config_get_int(config,"sound","ec_delay",0),
2273 lp_config_get_int(config,"sound","ec_tail_len",0),
2274 lp_config_get_int(config,"sound","ec_framesize",0));
2283 static int lpc_cmd_echolimiter(LinphoneCore *lc, char *args){
2285 if (strcmp(args,"on")==0){
2286 linphone_core_enable_echo_limiter (lc,TRUE);
2287 }else if (strcmp(args,"off")==0){
2288 linphone_core_enable_echo_limiter (lc,FALSE);
2291 linphonec_out("Echo limiter is now %s.\n",linphone_core_echo_limiter_enabled (lc) ? "on":"off");
2295 static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args)
2297 linphone_core_mute_mic(lc, 1);
2301 static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args){
2302 linphone_core_mute_mic(lc, 0);
2306 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args)
2308 bool_t rtp_xmit_off=FALSE;
2312 if(strstr(args,"1"))rtp_xmit_off=TRUE;
2313 if(linphone_core_get_current_call (lc)==NULL)
2314 linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_xmit_off);
2316 linphonec_out("nortp-on-audio-mute: call in progress - cannot change state\n");
2318 rtp_xmit_off=linphone_core_get_rtp_no_xmit_on_audio_mute(lc);
2319 if (rtp_xmit_off) status="off";
2321 linphonec_out("rtp transmit %s when audio muted\n",status);
2325 #ifdef VIDEO_ENABLED
2326 static int _lpc_cmd_video_window(LinphoneCore *lc, char *args, bool_t is_preview){
2327 char subcommand[64];
2330 VideoParams *params=is_preview ? &lpc_preview_params : &lpc_video_params;
2332 if (!args) return 0;
2333 err=sscanf(args,"%s %i %i",subcommand,&a,&b);
2335 if (strcmp(subcommand,"pos")==0){
2336 if (err<3) return 0;
2339 params->refresh=TRUE;
2340 }else if (strcmp(subcommand,"size")==0){
2341 if (err<3) return 0;
2344 params->refresh=TRUE;
2345 }else if (strcmp(subcommand,"show")==0){
2347 params->refresh=TRUE;
2348 if (is_preview) linphone_core_enable_video_preview (lc,TRUE);
2349 }else if (strcmp(subcommand,"hide")==0){
2351 params->refresh=TRUE;
2352 if (is_preview) linphone_core_enable_video_preview (lc,FALSE);
2353 }else if (strcmp(subcommand,"id")==0){
2355 linphonec_out("vwindow id: 0x%x\n",is_preview ? linphone_core_get_native_preview_window_id (lc) :
2356 linphone_core_get_native_video_window_id (lc));
2358 } else if (err != 2) return 0;
2361 linphone_core_set_native_preview_window_id (lc,a);
2363 linphone_core_set_native_video_window_id(lc,a);
2364 }else if (is_preview==TRUE){
2365 if (strcmp(subcommand,"integrated")==0){
2366 linphone_core_use_preview_window (lc,FALSE);
2367 }else if (strcmp(subcommand,"standalone")==0){
2368 linphone_core_use_preview_window(lc,TRUE);
2375 static int lpc_cmd_video_window(LinphoneCore *lc, char *args){
2376 return _lpc_cmd_video_window(lc, args, FALSE);
2379 static int lpc_cmd_preview_window(LinphoneCore *lc, char *args){
2380 return _lpc_cmd_video_window(lc, args, TRUE);
2384 static void lpc_display_global_state(LinphoneCore *lc){
2385 linphonec_out("Global liblinphone state\n%s\n",
2386 linphone_global_state_to_string(linphone_core_get_global_state(lc)));
2389 static void lpc_display_call_states(LinphoneCore *lc){
2393 linphonec_out("Call states\n"
2394 "Id | Destination | State\n"
2395 "---------------------------------------------------------------\n");
2396 elem=linphone_core_get_calls(lc);
2398 linphonec_out("(empty)\n");
2400 for(;elem!=NULL;elem=elem->next){
2401 call=(LinphoneCall*)elem->data;
2402 tmp=linphone_call_get_remote_address_as_string (call);
2403 linphonec_out("%-2i | %-35s | %s\n",(int)(long)linphone_call_get_user_pointer(call),
2404 tmp,linphone_call_state_to_string(linphone_call_get_state(call)));
2410 static void lpc_display_proxy_states(LinphoneCore *lc){
2412 linphonec_out("Proxy registration states\n"
2413 " Identity | State\n"
2414 "------------------------------------------------------------\n");
2415 elem=linphone_core_get_proxy_config_list (lc);
2416 if (elem==NULL) linphonec_out("(empty)\n");
2418 for(;elem!=NULL;elem=elem->next){
2419 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
2420 linphonec_out("%-40s | %s\n",linphone_proxy_config_get_identity (cfg),
2421 linphone_registration_state_to_string(linphone_proxy_config_get_state(cfg)));
2426 static int lpc_cmd_states(LinphoneCore *lc, char *args){
2428 lpc_display_global_state(lc);
2429 lpc_display_call_states(lc);
2430 lpc_display_proxy_states(lc);
2433 if (strcmp(args,"global")==0){
2434 lpc_display_global_state(lc);
2437 if (strcmp(args,"proxies")==0){
2438 lpc_display_proxy_states(lc);
2441 if (strcmp(args,"calls")==0){
2442 lpc_display_call_states(lc);
2448 #ifdef VIDEO_ENABLED
2449 static int lpc_cmd_camera(LinphoneCore *lc, char *args){
2450 LinphoneCall *call=linphone_core_get_current_call(lc);
2451 bool_t activated=FALSE;
2453 if (linphone_core_video_enabled (lc)==FALSE){
2454 linphonec_out("Video is disabled, re-run linphonec with -V option.");
2459 if (strcmp(args,"on")==0)
2461 else if (strcmp(args,"off")==0)
2469 linphonec_camera_enabled=activated;
2471 if (linphonec_camera_enabled){
2472 linphonec_out("Camera is enabled. Video stream will be setup immediately for outgoing and incoming calls.\n");
2474 linphonec_out("Camera is disabled. Calls will be established with audio-only, with the possibility to later add video using 'camera on'.\n");
2477 const LinphoneCallParams *cp=linphone_call_get_current_params (call);
2479 linphone_call_enable_camera(call,activated);
2480 if ((activated && !linphone_call_params_video_enabled (cp))){
2481 /*update the call to add the video stream*/
2482 LinphoneCallParams *ncp=linphone_call_params_copy(cp);
2483 linphone_call_params_enable_video(ncp,TRUE);
2484 linphone_core_update_call(lc,call,ncp);
2485 linphone_call_params_destroy (ncp);
2486 linphonec_out("Trying to bring up video stream...\n");
2489 if (linphone_call_camera_enabled (call))
2490 linphonec_out("Camera is allowed for current call.\n");
2491 else linphonec_out("Camera is dis-allowed for current call.\n");
2496 static int lpc_cmd_snapshot(LinphoneCore *lc, char *args){
2498 if (!args) return 0;
2499 call=linphone_core_get_current_call(lc);
2501 linphone_call_take_video_snapshot(call,args);
2502 linphonec_out("Taking video snapshot in file %s\n", args);
2503 }else linphonec_out("There is no active call.\n");
2507 static int lpc_cmd_vfureq(LinphoneCore *lc, char *arg){
2509 call=linphone_core_get_current_call(lc);
2511 linphone_call_send_vfu_request(call);
2512 linphonec_out("VFU request sent\n");
2513 }else linphonec_out("There is no active call.\n");
2518 static int lpc_cmd_identify(LinphoneCore *lc, char *args){
2520 const char *remote_ua;
2522 call=linphone_core_get_current_call(lc);
2524 linphonec_out("There is currently running call. Specify call id.\n");
2528 call=linphonec_get_call(atoi(args));
2533 remote_ua=linphone_call_get_remote_user_agent(call);
2535 linphonec_out("Remote user agent string is: %s\n",remote_ua);
2540 static int lpc_cmd_ringback(LinphoneCore *lc, char *args){
2541 if (!args) return 0;
2542 if (strcmp(args,"disable")==0){
2543 linphone_core_set_remote_ringback_tone(lc,NULL);
2544 linphonec_out("Disabling ringback tone.\n");
2547 linphone_core_set_remote_ringback_tone (lc,args);
2548 linphonec_out("Using %s as ringback tone to be played to callers.",args);
2552 /***************************************************************************
2554 * Command table management funx
2556 ***************************************************************************/
2559 * Find a command given its name
2561 static LPC_COMMAND *
2562 lpc_find_command(const char *name)
2566 for (i=0; commands[i].name; ++i)
2568 if (strcmp(name, commands[i].name) == 0)
2569 return &commands[i];
2572 for (i=0; advanced_commands[i].name; ++i)
2574 if (strcmp(name, advanced_commands[i].name) == 0)
2575 return &advanced_commands[i];
2578 return (LPC_COMMAND *)NULL;
2582 /****************************************************************************
2584 * $Log: commands.c,v $
2585 * Revision 1.39 2008/07/03 15:08:34 smorlat
2586 * api cleanups, interface in progress.
2588 * Revision 1.38 2008/06/17 20:38:59 smorlat
2589 * added missing file.
2591 * Revision 1.37 2008/04/09 09:26:00 smorlat
2592 * merge various patches
2595 * Revision 1.36 2007/08/01 14:47:53 strk
2596 * * console/commands.c: Clean up commands 'nat', 'stun'
2597 * and 'firewall' to be more intuitive.
2599 * Revision 1.35 2007/06/27 09:01:25 smorlat
2600 * logging improvements.
2602 * Revision 1.34 2007/02/20 10:17:13 smorlat
2603 * linphonec friends patch2
2605 * Revision 1.31 2006/09/22 07:22:47 smorlat
2606 * linphonecore api changes.
2608 * Revision 1.30 2006/09/08 15:32:57 smorlat
2609 * support for using files instead of soundcard (used by linphonec only)
2611 * Revision 1.29 2006/08/28 14:29:07 smorlat
2614 * Revision 1.28 2006/08/21 12:49:59 smorlat
2615 * merged several little patches.
2617 * Revision 1.27 2006/07/17 18:45:00 smorlat
2618 * support for several event queues in ortp.
2619 * glib dependency removed from coreapi/ and console/
2621 * Revision 1.26 2006/04/14 15:16:36 smorlat
2622 * soundcard use did nothing !
2624 * Revision 1.25 2006/04/06 20:09:33 smorlat
2625 * add linphonec command to see and select sound devices.
2627 * Revision 1.24 2006/03/04 11:17:10 smorlat
2628 * mediastreamer2 in progress.
2630 * Revision 1.23 2006/02/20 21:14:01 strk
2631 * Handled syntax errors with 'friend' command
2633 * Revision 1.22 2006/02/20 10:20:29 strk
2634 * Added substring-based filter support for command 'friend list'
2636 * Revision 1.21 2006/02/02 15:39:18 strk
2637 * - Added 'friend list' and 'friend call' commands
2638 * - Allowed for multiple DTFM send in a single line
2639 * - Added status-specific callback (bare version)
2641 * Revision 1.20 2006/01/26 11:54:34 strk
2642 * More robust 'nat' command handler (strip blanks in args)
2644 * Revision 1.19 2006/01/26 09:48:05 strk
2645 * Added limits.h include
2647 * Revision 1.18 2006/01/26 02:18:05 strk
2648 * Added new commands 'nat use' and 'nat unuse'.
2649 * These will required a pending patch to linphonecore.c
2652 * Revision 1.17 2006/01/20 14:12:33 strk
2653 * Added linphonec_init() and linphonec_finish() functions.
2654 * Handled SIGINT and SIGTERM to invoke linphonec_finish().
2655 * Handling of auto-termination (-t) moved to linphonec_finish().
2656 * Reworked main (input read) loop to not rely on 'terminate'
2657 * and 'run' variable (dropped). configfile_name allocated on stack
2658 * using PATH_MAX limit. Changed print_usage signature to allow
2659 * for an exit_status specification.
2661 * Revision 1.16 2006/01/18 09:25:32 strk
2662 * Command completion inhibited in proxy addition and auth request prompts.
2663 * Avoided use of linphonec_readline's internal filename completion.
2665 * Revision 1.15 2006/01/14 13:29:32 strk
2666 * Reworked commands interface to use a table structure,
2667 * used by command line parser and help function.
2668 * Implemented first level of completion (commands).
2669 * Added notification of invalid "answer" and "terminate"
2670 * commands (no incoming call, no active call).
2671 * Forbidden "call" intialization when a call is already active.
2672 * Cleaned up all commands, adding more feedback and error checks.
2674 * Revision 1.14 2006/01/13 13:00:29 strk
2675 * Added linphonec.h. Code layout change (added comments, forward decl,
2676 * globals on top, copyright notices and Logs). Handled out-of-memory
2677 * condition on history management. Removed assumption on sizeof(char).
2678 * Fixed bug in authentication prompt (introduced by linphonec_readline).
2679 * Added support for multiple authentication requests (up to MAX_PENDING_AUTH).
2682 ****************************************************************************/