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_playback_gain(LinphoneCore *lc, char *args);
94 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args);
96 static int lpc_cmd_camera(LinphoneCore *lc, char *args);
97 static int lpc_cmd_video_window(LinphoneCore *lc, char *args);
98 static int lpc_cmd_preview_window(LinphoneCore *lc, char *args);
99 static int lpc_cmd_snapshot(LinphoneCore *lc, char *args);
100 static int lpc_cmd_vfureq(LinphoneCore *lc, char *arg);
102 static int lpc_cmd_states(LinphoneCore *lc, char *args);
103 static int lpc_cmd_identify(LinphoneCore *lc, char *args);
104 static int lpc_cmd_ringback(LinphoneCore *lc, char *args);
105 static int lpc_cmd_conference(LinphoneCore *lc, char *args);
106 static int lpc_cmd_zrtp_verified(LinphoneCore *lc, char *args);
107 static int lpc_cmd_zrtp_unverified(LinphoneCore *lc, char *args);
109 /* Command handler helpers */
110 static void linphonec_proxy_add(LinphoneCore *lc);
111 static void linphonec_proxy_display(LinphoneProxyConfig *lc);
112 static void linphonec_proxy_list(LinphoneCore *lc);
113 static void linphonec_proxy_remove(LinphoneCore *lc, int index);
114 static int linphonec_proxy_use(LinphoneCore *lc, int index);
115 static void linphonec_proxy_show(LinphoneCore *lc,int index);
116 static void linphonec_friend_display(LinphoneFriend *fr);
117 static int linphonec_friend_list(LinphoneCore *lc, char *arg);
118 static void linphonec_display_command_help(LPC_COMMAND *cmd);
119 static int linphonec_friend_call(LinphoneCore *lc, unsigned int num);
121 static int linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr);
123 static int linphonec_friend_delete(LinphoneCore *lc, int num);
124 static int linphonec_friend_delete(LinphoneCore *lc, int num);
125 static void linphonec_codec_list(int type, LinphoneCore *lc);
126 static void linphonec_codec_enable(int type, LinphoneCore *lc, int index);
127 static void linphonec_codec_disable(int type, LinphoneCore *lc, int index);
128 static void lpc_display_call_states(LinphoneCore *lc);
130 /* Command table management */
131 static LPC_COMMAND *lpc_find_command(const char *name);
133 void linphonec_out(const char *fmt,...);
135 VideoParams lpc_video_params={-1,-1,-1,-1,0,TRUE};
136 VideoParams lpc_preview_params={-1,-1,-1,-1,0,TRUE};
138 /***************************************************************************
142 ***************************************************************************/
147 static LPC_COMMAND commands[] = {
148 { "help", lpc_cmd_help, "Print commands help.",
149 "'help <command>'\t: displays specific help for command.\n"
150 "'help advanced'\t: shows advanced commands.\n"
152 { "call", lpc_cmd_call, "Call a SIP uri or number",
154 "'call <sip-url or number> [options]' \t: initiate a call to the specified destination.\n"
156 "--audio-only : initiate the call without video.\n"
157 "--early-media : sends audio and video stream immediately when remote proposes early media.\n"
159 "'call <sip-url or number>' \t: initiate a call to the specified destination.\n"
162 { "calls", lpc_cmd_calls, "Show all the current calls with their id and status.",
165 { "chat", lpc_cmd_chat, "Chat with a SIP uri",
166 "'chat <sip-url> \"message\"' "
167 ": send a chat message \"message\" to the specified destination."
169 { "terminate", lpc_cmd_terminate, "Terminate a call",
170 "'terminate' : Terminate the current call\n"
171 "'terminate <call id>' : Terminate the call with supplied id\n"
172 "'terminate <all>' : Terminate all the current calls\n"
174 { "answer", lpc_cmd_answer, "Answer a call",
175 "'answer' : Answer the current incoming call\n"
176 "'answer <call id>' : Answer the call with given id\n"
178 { "pause", lpc_cmd_pause, "pause a call",
179 "'pause' : pause the current call\n"},
180 { "resume", lpc_cmd_resume, "resume a call",
181 "'resume' : resume the unique call\n"
182 "'resume <call id>' : hold off the call with given id\n"},
183 { "transfer", lpc_cmd_transfer,
184 "Transfer a call to a specified destination.",
185 "'transfer <sip-uri>' : transfers the current active call to the destination sip-uri\n"
186 "'transfer <call id> <sip-uri>': transfers the call with 'id' to the destination sip-uri\n"
187 "'transfer <call id1> --to-call <call id2>': transfers the call with 'id1' to the destination of call 'id2' (attended transfer)\n"
189 { "conference", lpc_cmd_conference, "Create and manage an audio conference.",
190 "'conference add <call id> : join the call with id 'call id' into the audio conference."
191 "'conference rm <call id> : remove the call with id 'call id' from the audio conference."
193 { "mute", lpc_cmd_mute_mic,
194 "Mute microphone and suspend voice transmission."},
196 { "camera", lpc_cmd_camera, "Send camera output for current call.",
197 "'camera on'\t: allow sending of local camera video to remote end.\n"
198 "'camera off'\t: disable sending of local camera's video to remote end.\n"},
200 { "unmute", lpc_cmd_unmute_mic,
201 "Unmute microphone and resume voice transmission."},
202 { "playbackgain", lpc_cmd_playback_gain,
203 "Adjust playback gain."},
204 { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL },
206 { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
207 "'autoanswer' \t: show current autoanswer mode\n"
208 "'autoanswer enable'\t: enable autoanswer mode\n"
209 "'autoanswer disable'\t: disable autoanswer modeĀ \n"},
210 { "proxy", lpc_cmd_proxy, "Manage proxies",
211 "'proxy list' : list all proxy setups.\n"
212 "'proxy add' : add a new proxy setup.\n"
213 "'proxy remove <index>' : remove proxy setup with number index.\n"
214 "'proxy use <index>' : use proxy with number index as default proxy.\n"
215 "'proxy unuse' : don't use a default proxy.\n"
216 "'proxy show <index>' : show configuration and status of the proxy numbered by index.\n"
217 "'proxy show default' : show configuration and status of the default proxy.\n"
219 { "soundcard", lpc_cmd_soundcard, "Manage soundcards",
220 "'soundcard list' : list all sound devices.\n"
221 "'soundcard show' : show current sound devices configuration.\n"
222 "'soundcard use <index>' : select a sound device.\n"
223 "'soundcard use files' : use .wav files instead of soundcard\n"
225 { "webcam", lpc_cmd_webcam, "Manage webcams",
226 "'webcam list' : list all known devices.\n"
227 "'webcam use <index>' : select a video device.\n"
229 { "ipv6", lpc_cmd_ipv6, "Use IPV6",
230 "'ipv6 status' : show ipv6 usage status.\n"
231 "'ipv6 enable' : enable the use of the ipv6 network.\n"
232 "'ipv6 disable' : do not use ipv6 network."
234 { "nat", lpc_cmd_nat, "Set nat address",
235 "'nat' : show nat settings.\n"
236 "'nat <addr>' : set nat address.\n"
238 { "stun", lpc_cmd_stun, "Set stun server address",
239 "'stun' : show stun settings.\n"
240 "'stun <addr>' : set stun server address.\n"
242 { "firewall", lpc_cmd_firewall, "Set firewall policy",
243 "'firewall' : show current firewall policy.\n"
244 "'firewall none' : use direct connection.\n"
245 "'firewall nat' : use nat address given with the 'nat' command.\n"
246 "'firewall stun' : use stun server given with the 'stun' command.\n"
248 { "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
249 { "friend", lpc_cmd_friend, "Manage friends",
250 "'friend list [<pattern>]' : list friends.\n"
251 "'friend call <index>' : call a friend.\n"
252 "'friend add <name> <addr>' : add friend, <name> must be quoted to include\n"
253 " spaces, <addr> has \"sip:\" added if it isn't\n"
254 " there. Don't use '<' '>' around <addr>.\n"
255 "'friend delete <index>' : remove friend, 'all' removes all\n"
257 { "play", lpc_cmd_play, "play a wav file",
258 "This command has two roles:\n"
259 "Plays a file instead of capturing from soundcard - only available in file mode (see 'help soundcard')\n"
260 "Specifies a wav file to be played to play music to far end when putting it on hold (pause)\n"
261 "'play <wav file>' : play a wav file."
263 { "record", lpc_cmd_record, "record to a wav file",
264 "This feature is available only in file mode (see 'help soundcard')\n"
265 "'record <wav file>' : record into wav file."
267 { "quit", lpc_cmd_quit, "Exit linphonec", NULL },
268 { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
272 static LPC_COMMAND advanced_commands[] = {
273 { "codec", lpc_cmd_acodec, "Audio codec configuration",
274 "'codec list' : list audio codecs\n"
275 "'codec enable <index>' : enable available audio codec\n"
276 "'codec disable <index>' : disable audio codec" },
277 { "vcodec", lpc_cmd_vcodec, "Video codec configuration",
278 "'vcodec list' : list video codecs\n"
279 "'vcodec enable <index>' : enable available video codec\n"
280 "'vcodec disable <index>' : disable video codec" },
281 { "ec", lpc_cmd_echocancellation, "Echo cancellation",
282 "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
283 "'ec off' : turn echo cancellation (EC) off\n"
284 "'ec show' : show EC status" },
285 { "el", lpc_cmd_echolimiter, "Echo limiter",
286 "'el on turns on echo limiter (automatic half duplex, for cases where echo canceller cannot work)\n"
287 "'el off' : turn echo limiter off\n"
288 "'el show' : show echo limiter status" },
289 { "nortp-on-audio-mute", lpc_cmd_rtp_no_xmit_on_audio_mute,
290 "Set the rtp_no_xmit_on_audio_mute configuration parameter",
291 " If set to 1 then rtp transmission will be muted when\n"
292 " audio is muted , otherwise rtp is always sent."},
294 { "vwindow", lpc_cmd_video_window, "Control video display window",
295 "'vwindow show': shows video window\n"
296 "'vwindow hide': hides video window\n"
297 "'vwindow pos <x> <y>': Moves video window to x,y pixel coordinates\n"
298 "'vwindow size <width> <height>': Resizes video window\n"
299 "'vwindow id <window id>': embeds video display into supplied window id."
301 { "pwindow", lpc_cmd_preview_window, "Control local camera video display (preview window)",
302 "'pwindow show': shows the local camera video display\n"
303 "'pwindow hide': hides the local camera video display\n"
304 "'pwindow pos <x> <y>': Moves preview window to x,y pixel coordinates\n"
305 "'pwindow size <width> <height>': Resizes preview window\n"
306 "'pwindow id <window id>': embeds preview display into supplied window id.\n"
307 "'pwindow integrated': integrate preview display within the video window of current call.\n"
308 "'pwindow standalone': use standalone window for preview display."
310 { "snapshot", lpc_cmd_snapshot, "Take a snapshot of currently received video stream",
311 "'snapshot <file path>': take a snapshot and records it in jpeg format into the supplied path\n"
313 { "vfureq", lpc_cmd_vfureq, "Request the other side to send VFU for the current call"},
315 { "states", lpc_cmd_states, "Show internal states of liblinphone, registrations and calls, according to linphonecore.h definitions",
316 "'states global': shows global state of liblinphone \n"
317 "'states calls': shows state of calls\n"
318 "'states proxies': shows state of proxy configurations"
320 { "register", lpc_cmd_register, "Register in one line to a proxy" , "register <sip identity> <sip proxy> <password>"},
321 { "unregister", lpc_cmd_unregister, "Unregister from default proxy", NULL },
322 { "status", lpc_cmd_status, "Print various status information",
323 "'status register' \t: print status concerning registration\n"
324 "'status autoanswer'\t: tell whether autoanswer mode is enabled\n"
325 "'status hook' \t: print hook status\n" },
326 { "ports", lpc_cmd_ports, "Network ports configuration",
327 "'ports' \t: prints current used ports.\n"
328 "'ports sip <port number>'\t: Sets the sip port.\n" },
329 { "param", lpc_cmd_param, "parameter set or read as normally given in .linphonerc",
330 "'param <section> <parameter> [<value>]' \t: reads [sets] given parameter.\n"
331 "NOTES: - changes may become effective after (re)establishing a sip connection.\n"
332 " - upon exit, .linphonerc will reflect the updated state.\n" },
333 { "speak", lpc_cmd_speak, "Speak a sentence using espeak TTS engine",
334 "This feature is available only in file mode. (see 'help soundcard')\n"
335 "'speak <voice name> <sentence>' : speak a text using the specified espeak voice.\n"
336 "Example for english voice: 'speak default Hello my friend !'"
338 { "staticpic", lpc_cmd_staticpic, "Manage static pictures when nowebcam",
339 "'staticpic set' : Set path to picture that should be used.\n"
340 "'staticpic fps' : Get/set frames per seconds for picture emission.\n"
342 { "identify", lpc_cmd_identify, "Returns the user-agent string of far end",
343 "'identify' \t: returns remote user-agent string for current call.\n"
344 "'identify <id>' \t: returns remote user-agent string for call with supplied id.\n"
346 { "ringback", lpc_cmd_ringback, "Specifies a ringback tone to be played to remote end during incoming calls",
347 "'ringback <path of mono .wav file>'\t: Specifies a ringback tone to be played to remote end during incoming calls\n"
348 "'ringback disable'\t: Disable playing of ringback tone to callers\n"
350 { "redirect", lpc_cmd_redirect, "Redirect an incoming call",
351 "'redirect <redirect-uri>'\t: Redirect all pending incoming calls to the <redirect-uri>\n"
353 { "zrtp-set-verified", lpc_cmd_zrtp_verified,"Set ZRTP SAS verified.",
354 "'Set ZRTP SAS verified'\n"
356 { "zrtp-set-unverified", lpc_cmd_zrtp_unverified,"Set ZRTP SAS not verified.",
357 "'Set ZRTP SAS not verified'\n"
359 { NULL,NULL,NULL,NULL}
364 /***************************************************************************
368 ***************************************************************************/
371 * Main command dispatcher.
372 * WARNING: modifies second argument!
374 * Always return 1 currently.
377 linphonec_parse_command_line(LinphoneCore *lc, char *cl)
383 /* Isolate first word and args */
384 while(*ptr && !isspace(*ptr)) ++ptr;
388 /* set args to first nonblank */
390 while(*args && isspace(*args)) ++args;
394 if ( isdigit(*cl) || *cl == '#' || *cl == '*' )
396 while ( isdigit(*cl) || *cl == '#' || *cl == '*' )
398 linphone_core_send_dtmf(lc, *cl);
399 linphone_core_play_dtmf (lc,*cl,100);
400 ms_sleep(1); // be nice
404 // discard spurious trailing chars
408 /* Handle other kind of commands */
409 cmd=lpc_find_command(cl);
412 linphonec_out("'%s': Cannot understand this.\n", cl);
416 if ( ! cmd->func(lc, args) )
418 linphonec_out("Syntax error.\n");
419 linphonec_display_command_help(cmd);
426 * Generator function for command completion.
427 * STATE let us know whether to start from scratch;
428 * without any state (STATE==0), then we start at the
432 linphonec_command_generator(const char *text, int state)
434 static int index, len, adv;
444 * Return the next name which partially matches
445 * from the commands list
448 while ((name=commands[index].name))
450 ++index; /* so next call get next command */
452 if (strncmp(name, text, len) == 0)
454 return ortp_strdup(name);
461 while ((name=advanced_commands[index].name))
463 ++index; /* so next call get next command */
465 if (strncmp(name, text, len) == 0)
467 return ortp_strdup(name);
475 /***************************************************************************
479 ***************************************************************************/
482 lpc_cmd_help(LinphoneCore *lc, char *arg)
489 linphonec_out("Commands are:\n");
490 linphonec_out("---------------------------\n");
492 while (commands[i].help)
494 linphonec_out("%10.10s\t%s\n", commands[i].name,
499 linphonec_out("---------------------------\n");
500 linphonec_out("Type 'help <command>' for more details or\n");
501 linphonec_out(" 'help advanced' to list additional commands.\n");
506 if (strcmp(arg,"advanced")==0){
507 linphonec_out("Advanced commands are:\n");
508 linphonec_out("---------------------------\n");
510 while (advanced_commands[i].help)
512 linphonec_out("%10.10s\t%s\n", advanced_commands[i].name,
513 advanced_commands[i].help);
517 linphonec_out("---------------------------\n");
518 linphonec_out("Type 'help <command>' for more details.\n");
523 cmd=lpc_find_command(arg);
526 linphonec_out("No such command.\n");
530 linphonec_display_command_help(cmd);
535 static char callee_name[256]={0};
536 static char caller_name[256]={0};
540 lpc_cmd_call(LinphoneCore *lc, char *args)
542 if ( ! args || ! *args )
548 LinphoneCallParams *cp=linphone_core_create_default_call_parameters (lc);
550 if ( linphone_core_in_call(lc) )
552 linphonec_out("Terminate or hold on the current call first.\n");
555 opt1=strstr(args,"--audio-only");
556 opt2=strstr(args,"--early-media");
559 linphone_call_params_enable_video (cp,FALSE);
563 linphone_call_params_enable_early_media_sending(cp,TRUE);
565 if ( NULL == (call=linphone_core_invite_with_params(lc, args,cp)) )
567 linphonec_out("Error from linphone_core_invite.\n");
571 snprintf(callee_name,sizeof(callee_name),"%s",args);
573 linphone_call_params_destroy(cp);
579 lpc_cmd_calls(LinphoneCore *lc, char *args){
580 const MSList *calls = linphone_core_get_calls(lc);
583 lpc_display_call_states(lc);
586 linphonec_out("No active call.\n");
593 lpc_cmd_chat(LinphoneCore *lc, char *args)
601 /* Isolate first and second arg */
602 while(*ptr && !isspace(*ptr)) ++ptr;
607 while(*arg2 && isspace(*arg2)) ++arg2;
611 /* missing one parameter */
614 LinphoneChatRoom *cr = linphone_core_create_chat_room(lc,arg1);
615 linphone_chat_room_send_message(cr,arg2);
616 linphone_chat_room_destroy(cr);
621 const char *linphonec_get_callee(){
625 const char *linphonec_get_caller(){
629 void linphonec_set_caller(const char *caller){
630 snprintf(caller_name,sizeof(caller_name)-1,"%s",caller);
634 lpc_cmd_transfer(LinphoneCore *lc, char *args)
639 const char *refer_to=NULL;
643 int n=sscanf(args,"%255s %265s %li",arg1,arg2,&id2);
644 if (n==1 || isalpha(*arg1)){
645 call=linphone_core_get_current_call(lc);
646 if (call==NULL && ms_list_size(linphone_core_get_calls(lc))==1){
647 call=(LinphoneCall*)linphone_core_get_calls(lc)->data;
651 linphonec_out("No active call, please specify a call id among the ones listed by 'calls' command.\n");
654 linphone_core_transfer_call(lc, call, refer_to);
657 refer_to=args+strlen(arg1)+1;
658 call=linphonec_get_call(id);
659 if (call==NULL) return 0;
660 linphone_core_transfer_call(lc, call, refer_to);
663 call=linphonec_get_call(id);
664 call2=linphonec_get_call(id2);
665 if (call==NULL || call2==NULL) return 0;
666 if (strcmp(arg2,"--to-call")!=0){
669 linphonec_out("Performing attended transfer of call %i to call %i",id,id2);
670 linphone_core_transfer_call_to_another (lc,call,call2);
673 linphonec_out("Transfer command requires at least one argument\n");
680 lpc_cmd_terminate(LinphoneCore *lc, char *args)
682 if (linphone_core_get_calls(lc)==NULL){
683 linphonec_out("No active calls\n");
688 if ( -1 == linphone_core_terminate_call(lc, NULL) ){
689 linphonec_out("Could not stop the active call.\n");
694 if(strcmp(args,"all")==0){
695 linphonec_out("We are going to stop all the calls.\n");
696 linphone_core_terminate_all_calls(lc);
699 /*the argument is a linphonec call id */
701 LinphoneCall *call=linphonec_get_call(id);
703 if (linphone_core_terminate_call(lc,call)==-1){
704 linphonec_out("Could not stop the call with id %li\n",id);
714 lpc_cmd_redirect(LinphoneCore *lc, char *args){
718 if ((elem=linphone_core_get_calls(lc))==NULL){
719 linphonec_out("No active calls.\n");
723 LinphoneCall *call=(LinphoneCall*)elem->data;
724 if (linphone_call_get_state(call)==LinphoneCallIncomingReceived){
725 linphone_core_redirect_call(lc,call,args);
727 /*as the redirection closes the call, we need to re-check the call list that is invalidated.*/
728 elem=linphone_core_get_calls(lc);
729 }else elem=elem->next;
732 linphonec_out("There is no pending incoming call to redirect.");
738 lpc_cmd_answer(LinphoneCore *lc, char *args){
741 int nb=ms_list_size(linphone_core_get_calls(lc));
743 //if just one call is present answer the only one in passing NULL to the linphone_core_accept_call ...
744 if ( -1 == linphone_core_accept_call(lc, NULL) )
746 linphonec_out("Fail to accept incoming call\n");
749 linphonec_out("There are no calls to answer.\n");
751 linphonec_out("Multiple calls in progress, please specify call id.\n");
757 if (sscanf(args,"%li",&id)==1){
758 LinphoneCall *call=linphonec_get_call (id);
759 if (linphone_core_accept_call (lc,call)==-1){
760 linphonec_out("Fail to accept call %i\n",id);
769 lpc_cmd_autoanswer(LinphoneCore *lc, char *args)
773 if ( linphonec_get_autoanswer() ) {
774 linphonec_out("Auto answer is enabled. Use 'autoanswer disable' to disable.\n");
776 linphonec_out("Auto answer is disabled. Use 'autoanswer enable' to enable.\n");
781 if (strstr(args,"enable")){
782 linphonec_set_autoanswer(TRUE);
783 linphonec_out("Auto answer enabled.\n");
784 }else if (strstr(args,"disable")){
785 linphonec_set_autoanswer(FALSE);
786 linphonec_out("Auto answer disabled.\n");
792 lpc_cmd_quit(LinphoneCore *lc, char *args)
794 linphonec_main_loop_exit();
799 lpc_cmd_nat(LinphoneCore *lc, char *args)
804 if ( args ) args=lpc_strip_blanks(args);
808 linphone_core_set_nat_address(lc, args);
809 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS); */
812 nat = linphone_core_get_nat_address(lc);
813 use = linphone_core_get_firewall_policy(lc)==LinphonePolicyUseNatAddress;
814 linphonec_out("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
820 lpc_cmd_stun(LinphoneCore *lc, char *args)
825 if ( args ) args=lpc_strip_blanks(args);
829 linphone_core_set_stun_server(lc, args);
830 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN); */
833 stun = linphone_core_get_stun_server(lc);
834 use = linphone_core_get_firewall_policy(lc)==LinphonePolicyUseStun;
835 linphonec_out("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
841 lpc_cmd_firewall(LinphoneCore *lc, char *args)
843 const char* setting=NULL;
845 if ( args ) args=lpc_strip_blanks(args);
849 if (strcmp(args,"none")==0)
851 linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall);
853 else if (strcmp(args,"stun")==0)
855 setting = linphone_core_get_stun_server(lc);
858 linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
861 linphone_core_set_firewall_policy(lc,LinphonePolicyUseStun);
863 else if (strcmp(args,"nat")==0)
865 setting = linphone_core_get_nat_address(lc);
868 linphonec_out("No nat address is defined, use 'nat <address>' first");
871 linphone_core_set_firewall_policy(lc,LinphonePolicyUseNatAddress);
875 switch(linphone_core_get_firewall_policy(lc))
877 case LinphonePolicyNoFirewall:
878 linphonec_out("No firewall\n");
880 case LinphonePolicyUseStun:
881 linphonec_out("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
883 case LinphonePolicyUseNatAddress:
884 linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
891 /* Helper function for processing freind names */
893 lpc_friend_name(char **args, char **name)
895 /* Use space as a terminator unless quoted */
896 if (('"' == **args) || ('\'' == **args)){
901 while ((delim != *end) && ('\0' != *end)) end++;
903 fprintf(stderr, "Mismatched quotes\n");
910 *name = strsep(args, " ");
912 if (NULL == *args) { /* Means there was no separator */
913 fprintf(stderr, "Either name or address is missing\n");
916 if (NULL == *name) return 0;
923 lpc_cmd_friend(LinphoneCore *lc, char *args)
927 if ( args ) args=lpc_strip_blanks(args);
929 if ( ! args || ! *args ) return 0;
931 if ( !strncmp(args, "list", 4) )
933 return linphonec_friend_list(lc, args+4);
936 else if ( !strncmp(args, "call", 4) )
939 if ( ! *args ) return 0;
940 friend_num = strtol(args, NULL, 10);
942 if ( errno == ERANGE ) {
943 linphonec_out("Invalid friend number\n");
946 #endif /*_WIN32_WCE*/
947 linphonec_friend_call(lc, friend_num);
950 else if ( !strncmp(args, "delete", 6) )
953 if ( ! *args ) return 0;
954 while (*args == ' ') args++;
955 if ( ! *args ) return 0;
956 if (!strncmp(args, "all", 3))
962 friend_num = strtol(args, NULL, 10);
964 if ( errno == ERANGE ) {
965 linphonec_out("Invalid friend number\n");
968 #endif /*_WIN32_WCE*/
970 linphonec_friend_delete(lc, friend_num);
973 else if ( !strncmp(args, "add", 3) )
982 if ( ! *args ) return 0;
983 while (*args == ' ') args++;
984 if ( ! *args ) return 0;
986 if (!lpc_friend_name(&args, &name)) return 0;
988 while (*args == ' ') args++;
989 if ( ! *args ) return 0;
990 if (isdigit(*args)) {
991 strcpy (addr, "sip:");
992 addr_p = addr + strlen("sip:");
994 addr_orig = strsep(&args, " ");
995 if (1 >= strlen(addr_orig)) {
996 fprintf(stderr, "A single-digit address is not valid\n");
999 strcpy(addr_p, addr_orig);
1000 linphonec_friend_add(lc, name, addr);
1002 LinphoneFriend *new_friend;
1003 new_friend = linphone_friend_new_with_addr(args);
1004 linphone_core_add_friend(lc, new_friend);
1011 static int lpc_cmd_play(LinphoneCore *lc, char *args){
1012 if ( args ) args=lpc_strip_blanks(args);
1013 if ( ! args || ! *args ) return 0;
1014 linphone_core_set_play_file(lc,args);
1018 static int lpc_cmd_record(LinphoneCore *lc, char *args){
1019 if ( args ) args=lpc_strip_blanks(args);
1020 if ( ! args || ! *args ) return 0;
1021 linphone_core_set_record_file(lc,args);
1029 lpc_cmd_proxy(LinphoneCore *lc, char *args)
1036 if ( ! arg1 ) return 0;
1038 /* Isolate first and second arg */
1039 while(*ptr && !isspace(*ptr)) ++ptr;
1044 while(*arg2 && isspace(*arg2)) ++arg2;
1047 if (strcmp(arg1,"add")==0)
1049 #ifdef HAVE_READLINE
1050 rl_inhibit_completion=1;
1052 linphonec_proxy_add(lc);
1053 #ifdef HAVE_READLINE
1054 rl_inhibit_completion=0;
1057 else if (strcmp(arg1,"list")==0)
1059 linphonec_proxy_list(lc);
1061 else if (strcmp(arg1,"remove")==0)
1063 linphonec_proxy_remove(lc,atoi(arg2));
1065 else if (strcmp(arg1,"use")==0)
1067 if ( arg2 && *arg2 )
1069 proxynum=atoi(arg2);
1070 if ( linphonec_proxy_use(lc, proxynum) )
1071 linphonec_out("Default proxy set to %d.\n", proxynum);
1075 proxynum=linphone_core_get_default_proxy(lc, NULL);
1076 if ( proxynum == -1 ) linphonec_out("No default proxy.\n");
1077 else linphonec_out("Current default proxy is %d.\n", proxynum);
1079 }else if (strcmp(arg1, "unuse")==0){
1080 linphone_core_set_default_proxy(lc, NULL);
1081 linphonec_out("Use no proxy.\n");
1084 else if (strcmp(arg1, "show")==0)
1088 if (strstr(arg2,"default"))
1090 proxynum=linphone_core_get_default_proxy(lc, NULL);
1091 if ( proxynum < 0 ) {
1092 linphonec_out("No default proxy defined\n");
1095 linphonec_proxy_show(lc,proxynum);
1099 linphonec_proxy_show(lc, atoi(arg2));
1102 else return 0; /* syntax error */
1107 return 0; /* syntax error */
1114 lpc_cmd_call_logs(LinphoneCore *lc, char *args)
1116 const MSList *elem=linphone_core_get_call_logs(lc);
1117 for (;elem!=NULL;elem=ms_list_next(elem))
1119 LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
1120 char *str=linphone_call_log_to_str(cl);
1121 linphonec_out("%s\n",str);
1128 lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
1132 return 0; /* syntax error */
1135 if (strcmp(arg1,"status")==0)
1137 linphonec_out("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
1139 else if (strcmp(arg1,"enable")==0)
1141 linphone_core_enable_ipv6(lc,TRUE);
1142 linphonec_out("ipv6 use enabled.\n");
1144 else if (strcmp(arg1,"disable")==0)
1146 linphone_core_enable_ipv6(lc,FALSE);
1147 linphonec_out("ipv6 use disabled.\n");
1151 return 0; /* syntax error */
1156 static int devname_to_index(LinphoneCore *lc, const char *devname){
1159 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
1160 if (strcmp(devname,*p)==0) return i;
1165 static const char *index_to_devname(LinphoneCore *lc, int index){
1168 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
1169 if (i==index) return *p;
1174 static int lpc_cmd_soundcard(LinphoneCore *lc, char *args)
1182 if (!args) return 0; /* syntax error */
1184 /* Isolate first and second arg */
1185 while(*ptr && !isspace(*ptr)) ++ptr;
1190 while(*arg2 && isspace(*arg2)) ++arg2;
1193 if (strcmp(arg1, "list")==0)
1195 dev=linphone_core_get_sound_devices(lc);
1196 for(i=0; dev[i]!=NULL; ++i){
1197 linphonec_out("%i: %s\n",i,dev[i]);
1202 if (strcmp(arg1, "show")==0)
1204 linphonec_out("Ringer device: %s\n",
1205 linphone_core_get_ringer_device(lc));
1206 linphonec_out("Playback device: %s\n",
1207 linphone_core_get_playback_device(lc));
1208 linphonec_out("Capture device: %s\n",
1209 linphone_core_get_capture_device(lc));
1213 if (strcmp(arg1, "use")==0 && arg2)
1215 if (strcmp(arg2, "files")==0)
1217 linphonec_out("Using wav files instead of soundcard.\n");
1218 linphone_core_use_files(lc,TRUE);
1222 dev=linphone_core_get_sound_devices(lc);
1223 index=atoi(arg2); /* FIXME: handle not-a-number */
1224 for(i=0;dev[i]!=NULL;i++)
1226 if (i!=index) continue;
1228 linphone_core_set_ringer_device(lc,dev[i]);
1229 linphone_core_set_playback_device(lc,dev[i]);
1230 linphone_core_set_capture_device(lc,dev[i]);
1231 linphonec_out("Using sound device %s\n",dev[i]);
1234 linphonec_out("No such sound device\n");
1237 if (strcmp(arg1, "capture")==0)
1239 const char *devname=linphone_core_get_capture_device(lc);
1241 linphonec_out("Using capture device #%i (%s)\n",
1242 devname_to_index(lc,devname),devname);
1244 index=atoi(arg2); /* FIXME: handle not-a-number */
1245 devname=index_to_devname(lc,index);
1247 linphone_core_set_capture_device(lc,devname);
1248 linphonec_out("Using capture sound device %s\n",devname);
1251 linphonec_out("No such sound device\n");
1255 if (strcmp(arg1, "playback")==0)
1257 const char *devname=linphone_core_get_playback_device(lc);
1259 linphonec_out("Using playback device #%i (%s)\n",
1260 devname_to_index(lc,devname),devname);
1262 index=atoi(arg2); /* FIXME: handle not-a-number */
1263 devname=index_to_devname(lc,index);
1265 linphone_core_set_playback_device(lc,devname);
1266 linphonec_out("Using playback sound device %s\n",devname);
1269 linphonec_out("No such sound device\n");
1273 if (strcmp(arg1, "ring")==0)
1275 const char *devname=linphone_core_get_ringer_device(lc);
1277 linphonec_out("Using ring device #%i (%s)\n",
1278 devname_to_index(lc,devname),devname);
1280 index=atoi(arg2); /* FIXME: handle not-a-number */
1281 devname=index_to_devname(lc,index);
1283 linphone_core_set_ringer_device(lc,devname);
1284 linphonec_out("Using ring sound device %s\n",devname);
1287 linphonec_out("No such sound device\n");
1291 return 0; /* syntax error */
1294 static int lpc_cmd_webcam(LinphoneCore *lc, char *args)
1302 if (!args) return 0; /* syntax error */
1304 /* Isolate first and second arg */
1305 while(*ptr && !isspace(*ptr)) ++ptr;
1310 while(*arg2 && isspace(*arg2)) ++arg2;
1313 if (strcmp(arg1, "list")==0)
1315 dev=linphone_core_get_video_devices(lc);
1316 for(i=0; dev[i]!=NULL; ++i){
1317 linphonec_out("%i: %s\n",i,dev[i]);
1322 if (strcmp(arg1, "use")==0 && arg2)
1324 dev=linphone_core_get_video_devices(lc);
1325 index=atoi(arg2); /* FIXME: handle not-a-number */
1326 for(i=0;dev[i]!=NULL;i++)
1328 if (i!=index) continue;
1330 linphone_core_set_video_device(lc, dev[i]);
1331 linphonec_out("Using video device %s\n",dev[i]);
1334 linphonec_out("No such video device\n");
1337 return 0; /* syntax error */
1341 lpc_cmd_staticpic(LinphoneCore *lc, char *args)
1347 if (!args) return 0; /* Syntax error */
1349 /* Isolate first and second arg */
1350 while(*ptr && !isspace(*ptr)) ++ptr;
1355 while(*arg2 && isspace(*arg2)) ++arg2;
1358 if (strcmp(arg1, "set")==0 && arg2) {
1359 linphone_core_set_static_picture(lc, arg2);
1363 if (strcmp(arg1, "fps")==0) {
1365 float fps = atof(arg2); /* FIXME: Handle not-a-float */
1366 linphone_core_set_static_picture_fps(lc, fps);
1370 fps = linphone_core_get_static_picture_fps(lc);
1371 linphonec_out("Current FPS %f\n", fps);
1376 return 0; /* Syntax error */
1379 static int lpc_cmd_pause(LinphoneCore *lc, char *args){
1381 if(linphone_core_in_call(lc))
1383 linphone_core_pause_call(lc,linphone_core_get_current_call(lc));
1386 linphonec_out("you can only pause when a call is in process\n");
1390 static int lpc_cmd_resume(LinphoneCore *lc, char *args){
1392 if(linphone_core_in_call(lc))
1394 linphonec_out("There is already a call in process pause or stop it first");
1400 int n = sscanf(args, "%li", &id);
1402 LinphoneCall *call=linphonec_get_call (id);
1404 if(linphone_core_resume_call(lc,call)==-1){
1405 linphonec_out("There was a problem to resume the call check the remote address you gave %s\n",args);
1413 const MSList *calls = linphone_core_get_calls(lc);
1414 int nbcalls=ms_list_size(calls);
1417 if(linphone_core_resume_call(lc,calls->data) < 0)
1419 linphonec_out("There was a problem to resume the unique call.\n");
1422 }else if (nbcalls==0){
1423 linphonec_out("There is no calls at this time.\n");
1426 linphonec_out("There are %i calls at this time, please specify call id as given with 'calls' command.\n");
1433 static int lpc_cmd_conference(LinphoneCore *lc, char *args){
1435 char subcommand[32]={0};
1437 if (args==NULL) return 0;
1438 n=sscanf(args, "%31s %li", subcommand,&id);
1440 LinphoneCall *call=linphonec_get_call(id);
1441 if (call==NULL) return 1;
1442 if (strcmp(subcommand,"add")==0){
1443 linphone_core_add_to_conference(lc,call);
1445 }else if (strcmp(subcommand,"rm")==0){
1446 linphone_core_remove_from_conference(lc,call);
1448 }else if (strcmp(subcommand,"enter")==0){
1449 linphone_core_enter_conference(lc);
1451 }else if (strcmp(subcommand,"leave")==0){
1452 linphone_core_leave_conference(lc);
1459 /***************************************************************************
1461 * Commands helper functions
1463 ***************************************************************************/
1467 linphonec_proxy_add(LinphoneCore *lc)
1469 bool_t enable_register=FALSE;
1470 LinphoneProxyConfig *cfg;
1472 linphonec_out("Adding new proxy setup. Hit ^D to abort.\n");
1479 char *input=linphonec_readline("Enter proxy sip address: ");
1483 linphonec_out("Aborted.\n");
1488 clean=lpc_strip_blanks(input);
1494 cfg=linphone_proxy_config_new();
1495 if (linphone_proxy_config_set_server_addr(cfg,clean)<0)
1497 linphonec_out("Invalid sip address (sip:sip.domain.tld).\n");
1499 linphone_proxy_config_destroy(cfg);
1507 * SIP Proxy identity
1511 char *input=linphonec_readline("Your identity for this proxy: ");
1515 linphonec_out("Aborted.\n");
1516 linphone_proxy_config_destroy(cfg);
1521 clean=lpc_strip_blanks(input);
1527 linphone_proxy_config_set_identity(cfg, clean);
1528 if ( ! linphone_proxy_config_get_identity (cfg))
1530 linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
1539 * SIP Proxy enable register
1543 char *input=linphonec_readline("Do you want to register on this proxy (yes/no): ");
1547 linphonec_out("Aborted.\n");
1548 linphone_proxy_config_destroy(cfg);
1553 clean=lpc_strip_blanks(input);
1559 if ( ! strcmp(clean, "yes") ) enable_register=TRUE;
1560 else if ( ! strcmp(clean, "no") ) enable_register=FALSE;
1562 linphonec_out("Please answer with 'yes' or 'no'\n");
1566 linphone_proxy_config_enableregister(cfg, enable_register);
1572 * SIP Proxy registration expiration
1574 if ( enable_register==TRUE )
1579 char *input=linphonec_readline("Specify register expiration time"
1580 " in seconds (default is 600): ");
1583 linphonec_out("Aborted.\n");
1584 linphone_proxy_config_destroy(cfg);
1588 expires=strtol(input, (char **)NULL, 10);
1589 if ( expires == LONG_MIN || expires == LONG_MAX )
1591 linphonec_out("Invalid value: %s\n", strerror(errno));
1596 linphone_proxy_config_expires(cfg, expires);
1597 linphonec_out("Expiration: %d seconds\n", linphone_proxy_config_get_expires (cfg));
1609 char *input=linphonec_readline("Specify route if needed: ");
1613 linphonec_out("Aborted.\n");
1614 linphone_proxy_config_destroy(cfg);
1619 clean=lpc_strip_blanks(input);
1622 linphonec_out("No route specified.\n");
1626 linphone_proxy_config_set_route(cfg, clean);
1627 if ( ! linphone_proxy_config_get_route(cfg) )
1629 linphonec_out("Invalid route.\n");
1639 * Final confirmation
1646 linphonec_out("--------------------------------------------\n");
1647 linphonec_proxy_display(cfg);
1648 linphonec_out("--------------------------------------------\n");
1649 input=linphonec_readline("Accept the above proxy configuration (yes/no) ?: ");
1653 linphonec_out("Aborted.\n");
1654 linphone_proxy_config_destroy(cfg);
1659 clean=lpc_strip_blanks(input);
1665 if ( ! strcmp(clean, "yes") ) break;
1666 else if ( ! strcmp(clean, "no") )
1668 linphonec_out("Declined.\n");
1669 linphone_proxy_config_destroy(cfg);
1674 linphonec_out("Please answer with 'yes' or 'no'\n");
1680 linphone_core_add_proxy_config(lc,cfg);
1682 /* automatically set the last entered proxy as the default one */
1683 linphone_core_set_default_proxy(lc,cfg);
1685 linphonec_out("Proxy added.\n");
1689 linphonec_proxy_display(LinphoneProxyConfig *cfg)
1691 const char *route=linphone_proxy_config_get_route(cfg);
1692 const char *identity=linphone_proxy_config_get_identity(cfg);
1693 linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n",
1694 linphone_proxy_config_get_addr(cfg),
1695 (route!=NULL)? route:"",
1696 (identity!=NULL)?identity:"",
1697 linphone_proxy_config_register_enabled (cfg)?"yes":"no",
1698 linphone_proxy_config_get_expires (cfg),
1699 linphone_proxy_config_is_registered(cfg) ? "yes" : "no");
1702 static void linphonec_proxy_show(LinphoneCore *lc, int index)
1706 for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){
1708 LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)elem->data;
1709 linphonec_proxy_display(cfg);
1713 linphonec_out("No proxy with index %i\n", index);
1717 linphonec_proxy_list(LinphoneCore *lc)
1719 const MSList *proxies;
1721 int def=linphone_core_get_default_proxy(lc,NULL);
1723 proxies=linphone_core_get_proxy_config_list(lc);
1724 for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){
1726 linphonec_out("****** Proxy %i - this is the default one - *******\n",n);
1728 linphonec_out("****** Proxy %i *******\n",n);
1729 linphonec_proxy_display((LinphoneProxyConfig*)proxies->data);
1731 if ( ! n ) linphonec_out("No proxies defined\n");
1735 linphonec_proxy_remove(LinphoneCore *lc, int index)
1737 const MSList *proxies;
1738 LinphoneProxyConfig *cfg;
1739 proxies=linphone_core_get_proxy_config_list(lc);
1740 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1742 linphonec_out("No such proxy.\n");
1745 linphone_core_remove_proxy_config(lc,cfg);
1746 linphonec_out("Proxy %s removed.\n", linphone_proxy_config_get_addr(cfg));
1750 linphonec_proxy_use(LinphoneCore *lc, int index)
1752 const MSList *proxies;
1753 LinphoneProxyConfig *cfg;
1754 proxies=linphone_core_get_proxy_config_list(lc);
1755 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1757 linphonec_out("No such proxy (try 'proxy list').");
1760 linphone_core_set_default_proxy(lc,cfg);
1765 linphonec_friend_display(LinphoneFriend *fr)
1767 LinphoneAddress *uri=linphone_address_clone(linphone_friend_get_address(fr));
1770 linphonec_out("name: %s\n", linphone_address_get_display_name(uri));
1771 linphone_address_set_display_name(uri,NULL);
1772 str=linphone_address_as_string(uri);
1773 linphonec_out("address: %s\n", str);
1777 linphonec_friend_list(LinphoneCore *lc, char *pat)
1779 const MSList *friend;
1783 pat=lpc_strip_blanks(pat);
1784 if (!*pat) pat = NULL;
1787 friend = linphone_core_get_friend_list(lc);
1788 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1791 const char *name = linphone_address_get_display_name(
1792 linphone_friend_get_address((LinphoneFriend*)friend->data));
1793 if (name && ! strstr(name, pat) ) continue;
1795 linphonec_out("****** Friend %i *******\n",n);
1796 linphonec_friend_display((LinphoneFriend*)friend->data);
1803 linphonec_friend_call(LinphoneCore *lc, unsigned int num)
1805 const MSList *friend = linphone_core_get_friend_list(lc);
1809 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1814 addr = linphone_address_as_string(linphone_friend_get_address((LinphoneFriend*)friend->data));
1815 ret=lpc_cmd_call(lc, addr);
1820 linphonec_out("No such friend %u\n", num);
1826 linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr)
1828 LinphoneFriend *newFriend;
1832 snprintf(url, PATH_MAX, "%s <%s>", name, addr);
1833 newFriend = linphone_friend_new_with_addr(url);
1834 linphone_core_add_friend(lc, newFriend);
1840 linphonec_friend_delete(LinphoneCore *lc, int num)
1842 const MSList *friend = linphone_core_get_friend_list(lc);
1845 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1849 linphone_core_remove_friend(lc, friend->data);
1857 for (i = 0 ; i < n ; i++)
1858 linphonec_friend_delete(lc, 0);
1862 linphonec_out("No such friend %u\n", num);
1867 linphonec_display_command_help(LPC_COMMAND *cmd)
1869 if ( cmd->doc ) linphonec_out ("%s\n", cmd->doc);
1870 else linphonec_out("%s\n", cmd->help);
1874 static int lpc_cmd_register(LinphoneCore *lc, char *args){
1878 LinphoneProxyConfig *cfg;
1883 /* it means that you want to register the default proxy */
1884 LinphoneProxyConfig *cfg=NULL;
1885 linphone_core_get_default_proxy(lc,&cfg);
1888 if(!linphone_proxy_config_is_registered(cfg)) {
1889 linphone_proxy_config_enable_register(cfg,TRUE);
1890 linphone_proxy_config_done(cfg);
1892 linphonec_out("default proxy already registered\n");
1895 linphonec_out("we do not have a default proxy\n");
1900 passwd[0]=proxy[0]=identity[0]='\0';
1901 sscanf(args,"%511s %511s %511s",identity,proxy,passwd);
1902 if (proxy[0]=='\0' || identity[0]=='\0'){
1903 linphonec_out("Missing parameters, see help register\n");
1906 if (passwd[0]!='\0'){
1907 LinphoneAddress *from;
1908 LinphoneAuthInfo *info;
1909 if ((from=linphone_address_new(identity))!=NULL){
1911 snprintf(realm,sizeof(realm)-1,"\"%s\"",linphone_address_get_domain(from));
1912 info=linphone_auth_info_new(linphone_address_get_username(from),NULL,passwd,NULL,NULL);
1913 linphone_core_add_auth_info(lc,info);
1914 linphone_address_destroy(from);
1915 linphone_auth_info_destroy(info);
1918 elem=linphone_core_get_proxy_config_list(lc);
1920 cfg=(LinphoneProxyConfig*)elem->data;
1921 linphone_proxy_config_edit(cfg);
1923 else cfg=linphone_proxy_config_new();
1924 linphone_proxy_config_set_identity(cfg,identity);
1925 linphone_proxy_config_set_server_addr(cfg,proxy);
1926 linphone_proxy_config_enable_register(cfg,TRUE);
1927 if (elem) linphone_proxy_config_done(cfg);
1928 else linphone_core_add_proxy_config(lc,cfg);
1929 linphone_core_set_default_proxy(lc,cfg);
1933 static int lpc_cmd_unregister(LinphoneCore *lc, char *args){
1934 LinphoneProxyConfig *cfg=NULL;
1935 linphone_core_get_default_proxy(lc,&cfg);
1936 if (cfg && linphone_proxy_config_is_registered(cfg)) {
1937 linphone_proxy_config_edit(cfg);
1938 linphone_proxy_config_enable_register(cfg,FALSE);
1939 linphone_proxy_config_done(cfg);
1941 linphonec_out("unregistered\n");
1946 static int lpc_cmd_duration(LinphoneCore *lc, char *args){
1947 LinphoneCallLog *cl;
1948 const MSList *elem=linphone_core_get_call_logs(lc);
1949 for(;elem!=NULL;elem=elem->next){
1950 if (elem->next==NULL){
1951 cl=(LinphoneCallLog*)elem->data;
1952 linphonec_out("%i seconds\n",cl->duration);
1958 static int lpc_cmd_status(LinphoneCore *lc, char *args)
1960 LinphoneProxyConfig *cfg;
1962 if ( ! args ) return 0;
1963 linphone_core_get_default_proxy(lc,&cfg);
1964 if (strstr(args,"register"))
1968 if (linphone_proxy_config_is_registered(cfg)){
1969 linphonec_out("registered, identity=%s duration=%i\n",
1970 linphone_proxy_config_get_identity(cfg),
1971 linphone_proxy_config_get_expires(cfg));
1972 }else if (linphone_proxy_config_register_enabled(cfg)){
1973 linphonec_out("registered=-1\n");
1974 }else linphonec_out("registered=0\n");
1976 else linphonec_out("registered=0\n");
1978 else if (strstr(args,"autoanswer"))
1980 if (cfg && linphone_proxy_config_is_registered(cfg))
1981 linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer());
1982 else linphonec_out("unregistered\n");
1984 else if (strstr(args,"hook"))
1986 LinphoneCall *call=linphone_core_get_current_call (lc);
1987 LinphoneCallState call_state=LinphoneCallIdle;
1988 if (call) call_state=linphone_call_get_state(call);
1991 case LinphoneCallOutgoingInit:
1992 linphonec_out("hook=outgoing_init sip:%s\n",linphonec_get_callee());
1994 case LinphoneCallOutgoingProgress:
1995 linphonec_out("hook=dialing sip:%s\n",linphonec_get_callee());
1997 case LinphoneCallOutgoingRinging:
1998 linphonec_out("hook=ringing sip:%s\n",linphonec_get_callee());
2000 case LinphoneCallPaused:
2001 linphonec_out("hook=paused sip:%s\n",linphonec_get_callee());
2003 case LinphoneCallIdle:
2004 linphonec_out("hook=offhook\n");
2006 case LinphoneCallStreamsRunning:
2007 case LinphoneCallConnected:
2008 if (linphone_call_get_dir(call)==LinphoneCallOutgoing){
2009 linphonec_out("Call out, hook=%s duration=%i, muted=%s rtp-xmit-muted=%s\n", linphonec_get_callee(),
2010 linphone_core_get_current_call_duration(lc),
2011 linphone_core_is_mic_muted (lc) ? "yes" : "no",
2012 linphone_core_is_rtp_muted(lc) ? "yes" : "no");
2014 linphonec_out("hook=answered duration=%i %s\n" ,
2015 linphone_core_get_current_call_duration(lc), linphonec_get_caller());
2018 case LinphoneCallIncomingReceived:
2019 linphonec_out("Incoming call from %s\n",linphonec_get_caller());
2031 static int lpc_cmd_ports(LinphoneCore *lc, char *args)
2035 linphonec_out("sip port = %i\naudio rtp port = %i\nvideo rtp port = %i\n",
2036 linphone_core_get_sip_port(lc),
2037 linphone_core_get_audio_port(lc),
2038 linphone_core_get_video_port(lc));
2041 if (sscanf(args,"sip %i",&port)==1){
2042 linphonec_out("Setting sip port to %i\n",port);
2043 linphone_core_set_sip_port(lc,port);
2049 static int lpc_cmd_param(LinphoneCore *lc, char *args)
2051 char section[20], param[20], value[50];
2057 switch (sscanf(args,"%19s %19s %49s",section,param,value)) {
2058 // case 1 might show all current settings under a section
2060 string = lp_config_get_string(linphone_core_get_config(lc), section, param, "(undef)");
2061 linphonec_out("current value: %s\n", string);
2064 if (lp_config_get_string(linphone_core_get_config(lc), section, param, NULL) != NULL) {
2065 lp_config_set_string(linphone_core_get_config(lc), section, param, value);
2066 // no indication of existence
2067 linphonec_out("updated value: %s\n", value);
2069 linphonec_out("only update of existing variables are allowed\n");
2078 static int lpc_cmd_speak(LinphoneCore *lc, char *args){
2087 if (!args) return 0;
2088 memset(voice,0,sizeof(voice));
2089 sscanf(args,"%63s",voice);
2090 sentence=args+strlen(voice);
2091 wavfile=tempnam("/tmp/","linphonec-espeak-");
2092 snprintf(cl,sizeof(cl),"espeak -v %s -s 100 -w %s --stdin",voice,wavfile);
2095 ms_error("Could not open pipe to espeak !");
2098 fprintf(file,"%s",sentence);
2099 status=pclose(file);
2100 if (WEXITSTATUS(status)==0){
2101 linphone_core_set_play_file(lc,wavfile);
2103 linphonec_out("espeak command failed.");
2106 linphonec_out("Sorry, this command is not implemented in windows version.");
2111 static int lpc_cmd_acodec(LinphoneCore *lc, char *args){
2112 return lpc_cmd_codec(AUDIO, lc, args);
2115 static int lpc_cmd_vcodec(LinphoneCore *lc, char *args){
2116 return lpc_cmd_codec(VIDEO, lc, args);
2119 static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args){
2124 if (!args) return 0;
2126 /* Isolate first and second arg */
2127 while(*ptr && !isspace(*ptr)) ++ptr;
2132 while(*arg2 && isspace(*arg2)) ++arg2;
2135 if (strcmp(arg1,"enable")==0)
2137 #ifdef HAVE_READLINE
2138 rl_inhibit_completion=1;
2140 if (!strcmp(arg2,"all")) linphonec_codec_enable(type,lc,-1);
2141 else linphonec_codec_enable(type,lc,atoi(arg2));
2142 #ifdef HAVE_READLINE
2143 rl_inhibit_completion=0;
2146 else if (strcmp(arg1,"list")==0)
2148 linphonec_codec_list(type,lc);
2150 else if (strcmp(arg1,"disable")==0)
2152 if (!strcmp(arg2,"all")) linphonec_codec_disable(type,lc,-1);
2153 else linphonec_codec_disable(type,lc,atoi(arg2));
2157 return 0; /* syntax error */
2163 static void linphonec_codec_list(int type, LinphoneCore *lc){
2166 const MSList *node=NULL;
2168 if (type == AUDIO) {
2169 node=linphone_core_get_audio_codecs(lc);
2170 } else if(type==VIDEO) {
2171 node=linphone_core_get_video_codecs(lc);
2174 for(;node!=NULL;node=ms_list_next(node)){
2175 pt=(PayloadType*)(node->data);
2176 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate,
2177 linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled");
2182 static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){
2185 const MSList *node=NULL;
2187 if (type == AUDIO) {
2188 node=linphone_core_get_audio_codecs(lc);
2189 } else if(type==VIDEO) {
2190 node=linphone_core_get_video_codecs(lc);
2193 for(;node!=NULL;node=ms_list_next(node)){
2194 if (index == sel_index || sel_index == -1) {
2195 pt=(PayloadType*)(node->data);
2196 linphone_core_enable_payload_type (lc,pt,TRUE);
2197 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled");
2203 static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){
2206 const MSList *node=NULL;
2208 if (type == AUDIO) {
2209 node=linphone_core_get_audio_codecs(lc);
2210 } else if(type==VIDEO) {
2211 node=linphone_core_get_video_codecs(lc);
2214 for(;node!=NULL;node=ms_list_next(node)){
2215 if (index == sel_index || sel_index == -1) {
2216 pt=(PayloadType*)(node->data);
2217 linphone_core_enable_payload_type (lc,pt,FALSE);
2218 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
2224 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
2228 LpConfig *config=linphone_core_get_config(lc);
2230 if (!args) return 0;
2232 /* Isolate first and second arg */
2233 while(*ptr && !isspace(*ptr)) ++ptr;
2238 while(*arg2 && isspace(*arg2)) ++arg2;
2241 if (strcmp(arg1,"on")==0){
2242 int delay, tail_len, frame_size;
2245 linphone_core_enable_echo_cancellation(lc,1);
2248 n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size);
2251 lp_config_set_int(config,"sound","ec_delay",delay);
2254 lp_config_set_int(config,"sound","ec_delay",delay);
2255 lp_config_set_int(config,"sound","ec_tail_len",tail_len);
2258 lp_config_set_int(config,"sound","ec_delay",delay);
2259 lp_config_set_int(config,"sound","ec_tail_len",tail_len);
2260 lp_config_set_int(config,"sound","ec_framesize",frame_size);
2264 else if (strcmp(arg1,"off")==0){
2265 linphone_core_enable_echo_cancellation(lc,0);
2267 else if (strcmp(arg1,"show")==0){
2268 linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",
2269 linphone_core_echo_cancellation_enabled(lc) ? "on" : "off",
2270 lp_config_get_int(config,"sound","ec_delay",0),
2271 lp_config_get_int(config,"sound","ec_tail_len",0),
2272 lp_config_get_int(config,"sound","ec_framesize",0));
2281 static int lpc_cmd_echolimiter(LinphoneCore *lc, char *args){
2283 if (strcmp(args,"on")==0){
2284 linphone_core_enable_echo_limiter (lc,TRUE);
2285 }else if (strcmp(args,"off")==0){
2286 linphone_core_enable_echo_limiter (lc,FALSE);
2289 linphonec_out("Echo limiter is now %s.\n",linphone_core_echo_limiter_enabled (lc) ? "on":"off");
2293 static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args)
2295 linphone_core_mute_mic(lc, 1);
2299 static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args){
2300 linphone_core_mute_mic(lc, 0);
2304 static int lpc_cmd_playback_gain(LinphoneCore *lc, char *args)
2307 linphone_core_set_playback_gain_db(lc, atof(args));
2313 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args)
2315 bool_t rtp_xmit_off=FALSE;
2319 if(strstr(args,"1"))rtp_xmit_off=TRUE;
2320 if(linphone_core_get_current_call (lc)==NULL)
2321 linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_xmit_off);
2323 linphonec_out("nortp-on-audio-mute: call in progress - cannot change state\n");
2325 rtp_xmit_off=linphone_core_get_rtp_no_xmit_on_audio_mute(lc);
2326 if (rtp_xmit_off) status="off";
2328 linphonec_out("rtp transmit %s when audio muted\n",status);
2332 #ifdef VIDEO_ENABLED
2333 static int _lpc_cmd_video_window(LinphoneCore *lc, char *args, bool_t is_preview){
2334 char subcommand[64];
2337 VideoParams *params=is_preview ? &lpc_preview_params : &lpc_video_params;
2339 if (!args) return 0;
2340 err=sscanf(args,"%63s %i %i",subcommand,&a,&b);
2342 if (strcmp(subcommand,"pos")==0){
2343 if (err<3) return 0;
2346 params->refresh=TRUE;
2347 }else if (strcmp(subcommand,"size")==0){
2348 if (err<3) return 0;
2351 params->refresh=TRUE;
2352 }else if (strcmp(subcommand,"show")==0){
2354 params->refresh=TRUE;
2355 if (is_preview) linphone_core_enable_video_preview (lc,TRUE);
2356 }else if (strcmp(subcommand,"hide")==0){
2358 params->refresh=TRUE;
2359 if (is_preview) linphone_core_enable_video_preview (lc,FALSE);
2360 }else if (strcmp(subcommand,"id")==0){
2362 linphonec_out("vwindow id: 0x%x\n",is_preview ? linphone_core_get_native_preview_window_id (lc) :
2363 linphone_core_get_native_video_window_id (lc));
2365 } else if (err != 2) return 0;
2368 linphone_core_set_native_preview_window_id (lc,a);
2370 linphone_core_set_native_video_window_id(lc,a);
2371 }else if (is_preview==TRUE){
2372 if (strcmp(subcommand,"integrated")==0){
2373 linphone_core_use_preview_window (lc,FALSE);
2374 }else if (strcmp(subcommand,"standalone")==0){
2375 linphone_core_use_preview_window(lc,TRUE);
2382 static int lpc_cmd_video_window(LinphoneCore *lc, char *args){
2383 return _lpc_cmd_video_window(lc, args, FALSE);
2386 static int lpc_cmd_preview_window(LinphoneCore *lc, char *args){
2387 return _lpc_cmd_video_window(lc, args, TRUE);
2391 static void lpc_display_global_state(LinphoneCore *lc){
2392 linphonec_out("Global liblinphone state\n%s\n",
2393 linphone_global_state_to_string(linphone_core_get_global_state(lc)));
2396 static void lpc_display_call_states(LinphoneCore *lc){
2400 linphonec_out("Call states\n"
2401 "Id | Destination | State | Flags |\n"
2402 "------------------------------------------------------------------------\n");
2403 elem=linphone_core_get_calls(lc);
2405 linphonec_out("(empty)\n");
2407 for(;elem!=NULL;elem=elem->next){
2409 call=(LinphoneCall*)elem->data;
2410 bool_t in_conference=linphone_call_params_local_conference_mode(linphone_call_get_current_params(call));
2411 tmp=linphone_call_get_remote_address_as_string (call);
2412 flag=in_conference ? "conferencing" : "";
2413 flag=linphone_call_has_transfer_pending(call) ? "transfer pending" : flag;
2414 linphonec_out("%-2i | %-35s | %-15s | %s\n",(int)(long)linphone_call_get_user_pointer(call),
2415 tmp,linphone_call_state_to_string(linphone_call_get_state(call))+strlen("LinphoneCall"),flag);
2421 static void lpc_display_proxy_states(LinphoneCore *lc){
2423 linphonec_out("Proxy registration states\n"
2424 " Identity | State\n"
2425 "------------------------------------------------------------\n");
2426 elem=linphone_core_get_proxy_config_list (lc);
2427 if (elem==NULL) linphonec_out("(empty)\n");
2429 for(;elem!=NULL;elem=elem->next){
2430 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
2431 linphonec_out("%-40s | %s\n",linphone_proxy_config_get_identity (cfg),
2432 linphone_registration_state_to_string(linphone_proxy_config_get_state(cfg)));
2437 static int lpc_cmd_states(LinphoneCore *lc, char *args){
2439 lpc_display_global_state(lc);
2440 lpc_display_call_states(lc);
2441 lpc_display_proxy_states(lc);
2444 if (strcmp(args,"global")==0){
2445 lpc_display_global_state(lc);
2448 if (strcmp(args,"proxies")==0){
2449 lpc_display_proxy_states(lc);
2452 if (strcmp(args,"calls")==0){
2453 lpc_display_call_states(lc);
2459 #ifdef VIDEO_ENABLED
2460 static int lpc_cmd_camera(LinphoneCore *lc, char *args){
2461 LinphoneCall *call=linphone_core_get_current_call(lc);
2462 bool_t activated=FALSE;
2464 if (linphone_core_video_enabled (lc)==FALSE){
2465 linphonec_out("Video is disabled, re-run linphonec with -V option.");
2470 if (strcmp(args,"on")==0)
2472 else if (strcmp(args,"off")==0)
2480 linphonec_camera_enabled=activated;
2482 if (linphonec_camera_enabled){
2483 linphonec_out("Camera is enabled. Video stream will be setup immediately for outgoing and incoming calls.\n");
2485 linphonec_out("Camera is disabled. Calls will be established with audio-only, with the possibility to later add video using 'camera on'.\n");
2488 const LinphoneCallParams *cp=linphone_call_get_current_params (call);
2490 linphone_call_enable_camera(call,activated);
2491 if ((activated && !linphone_call_params_video_enabled (cp))){
2492 /*update the call to add the video stream*/
2493 LinphoneCallParams *ncp=linphone_call_params_copy(cp);
2494 linphone_call_params_enable_video(ncp,TRUE);
2495 linphone_core_update_call(lc,call,ncp);
2496 linphone_call_params_destroy (ncp);
2497 linphonec_out("Trying to bring up video stream...\n");
2500 if (linphone_call_camera_enabled (call))
2501 linphonec_out("Camera is allowed for current call.\n");
2502 else linphonec_out("Camera is dis-allowed for current call.\n");
2507 static int lpc_cmd_snapshot(LinphoneCore *lc, char *args){
2509 if (!args) return 0;
2510 call=linphone_core_get_current_call(lc);
2512 linphone_call_take_video_snapshot(call,args);
2513 linphonec_out("Taking video snapshot in file %s\n", args);
2514 }else linphonec_out("There is no active call.\n");
2518 static int lpc_cmd_vfureq(LinphoneCore *lc, char *arg){
2520 call=linphone_core_get_current_call(lc);
2522 linphone_call_send_vfu_request(call);
2523 linphonec_out("VFU request sent\n");
2524 }else linphonec_out("There is no active call.\n");
2529 static int lpc_cmd_identify(LinphoneCore *lc, char *args){
2531 const char *remote_ua;
2533 call=linphone_core_get_current_call(lc);
2535 linphonec_out("There is currently running call. Specify call id.\n");
2539 call=linphonec_get_call(atoi(args));
2544 remote_ua=linphone_call_get_remote_user_agent(call);
2546 linphonec_out("Remote user agent string is: %s\n",remote_ua);
2551 static int lpc_cmd_ringback(LinphoneCore *lc, char *args){
2552 if (!args) return 0;
2553 if (strcmp(args,"disable")==0){
2554 linphone_core_set_remote_ringback_tone(lc,NULL);
2555 linphonec_out("Disabling ringback tone.\n");
2558 linphone_core_set_remote_ringback_tone (lc,args);
2559 linphonec_out("Using %s as ringback tone to be played to callers.",args);
2563 static int zrtp_set_verified(LinphoneCore *lc, char *args, bool_t verified){
2564 LinphoneCall *call=linphone_core_get_current_call(lc);
2565 if (linphone_call_params_get_media_encryption(linphone_call_get_current_params(call))==LinphoneMediaEncryptionZRTP){
2566 linphone_call_set_authentication_token_verified(call,verified);
2570 static int lpc_cmd_zrtp_verified(LinphoneCore *lc, char *args){
2571 return zrtp_set_verified(lc,args,TRUE);
2573 static int lpc_cmd_zrtp_unverified(LinphoneCore *lc, char *args){
2574 return zrtp_set_verified(lc,args,FALSE);
2577 /***************************************************************************
2579 * Command table management funx
2581 ***************************************************************************/
2584 * Find a command given its name
2586 static LPC_COMMAND *
2587 lpc_find_command(const char *name)
2591 for (i=0; commands[i].name; ++i)
2593 if (strcmp(name, commands[i].name) == 0)
2594 return &commands[i];
2597 for (i=0; advanced_commands[i].name; ++i)
2599 if (strcmp(name, advanced_commands[i].name) == 0)
2600 return &advanced_commands[i];
2603 return (LPC_COMMAND *)NULL;
2607 /****************************************************************************
2609 * $Log: commands.c,v $
2610 * Revision 1.39 2008/07/03 15:08:34 smorlat
2611 * api cleanups, interface in progress.
2613 * Revision 1.38 2008/06/17 20:38:59 smorlat
2614 * added missing file.
2616 * Revision 1.37 2008/04/09 09:26:00 smorlat
2617 * merge various patches
2620 * Revision 1.36 2007/08/01 14:47:53 strk
2621 * * console/commands.c: Clean up commands 'nat', 'stun'
2622 * and 'firewall' to be more intuitive.
2624 * Revision 1.35 2007/06/27 09:01:25 smorlat
2625 * logging improvements.
2627 * Revision 1.34 2007/02/20 10:17:13 smorlat
2628 * linphonec friends patch2
2630 * Revision 1.31 2006/09/22 07:22:47 smorlat
2631 * linphonecore api changes.
2633 * Revision 1.30 2006/09/08 15:32:57 smorlat
2634 * support for using files instead of soundcard (used by linphonec only)
2636 * Revision 1.29 2006/08/28 14:29:07 smorlat
2639 * Revision 1.28 2006/08/21 12:49:59 smorlat
2640 * merged several little patches.
2642 * Revision 1.27 2006/07/17 18:45:00 smorlat
2643 * support for several event queues in ortp.
2644 * glib dependency removed from coreapi/ and console/
2646 * Revision 1.26 2006/04/14 15:16:36 smorlat
2647 * soundcard use did nothing !
2649 * Revision 1.25 2006/04/06 20:09:33 smorlat
2650 * add linphonec command to see and select sound devices.
2652 * Revision 1.24 2006/03/04 11:17:10 smorlat
2653 * mediastreamer2 in progress.
2655 * Revision 1.23 2006/02/20 21:14:01 strk
2656 * Handled syntax errors with 'friend' command
2658 * Revision 1.22 2006/02/20 10:20:29 strk
2659 * Added substring-based filter support for command 'friend list'
2661 * Revision 1.21 2006/02/02 15:39:18 strk
2662 * - Added 'friend list' and 'friend call' commands
2663 * - Allowed for multiple DTFM send in a single line
2664 * - Added status-specific callback (bare version)
2666 * Revision 1.20 2006/01/26 11:54:34 strk
2667 * More robust 'nat' command handler (strip blanks in args)
2669 * Revision 1.19 2006/01/26 09:48:05 strk
2670 * Added limits.h include
2672 * Revision 1.18 2006/01/26 02:18:05 strk
2673 * Added new commands 'nat use' and 'nat unuse'.
2674 * These will required a pending patch to linphonecore.c
2677 * Revision 1.17 2006/01/20 14:12:33 strk
2678 * Added linphonec_init() and linphonec_finish() functions.
2679 * Handled SIGINT and SIGTERM to invoke linphonec_finish().
2680 * Handling of auto-termination (-t) moved to linphonec_finish().
2681 * Reworked main (input read) loop to not rely on 'terminate'
2682 * and 'run' variable (dropped). configfile_name allocated on stack
2683 * using PATH_MAX limit. Changed print_usage signature to allow
2684 * for an exit_status specification.
2686 * Revision 1.16 2006/01/18 09:25:32 strk
2687 * Command completion inhibited in proxy addition and auth request prompts.
2688 * Avoided use of linphonec_readline's internal filename completion.
2690 * Revision 1.15 2006/01/14 13:29:32 strk
2691 * Reworked commands interface to use a table structure,
2692 * used by command line parser and help function.
2693 * Implemented first level of completion (commands).
2694 * Added notification of invalid "answer" and "terminate"
2695 * commands (no incoming call, no active call).
2696 * Forbidden "call" intialization when a call is already active.
2697 * Cleaned up all commands, adding more feedback and error checks.
2699 * Revision 1.14 2006/01/13 13:00:29 strk
2700 * Added linphonec.h. Code layout change (added comments, forward decl,
2701 * globals on top, copyright notices and Logs). Handled out-of-memory
2702 * condition on history management. Removed assumption on sizeof(char).
2703 * Fixed bug in authentication prompt (introduced by linphonec_readline).
2704 * Added support for multiple authentication requests (up to MAX_PENDING_AUTH).
2707 ****************************************************************************/