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);
107 /* Command handler helpers */
108 static void linphonec_proxy_add(LinphoneCore *lc);
109 static void linphonec_proxy_display(LinphoneProxyConfig *lc);
110 static void linphonec_proxy_list(LinphoneCore *lc);
111 static void linphonec_proxy_remove(LinphoneCore *lc, int index);
112 static int linphonec_proxy_use(LinphoneCore *lc, int index);
113 static void linphonec_proxy_show(LinphoneCore *lc,int index);
114 static void linphonec_friend_display(LinphoneFriend *fr);
115 static int linphonec_friend_list(LinphoneCore *lc, char *arg);
116 static void linphonec_display_command_help(LPC_COMMAND *cmd);
117 static int linphonec_friend_call(LinphoneCore *lc, unsigned int num);
119 static int linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr);
121 static int linphonec_friend_delete(LinphoneCore *lc, int num);
122 static int linphonec_friend_delete(LinphoneCore *lc, int num);
123 static void linphonec_codec_list(int type, LinphoneCore *lc);
124 static void linphonec_codec_enable(int type, LinphoneCore *lc, int index);
125 static void linphonec_codec_disable(int type, LinphoneCore *lc, int index);
128 /* Command table management */
129 static LPC_COMMAND *lpc_find_command(const char *name);
131 void linphonec_out(const char *fmt,...);
133 VideoParams lpc_video_params={-1,-1,-1,-1,0,TRUE};
134 VideoParams lpc_preview_params={-1,-1,-1,-1,0,TRUE};
136 /***************************************************************************
140 ***************************************************************************/
145 static LPC_COMMAND commands[] = {
146 { "help", lpc_cmd_help, "Print commands help.",
147 "'help <command>'\t: displays specific help for command.\n"
148 "'help advanced'\t: shows advanced commands.\n"
150 { "call", lpc_cmd_call, "Call a SIP uri or number",
152 "'call <sip-url or number> [options]' \t: initiate a call to the specified destination.\n"
154 "--audio-only : initiate the call without video.\n"
155 "--early-media : sends audio and video stream immediately when remote proposes early media.\n"
157 "'call <sip-url or number>' \t: initiate a call to the specified destination.\n"
160 { "calls", lpc_cmd_calls, "Show all the current calls with their id and status.",
163 { "chat", lpc_cmd_chat, "Chat with a SIP uri",
164 "'chat <sip-url> \"message\"' "
165 ": send a chat message \"message\" to the specified destination."
167 { "terminate", lpc_cmd_terminate, "Terminate a call",
168 "'terminate' : Terminate the current call\n"
169 "'terminate <call id>' : Terminate the call with supplied id\n"
170 "'terminate <all>' : Terminate all the current calls\n"
172 { "answer", lpc_cmd_answer, "Answer a call",
173 "'answer' : Answer the current incoming call\n"
174 "'answer <call id>' : Answer the call with given id\n"
176 { "pause", lpc_cmd_pause, "pause a call",
177 "'pause' : pause the current call\n"},
178 { "resume", lpc_cmd_resume, "resume a call",
179 "'resume' : resume the unique call\n"
180 "'resume <call id>' : hold off the call with given id\n"},
181 { "transfer", lpc_cmd_transfer,
182 "Transfer a call to a specified destination.",
183 "'transfer <sip-uri>' : transfers the current active call to the destination sip-uri\n"
184 "'transfer <call id> <sip-uri>': transfers the call with 'id' to the destination sip-uri\n"
185 "'transfer <call id1> --to-call <call id2>': transfers the call with 'id1' to the destination of call 'id2' (attended transfer)\n"
187 { "conference", lpc_cmd_conference, "Create and manage an audio conference.",
188 "'conference add <call id> : join the call with id 'call id' into the audio conference."
189 "'conference rm <call id> : remove the call with id 'call id' from the audio conference."
191 { "mute", lpc_cmd_mute_mic,
192 "Mute microphone and suspend voice transmission."},
194 { "camera", lpc_cmd_camera, "Send camera output for current call.",
195 "'camera on'\t: allow sending of local camera video to remote end.\n"
196 "'camera off'\t: disable sending of local camera's video to remote end.\n"},
198 { "unmute", lpc_cmd_unmute_mic,
199 "Unmute microphone and resume voice transmission."},
200 { "playbackgain", lpc_cmd_playback_gain,
201 "Adjust playback gain."},
202 { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL },
204 { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
205 "'autoanswer' \t: show current autoanswer mode\n"
206 "'autoanswer enable'\t: enable autoanswer mode\n"
207 "'autoanswer disable'\t: disable autoanswer modeĀ \n"},
208 { "proxy", lpc_cmd_proxy, "Manage proxies",
209 "'proxy list' : list all proxy setups.\n"
210 "'proxy add' : add a new proxy setup.\n"
211 "'proxy remove <index>' : remove proxy setup with number index.\n"
212 "'proxy use <index>' : use proxy with number index as default proxy.\n"
213 "'proxy unuse' : don't use a default proxy.\n"
214 "'proxy show <index>' : show configuration and status of the proxy numbered by index.\n"
215 "'proxy show default' : show configuration and status of the default proxy.\n"
217 { "soundcard", lpc_cmd_soundcard, "Manage soundcards",
218 "'soundcard list' : list all sound devices.\n"
219 "'soundcard show' : show current sound devices configuration.\n"
220 "'soundcard use <index>' : select a sound device.\n"
221 "'soundcard use files' : use .wav files instead of soundcard\n"
223 { "webcam", lpc_cmd_webcam, "Manage webcams",
224 "'webcam list' : list all known devices.\n"
225 "'webcam use <index>' : select a video device.\n"
227 { "ipv6", lpc_cmd_ipv6, "Use IPV6",
228 "'ipv6 status' : show ipv6 usage status.\n"
229 "'ipv6 enable' : enable the use of the ipv6 network.\n"
230 "'ipv6 disable' : do not use ipv6 network."
232 { "nat", lpc_cmd_nat, "Set nat address",
233 "'nat' : show nat settings.\n"
234 "'nat <addr>' : set nat address.\n"
236 { "stun", lpc_cmd_stun, "Set stun server address",
237 "'stun' : show stun settings.\n"
238 "'stun <addr>' : set stun server address.\n"
240 { "firewall", lpc_cmd_firewall, "Set firewall policy",
241 "'firewall' : show current firewall policy.\n"
242 "'firewall none' : use direct connection.\n"
243 "'firewall nat' : use nat address given with the 'nat' command.\n"
244 "'firewall stun' : use stun server given with the 'stun' command.\n"
246 { "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
247 { "friend", lpc_cmd_friend, "Manage friends",
248 "'friend list [<pattern>]' : list friends.\n"
249 "'friend call <index>' : call a friend.\n"
250 "'friend add <name> <addr>' : add friend, <name> must be quoted to include\n"
251 " spaces, <addr> has \"sip:\" added if it isn't\n"
252 " there. Don't use '<' '>' around <addr>.\n"
253 "'friend delete <index>' : remove friend, 'all' removes all\n"
255 { "play", lpc_cmd_play, "play a wav file",
256 "This command has two roles:\n"
257 "Plays a file instead of capturing from soundcard - only available in file mode (see 'help soundcard')\n"
258 "Specifies a wav file to be played to play music to far end when putting it on hold (pause)\n"
259 "'play <wav file>' : play a wav file."
261 { "record", lpc_cmd_record, "record to a wav file",
262 "This feature is available only in file mode (see 'help soundcard')\n"
263 "'record <wav file>' : record into wav file."
265 { "quit", lpc_cmd_quit, "Exit linphonec", NULL },
266 { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
270 static LPC_COMMAND advanced_commands[] = {
271 { "codec", lpc_cmd_acodec, "Audio codec configuration",
272 "'codec list' : list audio codecs\n"
273 "'codec enable <index>' : enable available audio codec\n"
274 "'codec disable <index>' : disable audio codec" },
275 { "vcodec", lpc_cmd_vcodec, "Video codec configuration",
276 "'vcodec list' : list video codecs\n"
277 "'vcodec enable <index>' : enable available video codec\n"
278 "'vcodec disable <index>' : disable video codec" },
279 { "ec", lpc_cmd_echocancellation, "Echo cancellation",
280 "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
281 "'ec off' : turn echo cancellation (EC) off\n"
282 "'ec show' : show EC status" },
283 { "el", lpc_cmd_echolimiter, "Echo limiter",
284 "'el on turns on echo limiter (automatic half duplex, for cases where echo canceller cannot work)\n"
285 "'el off' : turn echo limiter off\n"
286 "'el show' : show echo limiter status" },
287 { "nortp-on-audio-mute", lpc_cmd_rtp_no_xmit_on_audio_mute,
288 "Set the rtp_no_xmit_on_audio_mute configuration parameter",
289 " If set to 1 then rtp transmission will be muted when\n"
290 " audio is muted , otherwise rtp is always sent."},
292 { "vwindow", lpc_cmd_video_window, "Control video display window",
293 "'vwindow show': shows video window\n"
294 "'vwindow hide': hides video window\n"
295 "'vwindow pos <x> <y>': Moves video window to x,y pixel coordinates\n"
296 "'vwindow size <width> <height>': Resizes video window\n"
297 "'vwindow id <window id>': embeds video display into supplied window id."
299 { "pwindow", lpc_cmd_preview_window, "Control local camera video display (preview window)",
300 "'pwindow show': shows the local camera video display\n"
301 "'pwindow hide': hides the local camera video display\n"
302 "'pwindow pos <x> <y>': Moves preview window to x,y pixel coordinates\n"
303 "'pwindow size <width> <height>': Resizes preview window\n"
304 "'pwindow id <window id>': embeds preview display into supplied window id.\n"
305 "'pwindow integrated': integrate preview display within the video window of current call.\n"
306 "'pwindow standalone': use standalone window for preview display."
308 { "snapshot", lpc_cmd_snapshot, "Take a snapshot of currently received video stream",
309 "'snapshot <file path>': take a snapshot and records it in jpeg format into the supplied path\n"
311 { "vfureq", lpc_cmd_vfureq, "Request the other side to send VFU for the current call"},
313 { "states", lpc_cmd_states, "Show internal states of liblinphone, registrations and calls, according to linphonecore.h definitions",
314 "'states global': shows global state of liblinphone \n"
315 "'states calls': shows state of calls\n"
316 "'states proxies': shows state of proxy configurations"
318 { "register", lpc_cmd_register, "Register in one line to a proxy" , "register <sip identity> <sip proxy> <password>"},
319 { "unregister", lpc_cmd_unregister, "Unregister from default proxy", NULL },
320 { "status", lpc_cmd_status, "Print various status information",
321 "'status register' \t: print status concerning registration\n"
322 "'status autoanswer'\t: tell whether autoanswer mode is enabled\n"
323 "'status hook' \t: print hook status\n" },
324 { "ports", lpc_cmd_ports, "Network ports configuration",
325 "'ports' \t: prints current used ports.\n"
326 "'ports sip <port number>'\t: Sets the sip port.\n" },
327 { "param", lpc_cmd_param, "parameter set or read as normally given in .linphonerc",
328 "'param <section> <parameter> [<value>]' \t: reads [sets] given parameter.\n"
329 "NOTES: - changes may become effective after (re)establishing a sip connection.\n"
330 " - upon exit, .linphonerc will reflect the updated state.\n" },
331 { "speak", lpc_cmd_speak, "Speak a sentence using espeak TTS engine",
332 "This feature is available only in file mode. (see 'help soundcard')\n"
333 "'speak <voice name> <sentence>' : speak a text using the specified espeak voice.\n"
334 "Example for english voice: 'speak default Hello my friend !'"
336 { "staticpic", lpc_cmd_staticpic, "Manage static pictures when nowebcam",
337 "'staticpic set' : Set path to picture that should be used.\n"
338 "'staticpic fps' : Get/set frames per seconds for picture emission.\n"
340 { "identify", lpc_cmd_identify, "Returns the user-agent string of far end",
341 "'identify' \t: returns remote user-agent string for current call.\n"
342 "'identify <id>' \t: returns remote user-agent string for call with supplied id.\n"
344 { "ringback", lpc_cmd_ringback, "Specifies a ringback tone to be played to remote end during incoming calls",
345 "'ringback <path of mono .wav file>'\t: Specifies a ringback tone to be played to remote end during incoming calls\n"
346 "'ringback disable'\t: Disable playing of ringback tone to callers\n"
348 { "redirect", lpc_cmd_redirect, "Redirect an incoming call",
349 "'redirect <redirect-uri>'\t: Redirect all pending incoming calls to the <redirect-uri>\n"
351 { NULL,NULL,NULL,NULL}
356 /***************************************************************************
360 ***************************************************************************/
363 * Main command dispatcher.
364 * WARNING: modifies second argument!
366 * Always return 1 currently.
369 linphonec_parse_command_line(LinphoneCore *lc, char *cl)
375 /* Isolate first word and args */
376 while(*ptr && !isspace(*ptr)) ++ptr;
380 /* set args to first nonblank */
382 while(*args && isspace(*args)) ++args;
386 if ( isdigit(*cl) || *cl == '#' || *cl == '*' )
388 while ( isdigit(*cl) || *cl == '#' || *cl == '*' )
390 linphone_core_send_dtmf(lc, *cl);
391 linphone_core_play_dtmf (lc,*cl,100);
392 ms_sleep(1); // be nice
396 // discard spurious trailing chars
400 /* Handle other kind of commands */
401 cmd=lpc_find_command(cl);
404 linphonec_out("'%s': Cannot understand this.\n", cl);
408 if ( ! cmd->func(lc, args) )
410 linphonec_out("Syntax error.\n");
411 linphonec_display_command_help(cmd);
418 * Generator function for command completion.
419 * STATE let us know whether to start from scratch;
420 * without any state (STATE==0), then we start at the
424 linphonec_command_generator(const char *text, int state)
426 static int index, len, adv;
436 * Return the next name which partially matches
437 * from the commands list
440 while ((name=commands[index].name))
442 ++index; /* so next call get next command */
444 if (strncmp(name, text, len) == 0)
446 return ortp_strdup(name);
453 while ((name=advanced_commands[index].name))
455 ++index; /* so next call get next command */
457 if (strncmp(name, text, len) == 0)
459 return ortp_strdup(name);
467 /***************************************************************************
471 ***************************************************************************/
474 lpc_cmd_help(LinphoneCore *lc, char *arg)
481 linphonec_out("Commands are:\n");
482 linphonec_out("---------------------------\n");
484 while (commands[i].help)
486 linphonec_out("%10.10s\t%s\n", commands[i].name,
491 linphonec_out("---------------------------\n");
492 linphonec_out("Type 'help <command>' for more details or\n");
493 linphonec_out(" 'help advanced' to list additional commands.\n");
498 if (strcmp(arg,"advanced")==0){
499 linphonec_out("Advanced commands are:\n");
500 linphonec_out("---------------------------\n");
502 while (advanced_commands[i].help)
504 linphonec_out("%10.10s\t%s\n", advanced_commands[i].name,
505 advanced_commands[i].help);
509 linphonec_out("---------------------------\n");
510 linphonec_out("Type 'help <command>' for more details.\n");
515 cmd=lpc_find_command(arg);
518 linphonec_out("No such command.\n");
522 linphonec_display_command_help(cmd);
527 static char callee_name[256]={0};
528 static char caller_name[256]={0};
530 static const char *get_call_status(LinphoneCall *call){
531 switch(linphone_call_get_state(call)){
532 case LinphoneCallPaused:
533 if (linphone_call_get_refer_to (call)!=NULL){
534 return "Paused (transfered)";
539 case LinphoneCallPausedByRemote:
540 return "Paused by remote";
542 case LinphoneCallIncomingReceived:
545 case LinphoneCallOutgoingInit:
546 case LinphoneCallOutgoingProgress:
547 return "Dialing out";
549 case LinphoneCallOutgoingEarlyMedia:
550 case LinphoneCallOutgoingRinging:
551 return "Remote ringing";
554 if (linphone_call_has_transfer_pending(call)){
555 return "Running (transfer pending)";
563 lpc_cmd_call(LinphoneCore *lc, char *args)
565 if ( ! args || ! *args )
571 LinphoneCallParams *cp=linphone_core_create_default_call_parameters (lc);
573 if ( linphone_core_in_call(lc) )
575 linphonec_out("Terminate or hold on the current call first.\n");
578 opt1=strstr(args,"--audio-only");
579 opt2=strstr(args,"--early-media");
582 linphone_call_params_enable_video (cp,FALSE);
586 linphone_call_params_enable_early_media_sending(cp,TRUE);
588 if ( NULL == (call=linphone_core_invite_with_params(lc, args,cp)) )
590 linphonec_out("Error from linphone_core_invite.\n");
594 snprintf(callee_name,sizeof(callee_name),"%s",args);
596 linphone_call_params_destroy(cp);
602 lpc_cmd_calls(LinphoneCore *lc, char *args){
603 const MSList *calls = linphone_core_get_calls(lc);
606 const MSList *p_calls = calls;
607 linphonec_out("ID\t\tDestination\t\t\t\tStatus\n---------------------------------------------------------------------\n");
608 while(p_calls != NULL)
610 LinphoneCall *call=(LinphoneCall*)p_calls->data;
611 char *tmp=linphone_call_get_remote_address_as_string(call);
612 linphonec_out("%li\t%s\t\t\t%s\r\n",
613 (long)linphone_call_get_user_pointer (call),
615 get_call_status(call));
616 p_calls = p_calls->next;
621 linphonec_out("No active call.\n");
628 lpc_cmd_chat(LinphoneCore *lc, char *args)
636 /* Isolate first and second arg */
637 while(*ptr && !isspace(*ptr)) ++ptr;
642 while(*arg2 && isspace(*arg2)) ++arg2;
646 /* missing one parameter */
649 LinphoneChatRoom *cr = linphone_core_create_chat_room(lc,arg1);
650 linphone_chat_room_send_message(cr,arg2);
651 linphone_chat_room_destroy(cr);
656 const char *linphonec_get_callee(){
660 const char *linphonec_get_caller(){
664 void linphonec_set_caller(const char *caller){
665 snprintf(caller_name,sizeof(caller_name)-1,"%s",caller);
669 lpc_cmd_transfer(LinphoneCore *lc, char *args)
674 const char *refer_to=NULL;
678 int n=sscanf(args,"%s %s %li",arg1,arg2,&id2);
679 if (n==1 || isalpha(*arg1)){
680 call=linphone_core_get_current_call(lc);
681 if (call==NULL && ms_list_size(linphone_core_get_calls(lc))==1){
682 call=(LinphoneCall*)linphone_core_get_calls(lc)->data;
686 linphonec_out("No active call, please specify a call id among the ones listed by 'calls' command.\n");
689 linphone_core_transfer_call(lc, call, refer_to);
692 refer_to=args+strlen(arg1)+1;
693 call=linphonec_get_call(id);
694 if (call==NULL) return 0;
695 linphone_core_transfer_call(lc, call, refer_to);
698 call=linphonec_get_call(id);
699 call2=linphonec_get_call(id2);
700 if (call==NULL || call2==NULL) return 0;
701 if (strcmp(arg2,"--to-call")!=0){
704 linphonec_out("Performing attended transfer of call %i to call %i",id,id2);
705 linphone_core_transfer_call_to_another (lc,call,call2);
708 linphonec_out("Transfer command requires at least one argument\n");
715 lpc_cmd_terminate(LinphoneCore *lc, char *args)
717 if (linphone_core_get_calls(lc)==NULL){
718 linphonec_out("No active calls\n");
723 if ( -1 == linphone_core_terminate_call(lc, NULL) ){
724 linphonec_out("Could not stop the active call.\n");
729 if(strcmp(args,"all")==0){
730 linphonec_out("We are going to stop all the calls.\n");
731 linphone_core_terminate_all_calls(lc);
734 /*the argument is a linphonec call id */
736 LinphoneCall *call=linphonec_get_call(id);
738 if (linphone_core_terminate_call(lc,call)==-1){
739 linphonec_out("Could not stop the call with id %li\n",id);
749 lpc_cmd_redirect(LinphoneCore *lc, char *args){
753 if ((elem=linphone_core_get_calls(lc))==NULL){
754 linphonec_out("No active calls.\n");
758 LinphoneCall *call=(LinphoneCall*)elem->data;
759 if (linphone_call_get_state(call)==LinphoneCallIncomingReceived){
760 linphone_core_redirect_call(lc,call,args);
762 /*as the redirection closes the call, we need to re-check the call list that is invalidated.*/
763 elem=linphone_core_get_calls(lc);
764 }else elem=elem->next;
767 linphonec_out("There is no pending incoming call to redirect.");
773 lpc_cmd_answer(LinphoneCore *lc, char *args){
776 int nb=ms_list_size(linphone_core_get_calls(lc));
778 //if just one call is present answer the only one in passing NULL to the linphone_core_accept_call ...
779 if ( -1 == linphone_core_accept_call(lc, NULL) )
781 linphonec_out("Fail to accept incoming call\n");
784 linphonec_out("There are no calls to answer.\n");
786 linphonec_out("Multiple calls in progress, please specify call id.\n");
792 if (sscanf(args,"%li",&id)==1){
793 LinphoneCall *call=linphonec_get_call (id);
794 if (linphone_core_accept_call (lc,call)==-1){
795 linphonec_out("Fail to accept call %i\n",id);
804 lpc_cmd_autoanswer(LinphoneCore *lc, char *args)
808 if ( linphonec_get_autoanswer() ) {
809 linphonec_out("Auto answer is enabled. Use 'autoanswer disable' to disable.\n");
811 linphonec_out("Auto answer is disabled. Use 'autoanswer enable' to enable.\n");
816 if (strstr(args,"enable")){
817 linphonec_set_autoanswer(TRUE);
818 linphonec_out("Auto answer enabled.\n");
819 }else if (strstr(args,"disable")){
820 linphonec_set_autoanswer(FALSE);
821 linphonec_out("Auto answer disabled.\n");
827 lpc_cmd_quit(LinphoneCore *lc, char *args)
829 linphonec_main_loop_exit();
834 lpc_cmd_nat(LinphoneCore *lc, char *args)
839 if ( args ) args=lpc_strip_blanks(args);
843 linphone_core_set_nat_address(lc, args);
844 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS); */
847 nat = linphone_core_get_nat_address(lc);
848 use = linphone_core_get_firewall_policy(lc)==LinphonePolicyUseNatAddress;
849 linphonec_out("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
855 lpc_cmd_stun(LinphoneCore *lc, char *args)
860 if ( args ) args=lpc_strip_blanks(args);
864 linphone_core_set_stun_server(lc, args);
865 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN); */
868 stun = linphone_core_get_stun_server(lc);
869 use = linphone_core_get_firewall_policy(lc)==LinphonePolicyUseStun;
870 linphonec_out("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
876 lpc_cmd_firewall(LinphoneCore *lc, char *args)
878 const char* setting=NULL;
880 if ( args ) args=lpc_strip_blanks(args);
884 if (strcmp(args,"none")==0)
886 linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall);
888 else if (strcmp(args,"stun")==0)
890 setting = linphone_core_get_stun_server(lc);
893 linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
896 linphone_core_set_firewall_policy(lc,LinphonePolicyUseStun);
898 else if (strcmp(args,"nat")==0)
900 setting = linphone_core_get_nat_address(lc);
903 linphonec_out("No nat address is defined, use 'nat <address>' first");
906 linphone_core_set_firewall_policy(lc,LinphonePolicyUseNatAddress);
910 switch(linphone_core_get_firewall_policy(lc))
912 case LinphonePolicyNoFirewall:
913 linphonec_out("No firewall\n");
915 case LinphonePolicyUseStun:
916 linphonec_out("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
918 case LinphonePolicyUseNatAddress:
919 linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
926 /* Helper function for processing freind names */
928 lpc_friend_name(char **args, char **name)
930 /* Use space as a terminator unless quoted */
931 if (('"' == **args) || ('\'' == **args)){
936 while ((delim != *end) && ('\0' != *end)) end++;
938 fprintf(stderr, "Mismatched quotes\n");
945 *name = strsep(args, " ");
947 if (NULL == *args) { /* Means there was no separator */
948 fprintf(stderr, "Either name or address is missing\n");
951 if (NULL == *name) return 0;
958 lpc_cmd_friend(LinphoneCore *lc, char *args)
962 if ( args ) args=lpc_strip_blanks(args);
964 if ( ! args || ! *args ) return 0;
966 if ( !strncmp(args, "list", 4) )
968 return linphonec_friend_list(lc, args+4);
971 else if ( !strncmp(args, "call", 4) )
974 if ( ! *args ) return 0;
975 friend_num = strtol(args, NULL, 10);
977 if ( errno == ERANGE ) {
978 linphonec_out("Invalid friend number\n");
981 #endif /*_WIN32_WCE*/
982 linphonec_friend_call(lc, friend_num);
985 else if ( !strncmp(args, "delete", 6) )
988 if ( ! *args ) return 0;
989 while (*args == ' ') args++;
990 if ( ! *args ) return 0;
991 if (!strncmp(args, "all", 3))
997 friend_num = strtol(args, NULL, 10);
999 if ( errno == ERANGE ) {
1000 linphonec_out("Invalid friend number\n");
1003 #endif /*_WIN32_WCE*/
1005 linphonec_friend_delete(lc, friend_num);
1008 else if ( !strncmp(args, "add", 3) )
1013 char *addr_p = addr;
1017 if ( ! *args ) return 0;
1018 while (*args == ' ') args++;
1019 if ( ! *args ) return 0;
1021 if (!lpc_friend_name(&args, &name)) return 0;
1023 while (*args == ' ') args++;
1024 if ( ! *args ) return 0;
1025 if (isdigit(*args)) {
1026 strcpy (addr, "sip:");
1027 addr_p = addr + strlen("sip:");
1029 addr_orig = strsep(&args, " ");
1030 if (1 >= strlen(addr_orig)) {
1031 fprintf(stderr, "A single-digit address is not valid\n");
1034 strcpy(addr_p, addr_orig);
1035 linphonec_friend_add(lc, name, addr);
1037 LinphoneFriend *new_friend;
1038 new_friend = linphone_friend_new_with_addr(args);
1039 linphone_core_add_friend(lc, new_friend);
1046 static int lpc_cmd_play(LinphoneCore *lc, char *args){
1047 if ( args ) args=lpc_strip_blanks(args);
1048 if ( ! args || ! *args ) return 0;
1049 linphone_core_set_play_file(lc,args);
1053 static int lpc_cmd_record(LinphoneCore *lc, char *args){
1054 if ( args ) args=lpc_strip_blanks(args);
1055 if ( ! args || ! *args ) return 0;
1056 linphone_core_set_record_file(lc,args);
1064 lpc_cmd_proxy(LinphoneCore *lc, char *args)
1071 if ( ! arg1 ) return 0;
1073 /* Isolate first and second arg */
1074 while(*ptr && !isspace(*ptr)) ++ptr;
1079 while(*arg2 && isspace(*arg2)) ++arg2;
1082 if (strcmp(arg1,"add")==0)
1084 #ifdef HAVE_READLINE
1085 rl_inhibit_completion=1;
1087 linphonec_proxy_add(lc);
1088 #ifdef HAVE_READLINE
1089 rl_inhibit_completion=0;
1092 else if (strcmp(arg1,"list")==0)
1094 linphonec_proxy_list(lc);
1096 else if (strcmp(arg1,"remove")==0)
1098 linphonec_proxy_remove(lc,atoi(arg2));
1100 else if (strcmp(arg1,"use")==0)
1102 if ( arg2 && *arg2 )
1104 proxynum=atoi(arg2);
1105 if ( linphonec_proxy_use(lc, proxynum) )
1106 linphonec_out("Default proxy set to %d.\n", proxynum);
1110 proxynum=linphone_core_get_default_proxy(lc, NULL);
1111 if ( proxynum == -1 ) linphonec_out("No default proxy.\n");
1112 else linphonec_out("Current default proxy is %d.\n", proxynum);
1114 }else if (strcmp(arg1, "unuse")==0){
1115 linphone_core_set_default_proxy(lc, NULL);
1116 linphonec_out("Use no proxy.\n");
1119 else if (strcmp(arg1, "show")==0)
1123 if (strstr(arg2,"default"))
1125 proxynum=linphone_core_get_default_proxy(lc, NULL);
1126 if ( proxynum < 0 ) {
1127 linphonec_out("No default proxy defined\n");
1130 linphonec_proxy_show(lc,proxynum);
1134 linphonec_proxy_show(lc, atoi(arg2));
1137 else return 0; /* syntax error */
1142 return 0; /* syntax error */
1149 lpc_cmd_call_logs(LinphoneCore *lc, char *args)
1151 const MSList *elem=linphone_core_get_call_logs(lc);
1152 for (;elem!=NULL;elem=ms_list_next(elem))
1154 LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
1155 char *str=linphone_call_log_to_str(cl);
1156 linphonec_out("%s\n",str);
1163 lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
1167 return 0; /* syntax error */
1170 if (strcmp(arg1,"status")==0)
1172 linphonec_out("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
1174 else if (strcmp(arg1,"enable")==0)
1176 linphone_core_enable_ipv6(lc,TRUE);
1177 linphonec_out("ipv6 use enabled.\n");
1179 else if (strcmp(arg1,"disable")==0)
1181 linphone_core_enable_ipv6(lc,FALSE);
1182 linphonec_out("ipv6 use disabled.\n");
1186 return 0; /* syntax error */
1191 static int devname_to_index(LinphoneCore *lc, const char *devname){
1194 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
1195 if (strcmp(devname,*p)==0) return i;
1200 static const char *index_to_devname(LinphoneCore *lc, int index){
1203 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
1204 if (i==index) return *p;
1209 static int lpc_cmd_soundcard(LinphoneCore *lc, char *args)
1217 if (!args) return 0; /* syntax error */
1219 /* Isolate first and second arg */
1220 while(*ptr && !isspace(*ptr)) ++ptr;
1225 while(*arg2 && isspace(*arg2)) ++arg2;
1228 if (strcmp(arg1, "list")==0)
1230 dev=linphone_core_get_sound_devices(lc);
1231 for(i=0; dev[i]!=NULL; ++i){
1232 linphonec_out("%i: %s\n",i,dev[i]);
1237 if (strcmp(arg1, "show")==0)
1239 linphonec_out("Ringer device: %s\n",
1240 linphone_core_get_ringer_device(lc));
1241 linphonec_out("Playback device: %s\n",
1242 linphone_core_get_playback_device(lc));
1243 linphonec_out("Capture device: %s\n",
1244 linphone_core_get_capture_device(lc));
1248 if (strcmp(arg1, "use")==0 && arg2)
1250 if (strcmp(arg2, "files")==0)
1252 linphonec_out("Using wav files instead of soundcard.\n");
1253 linphone_core_use_files(lc,TRUE);
1257 dev=linphone_core_get_sound_devices(lc);
1258 index=atoi(arg2); /* FIXME: handle not-a-number */
1259 for(i=0;dev[i]!=NULL;i++)
1261 if (i!=index) continue;
1263 linphone_core_set_ringer_device(lc,dev[i]);
1264 linphone_core_set_playback_device(lc,dev[i]);
1265 linphone_core_set_capture_device(lc,dev[i]);
1266 linphonec_out("Using sound device %s\n",dev[i]);
1269 linphonec_out("No such sound device\n");
1272 if (strcmp(arg1, "capture")==0)
1274 const char *devname=linphone_core_get_capture_device(lc);
1276 linphonec_out("Using capture device #%i (%s)\n",
1277 devname_to_index(lc,devname),devname);
1279 index=atoi(arg2); /* FIXME: handle not-a-number */
1280 devname=index_to_devname(lc,index);
1282 linphone_core_set_capture_device(lc,devname);
1283 linphonec_out("Using capture sound device %s\n",devname);
1286 linphonec_out("No such sound device\n");
1290 if (strcmp(arg1, "playback")==0)
1292 const char *devname=linphone_core_get_playback_device(lc);
1294 linphonec_out("Using playback device #%i (%s)\n",
1295 devname_to_index(lc,devname),devname);
1297 index=atoi(arg2); /* FIXME: handle not-a-number */
1298 devname=index_to_devname(lc,index);
1300 linphone_core_set_playback_device(lc,devname);
1301 linphonec_out("Using playback sound device %s\n",devname);
1304 linphonec_out("No such sound device\n");
1308 if (strcmp(arg1, "ring")==0)
1310 const char *devname=linphone_core_get_ringer_device(lc);
1312 linphonec_out("Using ring device #%i (%s)\n",
1313 devname_to_index(lc,devname),devname);
1315 index=atoi(arg2); /* FIXME: handle not-a-number */
1316 devname=index_to_devname(lc,index);
1318 linphone_core_set_ringer_device(lc,devname);
1319 linphonec_out("Using ring sound device %s\n",devname);
1322 linphonec_out("No such sound device\n");
1326 return 0; /* syntax error */
1329 static int lpc_cmd_webcam(LinphoneCore *lc, char *args)
1337 if (!args) return 0; /* syntax error */
1339 /* Isolate first and second arg */
1340 while(*ptr && !isspace(*ptr)) ++ptr;
1345 while(*arg2 && isspace(*arg2)) ++arg2;
1348 if (strcmp(arg1, "list")==0)
1350 dev=linphone_core_get_video_devices(lc);
1351 for(i=0; dev[i]!=NULL; ++i){
1352 linphonec_out("%i: %s\n",i,dev[i]);
1357 if (strcmp(arg1, "use")==0 && arg2)
1359 dev=linphone_core_get_video_devices(lc);
1360 index=atoi(arg2); /* FIXME: handle not-a-number */
1361 for(i=0;dev[i]!=NULL;i++)
1363 if (i!=index) continue;
1365 linphone_core_set_video_device(lc, dev[i]);
1366 linphonec_out("Using video device %s\n",dev[i]);
1369 linphonec_out("No such video device\n");
1372 return 0; /* syntax error */
1376 lpc_cmd_staticpic(LinphoneCore *lc, char *args)
1382 if (!args) return 0; /* Syntax error */
1384 /* Isolate first and second arg */
1385 while(*ptr && !isspace(*ptr)) ++ptr;
1390 while(*arg2 && isspace(*arg2)) ++arg2;
1393 if (strcmp(arg1, "set")==0 && arg2) {
1394 linphone_core_set_static_picture(lc, arg2);
1398 if (strcmp(arg1, "fps")==0) {
1400 float fps = atof(arg2); /* FIXME: Handle not-a-float */
1401 linphone_core_set_static_picture_fps(lc, fps);
1405 fps = linphone_core_get_static_picture_fps(lc);
1406 linphonec_out("Current FPS %f\n", fps);
1411 return 0; /* Syntax error */
1414 static int lpc_cmd_pause(LinphoneCore *lc, char *args){
1416 if(linphone_core_in_call(lc))
1418 linphone_core_pause_call(lc,linphone_core_get_current_call(lc));
1421 linphonec_out("you can only pause when a call is in process\n");
1425 static int lpc_cmd_resume(LinphoneCore *lc, char *args){
1427 if(linphone_core_in_call(lc))
1429 linphonec_out("There is already a call in process pause or stop it first");
1435 int n = sscanf(args, "%li", &id);
1437 LinphoneCall *call=linphonec_get_call (id);
1439 if(linphone_core_resume_call(lc,call)==-1){
1440 linphonec_out("There was a problem to resume the call check the remote address you gave %s\n",args);
1448 const MSList *calls = linphone_core_get_calls(lc);
1449 int nbcalls=ms_list_size(calls);
1452 if(linphone_core_resume_call(lc,calls->data) < 0)
1454 linphonec_out("There was a problem to resume the unique call.\n");
1457 }else if (nbcalls==0){
1458 linphonec_out("There is no calls at this time.\n");
1461 linphonec_out("There are %i calls at this time, please specify call id as given with 'calls' command.\n");
1468 static int lpc_cmd_conference(LinphoneCore *lc, char *args){
1470 char subcommand[32]={0};
1472 if (args==NULL) return 0;
1473 n=sscanf(args, "%31s %li", subcommand,&id);
1475 LinphoneCall *call=linphonec_get_call(id);
1476 if (call==NULL) return 1;
1477 if (strcmp(subcommand,"add")==0){
1478 linphone_core_add_to_conference(lc,call);
1479 }else if (strcmp(subcommand,"rm")==0){
1480 linphone_core_remove_from_conference(lc,call);
1486 /***************************************************************************
1488 * Commands helper functions
1490 ***************************************************************************/
1494 linphonec_proxy_add(LinphoneCore *lc)
1496 bool_t enable_register=FALSE;
1497 LinphoneProxyConfig *cfg;
1499 linphonec_out("Adding new proxy setup. Hit ^D to abort.\n");
1506 char *input=linphonec_readline("Enter proxy sip address: ");
1510 linphonec_out("Aborted.\n");
1515 clean=lpc_strip_blanks(input);
1521 cfg=linphone_proxy_config_new();
1522 if (linphone_proxy_config_set_server_addr(cfg,clean)<0)
1524 linphonec_out("Invalid sip address (sip:sip.domain.tld).\n");
1526 linphone_proxy_config_destroy(cfg);
1534 * SIP Proxy identity
1538 char *input=linphonec_readline("Your identity for this proxy: ");
1542 linphonec_out("Aborted.\n");
1543 linphone_proxy_config_destroy(cfg);
1548 clean=lpc_strip_blanks(input);
1554 linphone_proxy_config_set_identity(cfg, clean);
1555 if ( ! linphone_proxy_config_get_identity (cfg))
1557 linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
1566 * SIP Proxy enable register
1570 char *input=linphonec_readline("Do you want to register on this proxy (yes/no): ");
1574 linphonec_out("Aborted.\n");
1575 linphone_proxy_config_destroy(cfg);
1580 clean=lpc_strip_blanks(input);
1586 if ( ! strcmp(clean, "yes") ) enable_register=TRUE;
1587 else if ( ! strcmp(clean, "no") ) enable_register=FALSE;
1589 linphonec_out("Please answer with 'yes' or 'no'\n");
1593 linphone_proxy_config_enableregister(cfg, enable_register);
1599 * SIP Proxy registration expiration
1601 if ( enable_register==TRUE )
1606 char *input=linphonec_readline("Specify register expiration time"
1607 " in seconds (default is 600): ");
1610 linphonec_out("Aborted.\n");
1611 linphone_proxy_config_destroy(cfg);
1615 expires=strtol(input, (char **)NULL, 10);
1616 if ( expires == LONG_MIN || expires == LONG_MAX )
1618 linphonec_out("Invalid value: %s\n", strerror(errno));
1623 linphone_proxy_config_expires(cfg, expires);
1624 linphonec_out("Expiration: %d seconds\n", linphone_proxy_config_get_expires (cfg));
1636 char *input=linphonec_readline("Specify route if needed: ");
1640 linphonec_out("Aborted.\n");
1641 linphone_proxy_config_destroy(cfg);
1646 clean=lpc_strip_blanks(input);
1649 linphonec_out("No route specified.\n");
1653 linphone_proxy_config_set_route(cfg, clean);
1654 if ( ! linphone_proxy_config_get_route(cfg) )
1656 linphonec_out("Invalid route.\n");
1666 * Final confirmation
1673 linphonec_out("--------------------------------------------\n");
1674 linphonec_proxy_display(cfg);
1675 linphonec_out("--------------------------------------------\n");
1676 input=linphonec_readline("Accept the above proxy configuration (yes/no) ?: ");
1680 linphonec_out("Aborted.\n");
1681 linphone_proxy_config_destroy(cfg);
1686 clean=lpc_strip_blanks(input);
1692 if ( ! strcmp(clean, "yes") ) break;
1693 else if ( ! strcmp(clean, "no") )
1695 linphonec_out("Declined.\n");
1696 linphone_proxy_config_destroy(cfg);
1701 linphonec_out("Please answer with 'yes' or 'no'\n");
1707 linphone_core_add_proxy_config(lc,cfg);
1709 /* automatically set the last entered proxy as the default one */
1710 linphone_core_set_default_proxy(lc,cfg);
1712 linphonec_out("Proxy added.\n");
1716 linphonec_proxy_display(LinphoneProxyConfig *cfg)
1718 const char *route=linphone_proxy_config_get_route(cfg);
1719 const char *identity=linphone_proxy_config_get_identity(cfg);
1720 linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n",
1721 linphone_proxy_config_get_addr(cfg),
1722 (route!=NULL)? route:"",
1723 (identity!=NULL)?identity:"",
1724 linphone_proxy_config_register_enabled (cfg)?"yes":"no",
1725 linphone_proxy_config_get_expires (cfg),
1726 linphone_proxy_config_is_registered(cfg) ? "yes" : "no");
1729 static void linphonec_proxy_show(LinphoneCore *lc, int index)
1733 for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){
1735 LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)elem->data;
1736 linphonec_proxy_display(cfg);
1740 linphonec_out("No proxy with index %i\n", index);
1744 linphonec_proxy_list(LinphoneCore *lc)
1746 const MSList *proxies;
1748 int def=linphone_core_get_default_proxy(lc,NULL);
1750 proxies=linphone_core_get_proxy_config_list(lc);
1751 for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){
1753 linphonec_out("****** Proxy %i - this is the default one - *******\n",n);
1755 linphonec_out("****** Proxy %i *******\n",n);
1756 linphonec_proxy_display((LinphoneProxyConfig*)proxies->data);
1758 if ( ! n ) linphonec_out("No proxies defined\n");
1762 linphonec_proxy_remove(LinphoneCore *lc, int index)
1764 const MSList *proxies;
1765 LinphoneProxyConfig *cfg;
1766 proxies=linphone_core_get_proxy_config_list(lc);
1767 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1769 linphonec_out("No such proxy.\n");
1772 linphone_core_remove_proxy_config(lc,cfg);
1773 linphonec_out("Proxy %s removed.\n", linphone_proxy_config_get_addr(cfg));
1777 linphonec_proxy_use(LinphoneCore *lc, int index)
1779 const MSList *proxies;
1780 LinphoneProxyConfig *cfg;
1781 proxies=linphone_core_get_proxy_config_list(lc);
1782 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1784 linphonec_out("No such proxy (try 'proxy list').");
1787 linphone_core_set_default_proxy(lc,cfg);
1792 linphonec_friend_display(LinphoneFriend *fr)
1794 LinphoneAddress *uri=linphone_address_clone(linphone_friend_get_address(fr));
1797 linphonec_out("name: %s\n", linphone_address_get_display_name(uri));
1798 linphone_address_set_display_name(uri,NULL);
1799 str=linphone_address_as_string(uri);
1800 linphonec_out("address: %s\n", str);
1804 linphonec_friend_list(LinphoneCore *lc, char *pat)
1806 const MSList *friend;
1810 pat=lpc_strip_blanks(pat);
1811 if (!*pat) pat = NULL;
1814 friend = linphone_core_get_friend_list(lc);
1815 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1818 const char *name = linphone_address_get_display_name(
1819 linphone_friend_get_address((LinphoneFriend*)friend->data));
1820 if (name && ! strstr(name, pat) ) continue;
1822 linphonec_out("****** Friend %i *******\n",n);
1823 linphonec_friend_display((LinphoneFriend*)friend->data);
1830 linphonec_friend_call(LinphoneCore *lc, unsigned int num)
1832 const MSList *friend = linphone_core_get_friend_list(lc);
1836 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1841 addr = linphone_address_as_string(linphone_friend_get_address((LinphoneFriend*)friend->data));
1842 ret=lpc_cmd_call(lc, addr);
1847 linphonec_out("No such friend %u\n", num);
1853 linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr)
1855 LinphoneFriend *newFriend;
1859 snprintf(url, PATH_MAX, "%s <%s>", name, addr);
1860 newFriend = linphone_friend_new_with_addr(url);
1861 linphone_core_add_friend(lc, newFriend);
1867 linphonec_friend_delete(LinphoneCore *lc, int num)
1869 const MSList *friend = linphone_core_get_friend_list(lc);
1872 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1876 linphone_core_remove_friend(lc, friend->data);
1884 for (i = 0 ; i < n ; i++)
1885 linphonec_friend_delete(lc, 0);
1889 linphonec_out("No such friend %u\n", num);
1894 linphonec_display_command_help(LPC_COMMAND *cmd)
1896 if ( cmd->doc ) linphonec_out ("%s\n", cmd->doc);
1897 else linphonec_out("%s\n", cmd->help);
1901 static int lpc_cmd_register(LinphoneCore *lc, char *args){
1905 LinphoneProxyConfig *cfg;
1910 /* it means that you want to register the default proxy */
1911 LinphoneProxyConfig *cfg=NULL;
1912 linphone_core_get_default_proxy(lc,&cfg);
1915 if(!linphone_proxy_config_is_registered(cfg)) {
1916 linphone_proxy_config_enable_register(cfg,TRUE);
1917 linphone_proxy_config_done(cfg);
1919 linphonec_out("default proxy already registered\n");
1922 linphonec_out("we do not have a default proxy\n");
1927 passwd[0]=proxy[0]=identity[0]='\0';
1928 sscanf(args,"%s %s %s",identity,proxy,passwd);
1929 if (proxy[0]=='\0' || identity[0]=='\0'){
1930 linphonec_out("Missing parameters, see help register\n");
1933 if (passwd[0]!='\0'){
1934 LinphoneAddress *from;
1935 LinphoneAuthInfo *info;
1936 if ((from=linphone_address_new(identity))!=NULL){
1938 snprintf(realm,sizeof(realm)-1,"\"%s\"",linphone_address_get_domain(from));
1939 info=linphone_auth_info_new(linphone_address_get_username(from),NULL,passwd,NULL,NULL);
1940 linphone_core_add_auth_info(lc,info);
1941 linphone_address_destroy(from);
1942 linphone_auth_info_destroy(info);
1945 elem=linphone_core_get_proxy_config_list(lc);
1947 cfg=(LinphoneProxyConfig*)elem->data;
1948 linphone_proxy_config_edit(cfg);
1950 else cfg=linphone_proxy_config_new();
1951 linphone_proxy_config_set_identity(cfg,identity);
1952 linphone_proxy_config_set_server_addr(cfg,proxy);
1953 linphone_proxy_config_enable_register(cfg,TRUE);
1954 if (elem) linphone_proxy_config_done(cfg);
1955 else linphone_core_add_proxy_config(lc,cfg);
1956 linphone_core_set_default_proxy(lc,cfg);
1960 static int lpc_cmd_unregister(LinphoneCore *lc, char *args){
1961 LinphoneProxyConfig *cfg=NULL;
1962 linphone_core_get_default_proxy(lc,&cfg);
1963 if (cfg && linphone_proxy_config_is_registered(cfg)) {
1964 linphone_proxy_config_edit(cfg);
1965 linphone_proxy_config_enable_register(cfg,FALSE);
1966 linphone_proxy_config_done(cfg);
1968 linphonec_out("unregistered\n");
1973 static int lpc_cmd_duration(LinphoneCore *lc, char *args){
1974 LinphoneCallLog *cl;
1975 const MSList *elem=linphone_core_get_call_logs(lc);
1976 for(;elem!=NULL;elem=elem->next){
1977 if (elem->next==NULL){
1978 cl=(LinphoneCallLog*)elem->data;
1979 linphonec_out("%i seconds\n",cl->duration);
1985 static int lpc_cmd_status(LinphoneCore *lc, char *args)
1987 LinphoneProxyConfig *cfg;
1989 if ( ! args ) return 0;
1990 linphone_core_get_default_proxy(lc,&cfg);
1991 if (strstr(args,"register"))
1995 if (linphone_proxy_config_is_registered(cfg)){
1996 linphonec_out("registered, identity=%s duration=%i\n",
1997 linphone_proxy_config_get_identity(cfg),
1998 linphone_proxy_config_get_expires(cfg));
1999 }else if (linphone_proxy_config_register_enabled(cfg)){
2000 linphonec_out("registered=-1\n");
2001 }else linphonec_out("registered=0\n");
2003 else linphonec_out("registered=0\n");
2005 else if (strstr(args,"autoanswer"))
2007 if (cfg && linphone_proxy_config_is_registered(cfg))
2008 linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer());
2009 else linphonec_out("unregistered\n");
2011 else if (strstr(args,"hook"))
2013 LinphoneCall *call=linphone_core_get_current_call (lc);
2014 LinphoneCallState call_state=LinphoneCallIdle;
2015 if (call) call_state=linphone_call_get_state(call);
2018 case LinphoneCallOutgoingInit:
2019 linphonec_out("hook=outgoing_init sip:%s\n",linphonec_get_callee());
2021 case LinphoneCallOutgoingProgress:
2022 linphonec_out("hook=dialing sip:%s\n",linphonec_get_callee());
2024 case LinphoneCallOutgoingRinging:
2025 linphonec_out("hook=ringing sip:%s\n",linphonec_get_callee());
2027 case LinphoneCallPaused:
2028 linphonec_out("hook=paused sip:%s\n",linphonec_get_callee());
2030 case LinphoneCallIdle:
2031 linphonec_out("hook=offhook\n");
2033 case LinphoneCallStreamsRunning:
2034 case LinphoneCallConnected:
2035 if (linphone_call_get_dir(call)==LinphoneCallOutgoing){
2036 linphonec_out("Call out, hook=%s duration=%i, muted=%s rtp-xmit-muted=%s\n", linphonec_get_callee(),
2037 linphone_core_get_current_call_duration(lc),
2038 linphone_core_is_mic_muted (lc) ? "yes" : "no",
2039 linphone_core_is_rtp_muted(lc) ? "yes" : "no");
2041 linphonec_out("hook=answered duration=%i %s\n" ,
2042 linphone_core_get_current_call_duration(lc), linphonec_get_caller());
2045 case LinphoneCallIncomingReceived:
2046 linphonec_out("Incoming call from %s\n",linphonec_get_caller());
2058 static int lpc_cmd_ports(LinphoneCore *lc, char *args)
2062 linphonec_out("sip port = %i\naudio rtp port = %i\nvideo rtp port = %i\n",
2063 linphone_core_get_sip_port(lc),
2064 linphone_core_get_audio_port(lc),
2065 linphone_core_get_video_port(lc));
2068 if (sscanf(args,"sip %i",&port)==1){
2069 linphonec_out("Setting sip port to %i\n",port);
2070 linphone_core_set_sip_port(lc,port);
2076 static int lpc_cmd_param(LinphoneCore *lc, char *args)
2078 char section[20], param[20], value[50];
2084 switch (sscanf(args,"%s %s %s",section,param,value)) {
2085 // case 1 might show all current settings under a section
2087 string = lp_config_get_string(linphone_core_get_config(lc), section, param, "(undef)");
2088 linphonec_out("current value: %s\n", string);
2091 if (lp_config_get_string(linphone_core_get_config(lc), section, param, NULL) != NULL) {
2092 lp_config_set_string(linphone_core_get_config(lc), section, param, value);
2093 // no indication of existence
2094 linphonec_out("updated value: %s\n", value);
2096 linphonec_out("only update of existing variables are allowed\n");
2105 static int lpc_cmd_speak(LinphoneCore *lc, char *args){
2114 if (!args) return 0;
2115 memset(voice,0,sizeof(voice));
2116 sscanf(args,"%s63",voice);
2117 sentence=args+strlen(voice);
2118 wavfile=tempnam("/tmp/","linphonec-espeak-");
2119 snprintf(cl,sizeof(cl),"espeak -v %s -s 100 -w %s --stdin",voice,wavfile);
2122 ms_error("Could not open pipe to espeak !");
2125 fprintf(file,"%s",sentence);
2126 status=pclose(file);
2127 if (WEXITSTATUS(status)==0){
2128 linphone_core_set_play_file(lc,wavfile);
2130 linphonec_out("espeak command failed.");
2133 linphonec_out("Sorry, this command is not implemented in windows version.");
2138 static int lpc_cmd_acodec(LinphoneCore *lc, char *args){
2139 return lpc_cmd_codec(AUDIO, lc, args);
2142 static int lpc_cmd_vcodec(LinphoneCore *lc, char *args){
2143 return lpc_cmd_codec(VIDEO, lc, args);
2146 static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args){
2151 if (!args) return 0;
2153 /* Isolate first and second arg */
2154 while(*ptr && !isspace(*ptr)) ++ptr;
2159 while(*arg2 && isspace(*arg2)) ++arg2;
2162 if (strcmp(arg1,"enable")==0)
2164 #ifdef HAVE_READLINE
2165 rl_inhibit_completion=1;
2167 if (!strcmp(arg2,"all")) linphonec_codec_enable(type,lc,-1);
2168 else linphonec_codec_enable(type,lc,atoi(arg2));
2169 #ifdef HAVE_READLINE
2170 rl_inhibit_completion=0;
2173 else if (strcmp(arg1,"list")==0)
2175 linphonec_codec_list(type,lc);
2177 else if (strcmp(arg1,"disable")==0)
2179 if (!strcmp(arg2,"all")) linphonec_codec_disable(type,lc,-1);
2180 else linphonec_codec_disable(type,lc,atoi(arg2));
2184 return 0; /* syntax error */
2190 static void linphonec_codec_list(int type, LinphoneCore *lc){
2193 const MSList *node=NULL;
2195 if (type == AUDIO) {
2196 node=linphone_core_get_audio_codecs(lc);
2197 } else if(type==VIDEO) {
2198 node=linphone_core_get_video_codecs(lc);
2201 for(;node!=NULL;node=ms_list_next(node)){
2202 pt=(PayloadType*)(node->data);
2203 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate,
2204 linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled");
2209 static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){
2212 const MSList *node=NULL;
2214 if (type == AUDIO) {
2215 node=linphone_core_get_audio_codecs(lc);
2216 } else if(type==VIDEO) {
2217 node=linphone_core_get_video_codecs(lc);
2220 for(;node!=NULL;node=ms_list_next(node)){
2221 if (index == sel_index || sel_index == -1) {
2222 pt=(PayloadType*)(node->data);
2223 linphone_core_enable_payload_type (lc,pt,TRUE);
2224 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled");
2230 static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){
2233 const MSList *node=NULL;
2235 if (type == AUDIO) {
2236 node=linphone_core_get_audio_codecs(lc);
2237 } else if(type==VIDEO) {
2238 node=linphone_core_get_video_codecs(lc);
2241 for(;node!=NULL;node=ms_list_next(node)){
2242 if (index == sel_index || sel_index == -1) {
2243 pt=(PayloadType*)(node->data);
2244 linphone_core_enable_payload_type (lc,pt,FALSE);
2245 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
2251 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
2255 LpConfig *config=linphone_core_get_config(lc);
2257 if (!args) return 0;
2259 /* Isolate first and second arg */
2260 while(*ptr && !isspace(*ptr)) ++ptr;
2265 while(*arg2 && isspace(*arg2)) ++arg2;
2268 if (strcmp(arg1,"on")==0){
2269 int delay, tail_len, frame_size;
2272 linphone_core_enable_echo_cancellation(lc,1);
2275 n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size);
2278 lp_config_set_int(config,"sound","ec_delay",delay);
2281 lp_config_set_int(config,"sound","ec_delay",delay);
2282 lp_config_set_int(config,"sound","ec_tail_len",tail_len);
2285 lp_config_set_int(config,"sound","ec_delay",delay);
2286 lp_config_set_int(config,"sound","ec_tail_len",tail_len);
2287 lp_config_set_int(config,"sound","ec_framesize",frame_size);
2291 else if (strcmp(arg1,"off")==0){
2292 linphone_core_enable_echo_cancellation(lc,0);
2294 else if (strcmp(arg1,"show")==0){
2295 linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",
2296 linphone_core_echo_cancellation_enabled(lc) ? "on" : "off",
2297 lp_config_get_int(config,"sound","ec_delay",0),
2298 lp_config_get_int(config,"sound","ec_tail_len",0),
2299 lp_config_get_int(config,"sound","ec_framesize",0));
2308 static int lpc_cmd_echolimiter(LinphoneCore *lc, char *args){
2310 if (strcmp(args,"on")==0){
2311 linphone_core_enable_echo_limiter (lc,TRUE);
2312 }else if (strcmp(args,"off")==0){
2313 linphone_core_enable_echo_limiter (lc,FALSE);
2316 linphonec_out("Echo limiter is now %s.\n",linphone_core_echo_limiter_enabled (lc) ? "on":"off");
2320 static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args)
2322 linphone_core_mute_mic(lc, 1);
2326 static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args){
2327 linphone_core_mute_mic(lc, 0);
2331 static int lpc_cmd_playback_gain(LinphoneCore *lc, char *args)
2334 linphone_core_set_playback_gain_db(lc, atof(args));
2340 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args)
2342 bool_t rtp_xmit_off=FALSE;
2346 if(strstr(args,"1"))rtp_xmit_off=TRUE;
2347 if(linphone_core_get_current_call (lc)==NULL)
2348 linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_xmit_off);
2350 linphonec_out("nortp-on-audio-mute: call in progress - cannot change state\n");
2352 rtp_xmit_off=linphone_core_get_rtp_no_xmit_on_audio_mute(lc);
2353 if (rtp_xmit_off) status="off";
2355 linphonec_out("rtp transmit %s when audio muted\n",status);
2359 #ifdef VIDEO_ENABLED
2360 static int _lpc_cmd_video_window(LinphoneCore *lc, char *args, bool_t is_preview){
2361 char subcommand[64];
2364 VideoParams *params=is_preview ? &lpc_preview_params : &lpc_video_params;
2366 if (!args) return 0;
2367 err=sscanf(args,"%s %i %i",subcommand,&a,&b);
2369 if (strcmp(subcommand,"pos")==0){
2370 if (err<3) return 0;
2373 params->refresh=TRUE;
2374 }else if (strcmp(subcommand,"size")==0){
2375 if (err<3) return 0;
2378 params->refresh=TRUE;
2379 }else if (strcmp(subcommand,"show")==0){
2381 params->refresh=TRUE;
2382 if (is_preview) linphone_core_enable_video_preview (lc,TRUE);
2383 }else if (strcmp(subcommand,"hide")==0){
2385 params->refresh=TRUE;
2386 if (is_preview) linphone_core_enable_video_preview (lc,FALSE);
2387 }else if (strcmp(subcommand,"id")==0){
2389 linphonec_out("vwindow id: 0x%x\n",is_preview ? linphone_core_get_native_preview_window_id (lc) :
2390 linphone_core_get_native_video_window_id (lc));
2392 } else if (err != 2) return 0;
2395 linphone_core_set_native_preview_window_id (lc,a);
2397 linphone_core_set_native_video_window_id(lc,a);
2398 }else if (is_preview==TRUE){
2399 if (strcmp(subcommand,"integrated")==0){
2400 linphone_core_use_preview_window (lc,FALSE);
2401 }else if (strcmp(subcommand,"standalone")==0){
2402 linphone_core_use_preview_window(lc,TRUE);
2409 static int lpc_cmd_video_window(LinphoneCore *lc, char *args){
2410 return _lpc_cmd_video_window(lc, args, FALSE);
2413 static int lpc_cmd_preview_window(LinphoneCore *lc, char *args){
2414 return _lpc_cmd_video_window(lc, args, TRUE);
2418 static void lpc_display_global_state(LinphoneCore *lc){
2419 linphonec_out("Global liblinphone state\n%s\n",
2420 linphone_global_state_to_string(linphone_core_get_global_state(lc)));
2423 static void lpc_display_call_states(LinphoneCore *lc){
2427 linphonec_out("Call states\n"
2428 "Id | Destination | State\n"
2429 "---------------------------------------------------------------\n");
2430 elem=linphone_core_get_calls(lc);
2432 linphonec_out("(empty)\n");
2434 for(;elem!=NULL;elem=elem->next){
2435 call=(LinphoneCall*)elem->data;
2436 bool_t in_conference=linphone_call_params_local_conference_mode(linphone_call_get_current_params(call));
2437 tmp=linphone_call_get_remote_address_as_string (call);
2438 linphonec_out("%-2i | %-35s | %s %s\n",(int)(long)linphone_call_get_user_pointer(call),
2439 tmp,linphone_call_state_to_string(linphone_call_get_state(call)),
2440 in_conference ? "(conferencing)" : "");
2446 static void lpc_display_proxy_states(LinphoneCore *lc){
2448 linphonec_out("Proxy registration states\n"
2449 " Identity | State\n"
2450 "------------------------------------------------------------\n");
2451 elem=linphone_core_get_proxy_config_list (lc);
2452 if (elem==NULL) linphonec_out("(empty)\n");
2454 for(;elem!=NULL;elem=elem->next){
2455 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
2456 linphonec_out("%-40s | %s\n",linphone_proxy_config_get_identity (cfg),
2457 linphone_registration_state_to_string(linphone_proxy_config_get_state(cfg)));
2462 static int lpc_cmd_states(LinphoneCore *lc, char *args){
2464 lpc_display_global_state(lc);
2465 lpc_display_call_states(lc);
2466 lpc_display_proxy_states(lc);
2469 if (strcmp(args,"global")==0){
2470 lpc_display_global_state(lc);
2473 if (strcmp(args,"proxies")==0){
2474 lpc_display_proxy_states(lc);
2477 if (strcmp(args,"calls")==0){
2478 lpc_display_call_states(lc);
2484 #ifdef VIDEO_ENABLED
2485 static int lpc_cmd_camera(LinphoneCore *lc, char *args){
2486 LinphoneCall *call=linphone_core_get_current_call(lc);
2487 bool_t activated=FALSE;
2489 if (linphone_core_video_enabled (lc)==FALSE){
2490 linphonec_out("Video is disabled, re-run linphonec with -V option.");
2495 if (strcmp(args,"on")==0)
2497 else if (strcmp(args,"off")==0)
2505 linphonec_camera_enabled=activated;
2507 if (linphonec_camera_enabled){
2508 linphonec_out("Camera is enabled. Video stream will be setup immediately for outgoing and incoming calls.\n");
2510 linphonec_out("Camera is disabled. Calls will be established with audio-only, with the possibility to later add video using 'camera on'.\n");
2513 const LinphoneCallParams *cp=linphone_call_get_current_params (call);
2515 linphone_call_enable_camera(call,activated);
2516 if ((activated && !linphone_call_params_video_enabled (cp))){
2517 /*update the call to add the video stream*/
2518 LinphoneCallParams *ncp=linphone_call_params_copy(cp);
2519 linphone_call_params_enable_video(ncp,TRUE);
2520 linphone_core_update_call(lc,call,ncp);
2521 linphone_call_params_destroy (ncp);
2522 linphonec_out("Trying to bring up video stream...\n");
2525 if (linphone_call_camera_enabled (call))
2526 linphonec_out("Camera is allowed for current call.\n");
2527 else linphonec_out("Camera is dis-allowed for current call.\n");
2532 static int lpc_cmd_snapshot(LinphoneCore *lc, char *args){
2534 if (!args) return 0;
2535 call=linphone_core_get_current_call(lc);
2537 linphone_call_take_video_snapshot(call,args);
2538 linphonec_out("Taking video snapshot in file %s\n", args);
2539 }else linphonec_out("There is no active call.\n");
2543 static int lpc_cmd_vfureq(LinphoneCore *lc, char *arg){
2545 call=linphone_core_get_current_call(lc);
2547 linphone_call_send_vfu_request(call);
2548 linphonec_out("VFU request sent\n");
2549 }else linphonec_out("There is no active call.\n");
2554 static int lpc_cmd_identify(LinphoneCore *lc, char *args){
2556 const char *remote_ua;
2558 call=linphone_core_get_current_call(lc);
2560 linphonec_out("There is currently running call. Specify call id.\n");
2564 call=linphonec_get_call(atoi(args));
2569 remote_ua=linphone_call_get_remote_user_agent(call);
2571 linphonec_out("Remote user agent string is: %s\n",remote_ua);
2576 static int lpc_cmd_ringback(LinphoneCore *lc, char *args){
2577 if (!args) return 0;
2578 if (strcmp(args,"disable")==0){
2579 linphone_core_set_remote_ringback_tone(lc,NULL);
2580 linphonec_out("Disabling ringback tone.\n");
2583 linphone_core_set_remote_ringback_tone (lc,args);
2584 linphonec_out("Using %s as ringback tone to be played to callers.",args);
2588 /***************************************************************************
2590 * Command table management funx
2592 ***************************************************************************/
2595 * Find a command given its name
2597 static LPC_COMMAND *
2598 lpc_find_command(const char *name)
2602 for (i=0; commands[i].name; ++i)
2604 if (strcmp(name, commands[i].name) == 0)
2605 return &commands[i];
2608 for (i=0; advanced_commands[i].name; ++i)
2610 if (strcmp(name, advanced_commands[i].name) == 0)
2611 return &advanced_commands[i];
2614 return (LPC_COMMAND *)NULL;
2618 /****************************************************************************
2620 * $Log: commands.c,v $
2621 * Revision 1.39 2008/07/03 15:08:34 smorlat
2622 * api cleanups, interface in progress.
2624 * Revision 1.38 2008/06/17 20:38:59 smorlat
2625 * added missing file.
2627 * Revision 1.37 2008/04/09 09:26:00 smorlat
2628 * merge various patches
2631 * Revision 1.36 2007/08/01 14:47:53 strk
2632 * * console/commands.c: Clean up commands 'nat', 'stun'
2633 * and 'firewall' to be more intuitive.
2635 * Revision 1.35 2007/06/27 09:01:25 smorlat
2636 * logging improvements.
2638 * Revision 1.34 2007/02/20 10:17:13 smorlat
2639 * linphonec friends patch2
2641 * Revision 1.31 2006/09/22 07:22:47 smorlat
2642 * linphonecore api changes.
2644 * Revision 1.30 2006/09/08 15:32:57 smorlat
2645 * support for using files instead of soundcard (used by linphonec only)
2647 * Revision 1.29 2006/08/28 14:29:07 smorlat
2650 * Revision 1.28 2006/08/21 12:49:59 smorlat
2651 * merged several little patches.
2653 * Revision 1.27 2006/07/17 18:45:00 smorlat
2654 * support for several event queues in ortp.
2655 * glib dependency removed from coreapi/ and console/
2657 * Revision 1.26 2006/04/14 15:16:36 smorlat
2658 * soundcard use did nothing !
2660 * Revision 1.25 2006/04/06 20:09:33 smorlat
2661 * add linphonec command to see and select sound devices.
2663 * Revision 1.24 2006/03/04 11:17:10 smorlat
2664 * mediastreamer2 in progress.
2666 * Revision 1.23 2006/02/20 21:14:01 strk
2667 * Handled syntax errors with 'friend' command
2669 * Revision 1.22 2006/02/20 10:20:29 strk
2670 * Added substring-based filter support for command 'friend list'
2672 * Revision 1.21 2006/02/02 15:39:18 strk
2673 * - Added 'friend list' and 'friend call' commands
2674 * - Allowed for multiple DTFM send in a single line
2675 * - Added status-specific callback (bare version)
2677 * Revision 1.20 2006/01/26 11:54:34 strk
2678 * More robust 'nat' command handler (strip blanks in args)
2680 * Revision 1.19 2006/01/26 09:48:05 strk
2681 * Added limits.h include
2683 * Revision 1.18 2006/01/26 02:18:05 strk
2684 * Added new commands 'nat use' and 'nat unuse'.
2685 * These will required a pending patch to linphonecore.c
2688 * Revision 1.17 2006/01/20 14:12:33 strk
2689 * Added linphonec_init() and linphonec_finish() functions.
2690 * Handled SIGINT and SIGTERM to invoke linphonec_finish().
2691 * Handling of auto-termination (-t) moved to linphonec_finish().
2692 * Reworked main (input read) loop to not rely on 'terminate'
2693 * and 'run' variable (dropped). configfile_name allocated on stack
2694 * using PATH_MAX limit. Changed print_usage signature to allow
2695 * for an exit_status specification.
2697 * Revision 1.16 2006/01/18 09:25:32 strk
2698 * Command completion inhibited in proxy addition and auth request prompts.
2699 * Avoided use of linphonec_readline's internal filename completion.
2701 * Revision 1.15 2006/01/14 13:29:32 strk
2702 * Reworked commands interface to use a table structure,
2703 * used by command line parser and help function.
2704 * Implemented first level of completion (commands).
2705 * Added notification of invalid "answer" and "terminate"
2706 * commands (no incoming call, no active call).
2707 * Forbidden "call" intialization when a call is already active.
2708 * Cleaned up all commands, adding more feedback and error checks.
2710 * Revision 1.14 2006/01/13 13:00:29 strk
2711 * Added linphonec.h. Code layout change (added comments, forward decl,
2712 * globals on top, copyright notices and Logs). Handled out-of-memory
2713 * condition on history management. Removed assumption on sizeof(char).
2714 * Fixed bug in authentication prompt (introduced by linphonec_readline).
2715 * Added support for multiple authentication requests (up to MAX_PENDING_AUTH).
2718 ****************************************************************************/