Commit 27d10bbe authored by jehan's avatar jehan

Merge branch 'dev_sal' of belledonne-communications.com:linphone-private into dev_sal

parents 00eaddcf 8e675c90
This diff is collapsed.
......@@ -449,6 +449,7 @@ typedef struct _LinphoneCore LinphoneCore;
* In case of false, network state must be communicate to linphone core with method linphone_core_
*/
bool_t auto_net_state_mon;
bool_t network_reachable;
/* THE main API */
......
......@@ -193,7 +193,7 @@ static int lookup_buddy(SipSetupContext *ctx, BLReq *req){
LpConfig *config=linphone_core_get_config(lc);
const char *identity=linphone_proxy_config_get_identity(cfg);
const char *url=lp_config_get_string(config,"BuddyLookup","url",NULL);
LinphoneAuthInfo *aa;
const LinphoneAuthInfo *aa;
SoupMessage *sm;
LinphoneAddress *from;
......
......@@ -388,6 +388,7 @@ struct _LinphoneCore
bool_t bl_refresh;
bool_t preview_finished;
bool_t auto_net_state_mon;
bool_t network_reachable;
};
#endif /* _PRIVATE_H */
......@@ -634,11 +634,13 @@ SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg){
}
void linphone_proxy_config_update(LinphoneProxyConfig *cfg){
LinphoneCore *lc=cfg->lc;
if (cfg->commit){
if (cfg->type && cfg->ssctx==NULL){
linphone_proxy_config_activate_sip_setup(cfg);
}
linphone_proxy_config_register(cfg);
if (lc->sip_conf.register_only_when_network_is_up || lc->network_reachable)
linphone_proxy_config_register(cfg);
cfg->commit=FALSE;
}
}
......
......@@ -21,6 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "offeranswer.h"
static void _osip_list_set_empty(osip_list_t *l, void (*freefunc)(void*)){
void *data;
while((data=osip_list_get(l,0))!=NULL){
osip_list_remove(l,0);
freefunc(data);
}
}
void sal_get_default_local_ip(Sal *sal, int address_family,char *ip, size_t iplen){
if (eXosip_guess_localip(address_family,ip,iplen)<0){
/*default to something */
......@@ -183,6 +192,7 @@ void *sal_get_user_pointer(const Sal *sal){
}
void sal_masquerade(Sal *ctx, const char *ip){
ms_message("Masquerading SIP with %s",ip);
eXosip_set_option(EXOSIP_OPT_SET_IPV4_FOR_GATEWAY,ip);
}
......@@ -259,6 +269,25 @@ MSList *sal_get_pending_auths(Sal *sal){
return ms_list_copy(sal->pending_auths);
}
static int extract_received_rport(osip_message_t *msg, const char **received, int *rportval){
osip_via_t *via=NULL;
osip_generic_param_t *param=NULL;
const char *rport;
osip_message_get_via(msg,0,&via);
if (!via) return -1;
osip_via_param_get_byname(via,"rport",&param);
if (param) {
rport=param->gvalue;
if (rport && rport[0]!='\0') *rportval=atoi(rport);
else *rportval=5060;
}
param=NULL;
osip_via_param_get_byname(via,"received",&param);
if (param) *received=param->gvalue;
else return -1;
return 0;
}
static void set_sdp(osip_message_t *sip,sdp_message_t *msg){
int sdplen;
......@@ -329,7 +358,7 @@ int sal_call(SalOp *h, const char *from, const char *to){
return -1;
}
if (h->base.contact){
osip_list_special_free(&invite->contacts,(void (*)(void*))osip_contact_free);
_osip_list_set_empty(&invite->contacts,(void (*)(void*))osip_contact_free);
osip_message_set_contact(invite,h->base.contact);
}
if (h->base.root->session_expires!=0){
......@@ -374,7 +403,7 @@ int sal_call_accept(SalOp * h){
}
if (contact) {
osip_list_special_free(&msg->contacts,(void (*)(void*))osip_contact_free);
_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
osip_message_set_contact(msg,contact);
}
......@@ -542,7 +571,7 @@ static void handle_reinvite(Sal *sal, eXosip_event_t *ev){
if (op->supports_session_timers) osip_message_set_supported(msg, "timer");
}
if (op->base.contact){
osip_list_special_free(&msg->contacts,(void (*)(void*))osip_contact_free);
_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
osip_message_set_contact(msg,op->base.contact);
}
if (sdp){
......@@ -586,6 +615,9 @@ static void handle_ack(Sal *sal, eXosip_event_t *ev){
static int call_proceeding(Sal *sal, eXosip_event_t *ev){
SalOp *op=(SalOp*)ev->external_reference;
const char *received;
int rport;
if (op==NULL) {
ms_warning("This call has been canceled.");
eXosip_lock();
......@@ -595,6 +627,24 @@ static int call_proceeding(Sal *sal, eXosip_event_t *ev){
}
op->did=ev->did;
op->tid=ev->tid;
/* update contact if received and rport are set by the server */
if (extract_received_rport(ev->response,&received,&rport)==0){
const char *contact=sal_op_get_contact(op);
if (!contact){
/*no contact given yet, use from instead*/
contact=sal_op_get_from(op);
}
if (contact){
SalAddress *addr=sal_address_new(contact);
char *tmp;
sal_address_set_domain(addr,received);
sal_address_set_port_int(addr,rport);
tmp=sal_address_as_string(addr);
ms_message("Contact address automatically updated to %s for this call",tmp);
sal_op_set_contact(op,tmp);
ms_free(tmp);
}
}
return 0;
}
......@@ -617,6 +667,7 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){
sdp_message_t *sdp;
osip_message_t *msg=NULL;
SalOp *op;
const char *contact;
op=(SalOp*)ev->external_reference;
if (op==NULL){
ms_error("A closed call is accepted ?");
......@@ -630,6 +681,11 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){
if (op->base.local_media) sdp_process(op);
}
eXosip_call_build_ack(ev->did,&msg);
contact=sal_op_get_contact(op);
if (contact) {
_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
osip_message_set_contact(msg,contact);
}
if (op->sdp_answer)
set_sdp(msg,op->sdp_answer);
eXosip_call_send_ack(ev->did,msg);
......@@ -998,34 +1054,23 @@ static void other_request(Sal *sal, eXosip_event_t *ev){
static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *orig_request, osip_message_t *last_answer){
osip_message_t *msg;
const char *rport,*received;
osip_via_t *via=NULL;
osip_generic_param_t *param=NULL;
const char *received;
int rport;
osip_contact_t *ctt=NULL;
char *tmp;
char port[20];
osip_message_get_via(last_answer,0,&via);
if (!via) return FALSE;
osip_via_param_get_byname(via,"rport",&param);
if (param) rport=param->gvalue;
else return FALSE;
param=NULL;
osip_via_param_get_byname(via,"received",&param);
if (param) received=param->gvalue;
else return FALSE;
if (extract_received_rport(last_answer,&received,&rport)==-1) return FALSE;
osip_message_get_contact(orig_request,0,&ctt);
if (strcmp(ctt->url->host,received)==0){
/*ip address matches, check ports*/
const char *contact_port=ctt->url->port;
const char *via_rport=rport;
if (via_rport==NULL || strlen(via_rport)>0)
via_rport="5060";
if (contact_port==NULL || strlen(contact_port)>0)
if (contact_port==NULL || contact_port[0]=='\0')
contact_port="5060";
if (strcmp(contact_port,via_rport)==0){
if (atoi(contact_port)==rport){
ms_message("Register has up to date contact, doing nothing.");
return FALSE;
}else ms_message("ports do not match, need to update the register (%s <> %s)", contact_port,via_rport);
}else ms_message("ports do not match, need to update the register (%s <> %i)", contact_port,rport);
}
eXosip_lock();
msg=NULL;
......@@ -1043,7 +1088,8 @@ static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *ori
if (ctt->url->port!=NULL){
osip_free(ctt->url->port);
}
ctt->url->port=osip_strdup(rport);
snprintf(port,sizeof(port),"%i",rport);
ctt->url->port=osip_strdup(port);
eXosip_register_send_register(op->rid,msg);
eXosip_unlock();
osip_contact_to_str(ctt,&tmp);
......
......@@ -70,6 +70,7 @@ void linphone_gtk_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf);
const gchar *linphone_gtk_get_ui_config(const char *key, const char *def);
int linphone_gtk_get_ui_config_int(const char *key, int def);
void linphone_gtk_set_ui_config_int(const char *key , int val);
void linphone_gtk_visibility_set(const char *hiddens, const char *window_name, GtkWidget *w, gboolean show);
void linphone_gtk_open_browser(const char *url);
void linphone_gtk_check_for_new_version(void);
......
......@@ -224,46 +224,6 @@ GtkWidget *linphone_gtk_get_main_window(){
return the_ui;
}
static void parse_item(const char *item, const char *window_name, GtkWidget *w, gboolean show){
char tmp[64];
char *dot;
strcpy(tmp,item);
dot=strchr(tmp,'.');
if (dot){
*dot='\0';
dot++;
if (strcmp(window_name,tmp)==0){
GtkWidget *wd=linphone_gtk_get_widget(w,dot);
if (wd) {
if (!show) gtk_widget_hide(wd);
else gtk_widget_show(wd);
}
}
}
}
static void parse_widgets(const char *hiddens, const char *window_name, GtkWidget *w, gboolean show){
char item[64];
const char *i;
const char *b;
int len;
for(b=i=hiddens;*i!='\0';++i){
if (*i==' '){
len=MIN(i-b,sizeof(item)-1);
strncpy(item,b,len);
item[len]='\0';
b=i+1;
parse_item(item,window_name,w,show);
}
}
len=MIN(i-b,sizeof(item)-1);
if (len>0){
strncpy(item,b,len);
item[len]='\0';
parse_item(item,window_name,w,show);
}
}
static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name){
static const char *icon_path=NULL;
static const char *hiddens=NULL;
......@@ -277,9 +237,9 @@ static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name)
config_loaded=TRUE;
}
if (hiddens)
parse_widgets(hiddens,window_name,w,FALSE);
linphone_gtk_visibility_set(hiddens,window_name,w,FALSE);
if (shown)
parse_widgets(shown,window_name,w,TRUE);
linphone_gtk_visibility_set(shown,window_name,w,TRUE);
if (icon_path) {
GdkPixbuf *pbuf=create_pixbuf(icon_path);
gtk_window_set_icon(GTK_WINDOW(w),pbuf);
......@@ -1076,6 +1036,7 @@ static void linphone_gtk_configure_main_window(){
static const char *home;
static const char *start_call_icon;
static const char *stop_call_icon;
static const char *search_icon;
static gboolean update_check_menu;
GtkWidget *w=linphone_gtk_get_main_window();
if (!config_loaded){
......@@ -1083,6 +1044,7 @@ static void linphone_gtk_configure_main_window(){
home=linphone_gtk_get_ui_config("home","http://www.linphone.org");
start_call_icon=linphone_gtk_get_ui_config("start_call_icon","green.png");
stop_call_icon=linphone_gtk_get_ui_config("stop_call_icon","red.png");
search_icon=linphone_gtk_get_ui_config("directory_search_icon",NULL);
update_check_menu=linphone_gtk_get_ui_config_int("update_check_menu",0);
config_loaded=TRUE;
}
......@@ -1104,6 +1066,11 @@ static void linphone_gtk_configure_main_window(){
gtk_image_set_from_pixbuf(GTK_IMAGE(linphone_gtk_get_widget(w,"in_call_terminate_icon")),pbuf);
g_object_unref(G_OBJECT(pbuf));
}
if (search_icon){
GdkPixbuf *pbuf=create_pixbuf(search_icon);
gtk_image_set_from_pixbuf(GTK_IMAGE(linphone_gtk_get_widget(w,"directory_search_button_icon")),pbuf);
g_object_unref(G_OBJECT(pbuf));
}
if (home){
gchar *tmp;
GtkWidget *menu_item=linphone_gtk_get_widget(w,"home_item");
......
This diff is collapsed.
......@@ -108,6 +108,7 @@
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
......@@ -219,6 +220,7 @@
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
......@@ -373,6 +375,7 @@
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
......@@ -1546,7 +1549,40 @@ Video codecs</property>
</packing>
</child>
<child>
<placeholder/>
<widget class="GtkFrame" id="ui_level_frame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkCheckButton" id="ui_level">
<property name="label" translatable="yes">Show advanced settings</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="linphone_gtk_ui_level_toggled"/>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Level&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
......
......@@ -700,6 +700,28 @@ void linphone_gtk_lang_changed(GtkComboBox *combo){
}
}
static void linphone_gtk_ui_level_adapt(GtkWidget *top) {
gboolean ui_advanced;
const char *simple_ui = linphone_gtk_get_ui_config("simple_ui", "parameters.codec_tab parameters.transport_frame parameters.ports_frame");
ui_advanced = linphone_gtk_get_ui_config_int("advanced_ui", TRUE);
if (ui_advanced) {
linphone_gtk_visibility_set(simple_ui, "parameters", top, TRUE);
} else {
linphone_gtk_visibility_set(simple_ui, "parameters", top, FALSE);
}
}
void linphone_gtk_ui_level_toggled(GtkWidget *w) {
gint ui_advanced;
GtkWidget *top;
top = gtk_widget_get_toplevel(w);
ui_advanced = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
linphone_gtk_set_ui_config_int("advanced_ui", ui_advanced);
linphone_gtk_ui_level_adapt(top);
}
void linphone_gtk_show_parameters(void){
GtkWidget *pb=linphone_gtk_create_window("parameters");
LinphoneCore *lc=linphone_gtk_get_core();
......@@ -709,6 +731,8 @@ void linphone_gtk_show_parameters(void){
LinphoneFirewallPolicy pol;
GtkWidget *codec_list=linphone_gtk_get_widget(pb,"codec_list");
int mtu;
int ui_advanced;
/* NETWORK CONFIG */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb,"ipv6_enabled")),
linphone_core_ipv6_enabled(lc));
......@@ -779,6 +803,13 @@ void linphone_gtk_show_parameters(void){
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb,"upload_bw")),
linphone_core_get_upload_bandwidth(lc));
/* UI CONFIG */
linphone_gtk_fill_langs(pb);
ui_advanced = linphone_gtk_get_ui_config_int("advanced_ui", 1);
linphone_gtk_set_ui_config_int("advanced_ui", ui_advanced);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb,"ui_level")),
ui_advanced);
linphone_gtk_ui_level_adapt(pb);
gtk_widget_show(pb);
}
......@@ -193,3 +193,43 @@ void linphone_gtk_set_ui_config_int(const char *key , int val){
}
static void parse_item(const char *item, const char *window_name, GtkWidget *w, gboolean show){
char tmp[64];
char *dot;
strcpy(tmp,item);
dot=strchr(tmp,'.');
if (dot){
*dot='\0';
dot++;
if (strcmp(window_name,tmp)==0){
GtkWidget *wd=linphone_gtk_get_widget(w,dot);
if (wd) {
if (!show) gtk_widget_hide(wd);
else gtk_widget_show(wd);
}
}
}
}
void linphone_gtk_visibility_set(const char *hiddens, const char *window_name, GtkWidget *w, gboolean show){
char item[64];
const char *i;
const char *b;
int len;
for(b=i=hiddens;*i!='\0';++i){
if (*i==' '){
len=MIN(i-b,sizeof(item)-1);
strncpy(item,b,len);
item[len]='\0';
b=i+1;
parse_item(item,window_name,w,show);
}
}
len=MIN(i-b,sizeof(item)-1);
if (len>0){
strncpy(item,b,len);
item[len]='\0';
parse_item(item,window_name,w,show);
}
}
#!@INTLTOOL_PERL@ -w
# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4 -*-
#
# The Intltool Message Extractor
#
# Copyright (C) 2000-2001 Free Software Foundation.
#
# Intltool 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.
#
# Intltool 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# Authors: Kenneth Christiansen <kenneth@gnu.org>
# Darin Adler <darin@bentspoon.com>
#
## Release information
my $PROGRAM = "intltool-extract";
my $PACKAGE = "intltool";
my $VERSION = "0.22";
## Loaded modules
use strict;
use File::Basename;
use Getopt::Long;
## Scalars used by the option stuff
my $TYPE_ARG = "0";
my $LOCAL_ARG = "0";
my $HELP_ARG = "0";
my $VERSION_ARG = "0";
my $UPDATE_ARG = "0";
my $QUIET_ARG = "0";
my $FILE;
my $OUTFILE;
my $gettext_type = "";
my $input;
my %messages = ();
## Use this instead of \w for XML files to handle more possible characters.
my $w = "[-A-Za-z0-9._:]";
## Always print first
$| = 1;
## Handle options
GetOptions (
"type=s" => \$TYPE_ARG,
"local|l" => \$LOCAL_ARG,
"help|h" => \$HELP_ARG,
"version|v" => \$VERSION_ARG,
"update" => \$UPDATE_ARG,
"quiet|q" => \$QUIET_ARG,
) or &error;
&split_on_argument;
## Check for options.
## This section will check for the different options.
sub split_on_argument {
if ($VERSION_ARG) {
&version;
} elsif ($HELP_ARG) {
&help;
} elsif ($LOCAL_ARG) {
&place_local;
&extract;
} elsif ($UPDATE_ARG) {
&place_normal;
&extract;
} elsif (@ARGV > 0) {
&place_normal;
&message;
&extract;
} else {
&help;
}
}
sub place_normal {
$FILE = $ARGV[0];
$OUTFILE = "$FILE.h";
}
sub place_local {
$OUTFILE = fileparse($FILE, ());
if (!-e "tmp/") {
system("mkdir tmp/");
}
$OUTFILE = "./tmp/$OUTFILE.h"
}
sub determine_type {
if ($TYPE_ARG =~ /^gettext\/(.*)/) {
$gettext_type=$1
}
}
## Sub for printing release information
sub version{
print "${PROGRAM} (${PACKAGE}) $VERSION\n";
print "Copyright (C) 2000 Free Software Foundation, Inc.\n";
print "Written by Kenneth Christiansen, 2000.\n\n";
print "This is free software; see the source for copying conditions. There is NO\n";
print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
exit;
}
## Sub for printing usage information
sub help{
print "Usage: ${PROGRAM} [FILENAME] [OPTIONS] ...\n";
print "Generates a header file from an xml source file.\n\nGrabs all strings ";
print "between <_translatable_node> and it's end tag,\nwhere tag are all allowed ";
print "xml tags. Read the docs for more info.\n\n";
print " -v, --version shows the version\n";
print " -h, --help shows this help page\n";
print " -q, --quiet quiet mode\n";
print "\nReport bugs to <kenneth\@gnu.org>.\n";
exit;
}
## Sub for printing error messages
sub error{
print "Try `${PROGRAM} --help' for more information.\n";
exit;
}
sub message {
print "Generating C format header file for translation.\n";
}
sub extract {
&determine_type;
&convert ($FILE);
open OUT, ">$OUTFILE";
&msg_write;
close OUT;
print "Wrote $OUTFILE\n" unless $QUIET_ARG;
}
sub convert($) {
## Reading the file
{
local (*IN);
local $/; #slurp mode
open (IN, "<$FILE") || die "can't open $FILE: $!";
$input = <IN>;
}
&type_ini if $gettext_type eq "ini";
&type_keys if $gettext_type eq "keys";
&type_xml if $gettext_type eq "xml";
&type_glade if $gettext_type eq "glade";
&type_scheme if $gettext_type eq "scheme";
&type_schemas if $gettext_type eq "schemas";
}
sub entity_decode_minimal
{
local ($_) = @_;
s/&apos;/'/g; # '
s/&quot;/"/g; # "
s/&amp;/&/g;
return $_;
}
sub entity_decode
{
local ($_) = @_;
s/&apos;/'/g; # '
s/&quot;/"/g; # "
s/&amp;/&/g;
s/&lt;/</g;
s/&gt;/>/g;
return $_;
}
sub escape_char
{
return '\"' if $_ eq '"';
return '\n' if $_ eq "\n";
return '\\' if $_ eq '\\';
return $_;
}
sub escape
{
my ($string) = @_;
return join "", map &escape_char, split //, $string;
}
sub type_ini {
### For generic translatable desktop files ###
while ($input =~ /^_.*=(.*)$/mg) {
$messages{$1} = [];
}
}
sub type_keys {
### For generic translatable mime/keys files ###
while ($input =~ /^\s*_\w+=(.*)$/mg) {
$messages{$1} = [];
}
}
sub type_xml {
### For generic translatable XML files ###
while ($input =~ /\s_$w+=\"([^"]+)\"/sg) { # "
$messages{entity_decode_minimal($1)} = [];
}
while ($input =~ /<_($w+)>(.+?)<\/_\1>/sg) {
$_ = $2;