Commit 8bc6a662 authored by smorlat's avatar smorlat

merge patch fixing a portaudio plugin bug

tcp access to linphonec shell is enabled.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@239 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent e6df3d79
linphone-3.1.0 -- January 19, 2009
* linphone can now send large video pictures: up to SVGA, configurable via the user interface
* automatic rescaling of the video windows to the video size of incoming stream
* improved webcam support on windows
* plenty of user interface cosmetic improvements
* set a user friendly gtk theme by default on windows
* linphonec can compile and work without libreadline
* enable translations on windows
* bugfixing as usual
linphone-3.0.0 -- October 13, 2008
* new graphical interface based on Glade/Gtk
* systray icon
......
......@@ -11,27 +11,32 @@ INCLUDES = \
bin_PROGRAMS = linphonec sipomatic
bin_PROGRAMS = linphonec sipomatic linphonecsh
linphonec_SOURCES = linphonec.c linphonec.h commands.c
linphonec_LDADD = $(top_builddir)/coreapi/liblinphone.la $(READLINE_LIBS) $(OSIP_LIBS)
linphonec_LDADD = $(top_builddir)/coreapi/liblinphone.la $(READLINE_LIBS) \
$(top_builddir)/mediastreamer2/src/libmediastreamer.la \
$(ORTP_LIBS) \
$(SPEEX_LIBS) \
$(OSIP_LIBS)
sipomatic_SOURCES=\
sipomatic.c sipomatic.h
sipomatic_LDADD= $(INTLLIBS) \
$(top_builddir)/coreapi/liblinphone.la \
$(top_builddir)/coreapi/liblinphone.la \
$(top_builddir)/mediastreamer2/src/libmediastreamer.la \
$(ORTP_LIBS) \
$(SPEEX_LIBS) \
$(OSIP_LIBS)
linphonecsh_SOURCES = shell.c
linphonecsh_LDADD = $(ORTP_LIBS)
endif
AM_CFLAGS=$(STRICT_OPTIONS) -DENABLE_TRACE -D_ORTP_SOURCE $(VIDEO_CFLAGS) $(READLINE_CFLAGS) $(OSIP_CFLAGS)
AM_LDFLAGS= $(top_builddir)/mediastreamer2/src/libmediastreamer.la \
$(ORTP_LIBS) \
$(SPEEX_LIBS) \
$(OSIP_LIBS)
......@@ -5,21 +5,21 @@
* Copyright (C) 2006 Sandro Santilli <strk@keybit.net>
* Copyright (C) 2004 Simon MORLAT <simon.morlat@linphone.org>
*
****************************************************************************
****************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
****************************************************************************/
......@@ -74,6 +74,10 @@ static int linphonec_friend_delete(LinphoneCore *lc, int num);
/* Command table management */
static LPC_COMMAND *lpc_find_command(const char *name);
void linphonec_out(const char *fmt,...);
/***************************************************************************
*
* Global variables
......@@ -199,13 +203,13 @@ linphonec_parse_command_line(LinphoneCore *lc, char *cl)
cmd=lpc_find_command(cl);
if ( !cmd )
{
printf("'%s': Cannot understand this.\n", cl);
linphonec_out("'%s': Cannot understand this.\n", cl);
return 1;
}
if ( ! cmd->func(lc, args) )
{
printf("Syntax error.\n");
linphonec_out("Syntax error.\n");
linphonec_display_command_help(cmd);
}
......@@ -262,18 +266,18 @@ lpc_cmd_help(LinphoneCore *lc, char *arg)
if (!arg || !*arg)
{
printf("Commands are:\n");
printf("---------------------------\n");
linphonec_out("Commands are:\n");
linphonec_out("---------------------------\n");
while (commands[i].help)
{
printf("%10.10s\t%s\n", commands[i].name,
linphonec_out("%10.10s\t%s\n", commands[i].name,
commands[i].help);
i++;
}
printf("---------------------------\n");
printf("Type 'help <command>' for more details.\n");
linphonec_out("---------------------------\n");
linphonec_out("Type 'help <command>' for more details.\n");
return 1;
}
......@@ -281,7 +285,7 @@ lpc_cmd_help(LinphoneCore *lc, char *arg)
cmd=lpc_find_command(arg);
if ( !cmd )
{
printf("No such command.\n");
linphonec_out("No such command.\n");
return 1;
}
......@@ -300,13 +304,13 @@ lpc_cmd_call(LinphoneCore *lc, char *args)
if ( lc->call != NULL )
{
printf("Terminate current call first.\n");
linphonec_out("Terminate current call first.\n");
}
else
{
if ( -1 == linphone_core_invite(lc, args) )
{
printf("Error from linphone_core_invite.\n");
linphonec_out("Error from linphone_core_invite.\n");
}
else
{
......@@ -322,7 +326,7 @@ lpc_cmd_refer(LinphoneCore *lc, char *args)
if (args)
linphone_core_refer(lc, args);
else{
printf("refer needs an argument\n");
linphonec_out("refer needs an argument\n");
}
return 1;
}
......@@ -332,7 +336,7 @@ lpc_cmd_terminate(LinphoneCore *lc, char *args)
{
if ( -1 == linphone_core_terminate_call(lc, NULL) )
{
printf("No active call.\n");
linphonec_out("No active call.\n");
}
return 1;
}
......@@ -342,7 +346,7 @@ lpc_cmd_answer(LinphoneCore *lc, char *args)
{
if ( -1 == linphone_core_accept_call(lc, NULL) )
{
printf("No incoming call.\n");
linphonec_out("No incoming call.\n");
}
return 1;
}
......@@ -370,7 +374,7 @@ lpc_cmd_nat(LinphoneCore *lc, char *args)
nat = linphone_core_get_nat_address(lc);
use = linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_NAT_ADDRESS;
printf("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
linphonec_out("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
return 1;
}
......@@ -391,7 +395,7 @@ lpc_cmd_stun(LinphoneCore *lc, char *args)
stun = linphone_core_get_stun_server(lc);
use = linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_STUN;
printf("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
linphonec_out("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
return 1;
}
......@@ -414,7 +418,7 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
setting = linphone_core_get_stun_server(lc);
if ( ! setting )
{
printf("No stun server address is defined, use 'stun <address>' first");
linphonec_out("No stun server address is defined, use 'stun <address>' first");
return 1;
}
linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN);
......@@ -424,7 +428,7 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
setting = linphone_core_get_nat_address(lc);
if ( ! setting )
{
printf("No nat address is defined, use 'nat <address>' first");
linphonec_out("No nat address is defined, use 'nat <address>' first");
return 1;
}
linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS);
......@@ -434,13 +438,13 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
switch(linphone_core_get_firewall_policy(lc))
{
case LINPHONE_POLICY_NO_FIREWALL:
printf("No firewall\n");
linphonec_out("No firewall\n");
break;
case LINPHONE_POLICY_USE_STUN:
printf("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
linphonec_out("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
break;
case LINPHONE_POLICY_USE_NAT_ADDRESS:
printf("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
break;
}
return 1;
......@@ -496,7 +500,7 @@ lpc_cmd_friend(LinphoneCore *lc, char *args)
if ( ! *args ) return 0;
friend_num = strtol(args, NULL, 10);
if ( errno == ERANGE ) {
printf("Invalid friend number\n");
linphonec_out("Invalid friend number\n");
return 0;
}
linphonec_friend_call(lc, friend_num);
......@@ -516,7 +520,7 @@ lpc_cmd_friend(LinphoneCore *lc, char *args)
{
friend_num = strtol(args, NULL, 10);
if ( errno == ERANGE ) {
printf("Invalid friend number\n");
linphonec_out("Invalid friend number\n");
return 0;
}
}
......@@ -614,23 +618,23 @@ lpc_cmd_proxy(LinphoneCore *lc, char *args)
{
proxynum=atoi(arg2);
if ( linphonec_proxy_use(lc, proxynum) )
printf("Default proxy set to %d.\n", proxynum);
linphonec_out("Default proxy set to %d.\n", proxynum);
}
else
{
proxynum=linphone_core_get_default_proxy(lc, NULL);
if ( proxynum == -1 ) printf("No default proxy.\n");
else printf("Current default proxy is %d.\n", proxynum);
if ( proxynum == -1 ) linphonec_out("No default proxy.\n");
else linphonec_out("Current default proxy is %d.\n", proxynum);
}
}
else if (strcmp(arg1, "unuse")==0)
{
linphone_core_set_default_proxy(lc, NULL);
printf("Use no proxy.\n");
linphonec_out("Use no proxy.\n");
}
else
{
printf("Syntax error - see 'help proxy'\n");
linphonec_out("Syntax error - see 'help proxy'\n");
}
return 1;
......@@ -644,7 +648,7 @@ lpc_cmd_call_logs(LinphoneCore *lc, char *args)
{
LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
char *str=linphone_call_log_to_str(cl);
printf("%s\n",str);
linphonec_out("%s\n",str);
ms_free(str);
}
return 1;
......@@ -655,27 +659,27 @@ lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
{
if ( ! arg1 )
{
printf("Syntax error - see 'help ipv6'\n");
linphonec_out("Syntax error - see 'help ipv6'\n");
return 1;
}
if (strcmp(arg1,"status")==0)
{
printf("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
linphonec_out("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
}
else if (strcmp(arg1,"enable")==0)
{
linphone_core_enable_ipv6(lc,TRUE);
printf("ipv6 use enabled.\n");
linphonec_out("ipv6 use enabled.\n");
}
else if (strcmp(arg1,"disable")==0)
{
linphone_core_enable_ipv6(lc,FALSE);
printf("ipv6 use disabled.\n");
linphonec_out("ipv6 use disabled.\n");
}
else
{
printf("Syntax error - see 'help ipv6'\n");
linphonec_out("Syntax error - see 'help ipv6'\n");
}
return 1;
}
......@@ -683,13 +687,13 @@ lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
static int lpc_cmd_soundcard(LinphoneCore *lc, char *cmd){
int i;
if (cmd==NULL){
printf("Syntax error - see 'help soundcard'\n");
linphonec_out("Syntax error - see 'help soundcard'\n");
return 1;
}
if (strcmp(cmd,"list")==0){
const char **dev=linphone_core_get_sound_devices(lc);
for(i=0;dev[i]!=NULL;i++){
printf("%i: %s\n",i,dev[i]);
linphonec_out("%i: %s\n",i,dev[i]);
}
return 1;
}else{
......@@ -699,7 +703,7 @@ static int lpc_cmd_soundcard(LinphoneCore *lc, char *cmd){
int n=sscanf(cmd,"%s %s",tmp,card);
if (n==2 && strcmp(tmp,"use")==0){
if (strcmp(card,"files")==0) {
printf("Using wav files instead of soundcard.\n");
linphonec_out("Using wav files instead of soundcard.\n");
linphone_core_use_files(lc,TRUE);
return 1;
}else{
......@@ -710,15 +714,15 @@ static int lpc_cmd_soundcard(LinphoneCore *lc, char *cmd){
linphone_core_set_ringer_device(lc,dev[i]);
linphone_core_set_playback_device(lc,dev[i]);
linphone_core_set_capture_device(lc,dev[i]);
printf("Using sound device %s\n",dev[i]);
linphonec_out("Using sound device %s\n",dev[i]);
return 1;
}
}
printf("no such sound device\n");
linphonec_out("no such sound device\n");
return 1;
}
}
printf("Syntax error - see 'help soundcard'\n");
linphonec_out("Syntax error - see 'help soundcard'\n");
}
return 1;
}
......@@ -736,7 +740,7 @@ linphonec_proxy_add(LinphoneCore *lc)
bool_t enable_register=FALSE;
LinphoneProxyConfig *cfg;
printf("Adding new proxy setup. Hit ^D to abort.\n");
linphonec_out("Adding new proxy setup. Hit ^D to abort.\n");
/*
* SIP Proxy address
......@@ -747,7 +751,7 @@ linphonec_proxy_add(LinphoneCore *lc)
char *clean;
if ( ! input ) {
printf("Aborted.\n");
linphonec_out("Aborted.\n");
return;
}
......@@ -761,7 +765,7 @@ linphonec_proxy_add(LinphoneCore *lc)
cfg=linphone_proxy_config_new();
if (linphone_proxy_config_set_server_addr(cfg,clean)<0)
{
printf("Invalid sip address (sip:sip.domain.tld).\n");
linphonec_out("Invalid sip address (sip:sip.domain.tld).\n");
free(input);
linphone_proxy_config_destroy(cfg);
continue;
......@@ -779,7 +783,7 @@ linphonec_proxy_add(LinphoneCore *lc)
char *clean;
if ( ! input ) {
printf("Aborted.\n");
linphonec_out("Aborted.\n");
linphone_proxy_config_destroy(cfg);
return;
}
......@@ -794,7 +798,7 @@ linphonec_proxy_add(LinphoneCore *lc)
linphone_proxy_config_set_identity(cfg, clean);
if ( ! cfg->reg_identity )
{
printf("Invalid identity (sip:name@sip.domain.tld).\n");
linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
free(input);
continue;
}
......@@ -811,7 +815,7 @@ linphonec_proxy_add(LinphoneCore *lc)
char *clean;
if ( ! input ) {
printf("Aborted.\n");
linphonec_out("Aborted.\n");
linphone_proxy_config_destroy(cfg);
return;
}
......@@ -826,7 +830,7 @@ linphonec_proxy_add(LinphoneCore *lc)
if ( ! strcmp(clean, "yes") ) enable_register=TRUE;
else if ( ! strcmp(clean, "no") ) enable_register=FALSE;
else {
printf("Please answer with 'yes' or 'no'\n");
linphonec_out("Please answer with 'yes' or 'no'\n");
free(input);
continue;
}
......@@ -847,7 +851,7 @@ linphonec_proxy_add(LinphoneCore *lc)
" in seconds (default is 600): ");
if ( ! input ) {
printf("Aborted.\n");
linphonec_out("Aborted.\n");
linphone_proxy_config_destroy(cfg);
return;
}
......@@ -855,13 +859,13 @@ linphonec_proxy_add(LinphoneCore *lc)
expires=strtol(input, (char **)NULL, 10);
if ( expires == LONG_MIN || expires == LONG_MAX )
{
printf("Invalid value: %s\n", strerror(errno));
linphonec_out("Invalid value: %s\n", strerror(errno));
free(input);
continue;
}
linphone_proxy_config_expires(cfg, expires);
printf("Expiration: %d seconds\n", cfg->expires);
linphonec_out("Expiration: %d seconds\n", cfg->expires);
free(input);
break;
......@@ -877,7 +881,7 @@ linphonec_proxy_add(LinphoneCore *lc)
char *clean;
if ( ! input ) {
printf("Aborted.\n");
linphonec_out("Aborted.\n");
linphone_proxy_config_destroy(cfg);
return;
}
......@@ -886,14 +890,14 @@ linphonec_proxy_add(LinphoneCore *lc)
clean=lpc_strip_blanks(input);
if ( ! *clean ) {
free(input);
printf("No route specified.\n");
linphonec_out("No route specified.\n");
break;
}
linphone_proxy_config_set_route(cfg, clean);
if ( ! cfg->reg_route )
{
printf("Invalid route.\n");
linphonec_out("Invalid route.\n");
free(input);
continue;
}
......@@ -910,14 +914,14 @@ linphonec_proxy_add(LinphoneCore *lc)
char *input;
char *clean;
printf("--------------------------------------------\n");
linphonec_out("--------------------------------------------\n");
linphonec_proxy_display(cfg);
printf("--------------------------------------------\n");
linphonec_out("--------------------------------------------\n");
input=linphonec_readline("Accept the above proxy configuration (yes/no) ?: ");
if ( ! input ) {
printf("Aborted.\n");
linphonec_out("Aborted.\n");
linphone_proxy_config_destroy(cfg);
return;
}
......@@ -932,13 +936,13 @@ linphonec_proxy_add(LinphoneCore *lc)
if ( ! strcmp(clean, "yes") ) break;
else if ( ! strcmp(clean, "no") )
{
printf("Declined.\n");
linphonec_out("Declined.\n");
linphone_proxy_config_destroy(cfg);
free(input);
return;
}
printf("Please answer with 'yes' or 'no'\n");
linphonec_out("Please answer with 'yes' or 'no'\n");
free(input);
continue;
}
......@@ -949,13 +953,13 @@ linphonec_proxy_add(LinphoneCore *lc)
/* automatically set the last entered proxy as the default one */
linphone_core_set_default_proxy(lc,cfg);
printf("Proxy added.\n");
linphonec_out("Proxy added.\n");
}
static void
linphonec_proxy_display(LinphoneProxyConfig *cfg)
{
printf("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\n",
linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\n",
cfg->reg_proxy,
(cfg->reg_route!=NULL)?cfg->reg_route:"",
(cfg->reg_identity!=NULL)?cfg->reg_identity:"",
......@@ -973,9 +977,9 @@ linphonec_proxy_list(LinphoneCore *lc)
proxies=linphone_core_get_proxy_config_list(lc);
for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){
if (n==def)
printf("****** Proxy %i - this is the default one - *******\n",n);
linphonec_out("****** Proxy %i - this is the default one - *******\n",n);
else
printf("****** Proxy %i *******\n",n);
linphonec_out("****** Proxy %i *******\n",n);
linphonec_proxy_display((LinphoneProxyConfig*)proxies->data);
}
}
......@@ -988,11 +992,11 @@ linphonec_proxy_remove(LinphoneCore *lc, int index)
proxies=linphone_core_get_proxy_config_list(lc);
cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
if (cfg==NULL){
printf("No such proxy.\n");
linphonec_out("No such proxy.\n");
return;
}
linphone_core_remove_proxy_config(lc,cfg);
printf("Proxy %s removed.\n", cfg->reg_proxy);
linphonec_out("Proxy %s removed.\n", cfg->reg_proxy);
linphone_proxy_config_destroy(cfg);
}
......@@ -1004,7 +1008,7 @@ linphonec_proxy_use(LinphoneCore *lc, int index)
proxies=linphone_core_get_proxy_config_list(lc);
cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
if (cfg==NULL){
printf("No such proxy (try 'proxy list').");
linphonec_out("No such proxy (try 'proxy list').");
return 0;
}
linphone_core_set_default_proxy(lc,cfg);
......@@ -1018,8 +1022,8 @@ linphonec_friend_display(LinphoneFriend *fr)
char *addr = linphone_friend_get_addr(fr);
//char *url = linphone_friend_get_url(fr);
printf("name: %s\n", name);
printf("address: %s\n", addr);
linphonec_out("name: %s\n", name);
linphonec_out("address: %s\n", addr);
}
static int
......@@ -1040,7 +1044,7 @@ linphonec_friend_list(LinphoneCore *lc, char *pat)
char *name = linphone_friend_get_name(friend->data);
if ( ! strstr(name, pat) ) continue;
}
printf("****** Friend %i *******\n",n);
linphonec_out("****** Friend %i *******\n",n);
linphonec_friend_display((LinphoneFriend*)friend->data);
}
......@@ -1062,7 +1066,7 @@ linphonec_friend_call(LinphoneCore *lc, unsigned int num)
return lpc_cmd_call(lc, addr);
}
}
printf("No such friend %u\n", num);
linphonec_out("No such friend %u\n", num);
return 1;
}
......@@ -1102,15 +1106,15 @@ linphonec_friend_delete(LinphoneCore *lc, int num)
return 0;
}
printf("No such friend %u\n", num);
linphonec_out("No such friend %u\n", num);
return 1;
}
static void
linphonec_display_command_help(LPC_COMMAND *cmd)
{
if ( cmd->doc ) printf ("%s\n", cmd->doc);
else printf("%s\n", cmd->help);
if ( cmd->doc ) linphonec_out ("%s\n", cmd->doc);
else linphonec_out("%s\n", cmd->help);
}
/***************************************************************************
......
......@@ -6,21 +6,21 @@
* Copyright (C) 2002 Florian Winterstein <flox@gmx.net>
* Copyright (C) 2000 Simon MORLAT <simon.morlat@free.fr>
*
****************************************************************************
****************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
****************************************************************************/
......@@ -32,6 +32,7 @@
#include <signal.h>
#include <limits.h>
#include <ctype.h>
#include <linphonecore.h>
#include "linphonec.h"
......@@ -39,6 +40,16 @@
#include "config.h"
#endif
#ifdef WIN32
#include <ws2tcpip.h>
#include <ctype.h>
#include <conio.h>
#else
#include <sys/socket.h>
#include <netdb.h>
#endif
#ifdef HAVE_GETTEXT
#include <libintl.h>
#ifndef _
......@@ -48,6 +59,8 @@
#define _(something) (something)
#endif
#define DEFAULT_TCP_PORT 32333
/***************************************************************************
*
* Types
......@@ -117,11 +130,13 @@ static bool_t vcap_enabled=FALSE;
static bool_t display_enabled=FALSE;
static bool_t preview_enabled=FALSE;
static bool_t show_general_state=FALSE;
static int tcp_port=0; /* see --tcp: tcp port to listen for commands */
LPC_AUTH_STACK auth_stack;
static int trace_level = 0;
static char *logfile_name = NULL;
static char configfile_name[PATH_MAX];
static char *sipAddr = NULL; /* for autocall */
static ortp_socket_t client_sock=-1;
char prompt[PROMPT_MAX_LEN];
LinphoneCoreVTable linphonec_vtable = {
......@@ -350,6 +365,76 @@ static void start_prompt_reader(void){
ortp_thread_create(&th,NULL,prompt_reader_thread,NULL);
}
static ortp_socket_t create_server_socket(int port){
ortp_socket_t server_sock;
char service[12];
/*setup the server socket */
struct addrinfo *ai=NULL;
struct addrinfo hints;
memset(&hints,0,sizeof(hints));
hints.ai_family=AF_INET;
snprintf(service,sizeof(service),"%i",port);
getaddrinfo("127.0.0.1",service,&hints,&ai);
if (ai==NULL){
fprintf(stderr,"getaddrinfo failed on port %s",service);
exit(-1);
}
server_sock=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
if (bind(server_sock,ai->ai_addr,ai->ai_addrlen)!=0){
fprintf(stderr,"Failed to bind command socket.");
exit(-1);
}
listen(server_sock,1);
return server_sock;
}
static void *tcp_thread(void*p){
char tmp[250];
ortp_socket_t server_sock;
struct sockaddr_storage ss;
socklen_t ssize;
bool_t run=TRUE;
server_sock=create_server_socket(tcp_port);
if (server_sock==-1) return NULL;
while(run){
while(client_sock!=-1){ /*sleep until the last command is finished*/
#ifndef WIN32
usleep(20000);
#else
Sleep(20);
#endif
}
ssize=sizeof(ss);
if ((client_sock=accept(server_sock,(struct sockaddr*)&ss,&ssize))!=-1){
int len;
/*now read from the client */
if ((len=recv(client_sock,tmp,sizeof(tmp)-1,0))>0){
ortp_mutex_lock(&prompt_mutex);
tmp[len]='\0';
strcpy(received_prompt,tmp);
if (strcmp(received_prompt,"quit")==0) run=FALSE;
printf("Receiving command '%s'\n",received_prompt);fflush(stdout);
have_prompt=TRUE;
ortp_mutex_unlock(&prompt_mutex);
}else{
printf("read nothing\n");fflush(stdout);
close_socket(client_sock);
client_sock=-1;
}