diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index 2a5348bd1..4adf160dc 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -1027,6 +1027,9 @@ void linphone_core_iterate(LinphoneCore *lc) eXosip_unlock(); } } + + ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update); + if (lc->call!=NULL){ LinphoneCall *call=lc->call; @@ -2298,6 +2301,31 @@ void linphone_core_set_mtu(LinphoneCore *lc, int mtu){ }else ms_set_mtu(0);//use mediastreamer2 default value } +void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose){ + if (lc->vtable.waiting){ + lc->wait_ctx=lc->vtable.waiting(lc,NULL,LinphoneWaitingStart,purpose,0); + } +} + +void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progress){ + if (lc->vtable.waiting){ + lc->wait_ctx=lc->vtable.waiting(lc,lc->wait_ctx,LinphoneWaitingProgress,purpose,progress); + }else{ +#ifdef WIN32 + Sleep(50000); +#else + usleep(50000); +#endif + } +} + +void linphone_core_stop_waiting(LinphoneCore *lc){ + if (lc->vtable.waiting){ + lc->wait_ctx=lc->vtable.waiting(lc,lc->wait_ctx,LinphoneWaitingFinished,NULL,0); + } +} + + void net_config_uninit(LinphoneCore *lc) { net_config_t *config=&lc->net_conf; diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index 7f36f6df3..bb95b7a9b 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -295,7 +295,7 @@ typedef struct _LinphoneProxyConfig char *type; struct _SipSetupContext *ssctx; int auth_failures; - bool_t frozen; + bool_t commit; bool_t reg_sendregister; bool_t registered; bool_t publish; @@ -418,6 +418,12 @@ typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message); typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate); typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf); +typedef enum _LinphoneWaitingState{ + LinphoneWaitingStart, + LinphoneWaitingProgress, + LinphoneWaitingFinished +} LinphoneWaitingState; +typedef void * (*Waiting)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress); typedef struct _LinphoneVTable { @@ -440,6 +446,7 @@ typedef struct _LinphoneVTable TextMessageReceived text_received; GeneralStateChange general_state; DtmfReceived dtmf_received; + Waiting waiting; } LinphoneCoreVTable; typedef struct _LCCallbackObj @@ -504,6 +511,7 @@ typedef struct _LinphoneCore gstate_t gstate_power; gstate_t gstate_reg; gstate_t gstate_call; + void *wait_ctx; bool_t use_files; bool_t apply_nat_settings; bool_t ready; @@ -767,6 +775,10 @@ void linphone_core_stop_media_streams(LinphoneCore *lc); const char * linphone_core_get_identity(LinphoneCore *lc); const char * linphone_core_get_route(LinphoneCore *lc); bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, char **real_url, osip_to_t **real_parsed_url, char **route); +void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose); +void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses); +void linphone_core_stop_waiting(LinphoneCore *lc); + #ifdef __cplusplus } diff --git a/linphone/coreapi/private.h b/linphone/coreapi/private.h index c110a2bc1..7319e9b5a 100644 --- a/linphone/coreapi/private.h +++ b/linphone/coreapi/private.h @@ -127,5 +127,6 @@ void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCore *lc, co void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call); void linphone_core_write_friends_config(LinphoneCore* lc); +void linphone_proxy_config_update(LinphoneProxyConfig *cfg); #endif /* _PRIVATE_H */ diff --git a/linphone/coreapi/proxy.c b/linphone/coreapi/proxy.c index d4d3b2b95..5f73a8e26 100644 --- a/linphone/coreapi/proxy.c +++ b/linphone/coreapi/proxy.c @@ -218,7 +218,6 @@ void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val){ } void linphone_proxy_config_edit(LinphoneProxyConfig *obj){ - obj->frozen=TRUE; obj->auth_failures=0; if (obj->reg_sendregister){ /* unregister */ @@ -255,7 +254,7 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ int linphone_proxy_config_done(LinphoneProxyConfig *obj) { if (!linphone_proxy_config_check(obj->lc,obj)) return -1; - obj->frozen=FALSE; + obj->commit=TRUE; linphone_proxy_config_register(obj); linphone_proxy_config_write_all_to_config_file(obj->lc); return 0; @@ -588,15 +587,16 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config return cfg; } - -void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type){ - SipSetup *ss=sip_setup_lookup(type); +static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){ SipSetupContext *ssc; - if (cfg->type) - ms_free(cfg->type); - cfg->type=ms_strdup(type); + SipSetup *ss=sip_setup_lookup(cfg->type); if (!ss) return ; ssc=sip_setup_context_new(ss,cfg); + + if (cfg->reg_identity==NULL){ + ms_error("Invalid identity for this proxy configuration."); + return; + } if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL)==0){ if (sip_setup_context_get_capabilities(ssc) & SIP_SETUP_CAP_PROXY_PROVIDER){ char proxy[256]; @@ -608,6 +608,25 @@ void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *t cfg->ssctx=ssc; } +void linphone_proxy_config_update(LinphoneProxyConfig *cfg){ + if (cfg->commit){ + if (cfg->type && cfg->ssctx==NULL){ + linphone_proxy_config_activate_sip_setup(cfg); + } + cfg->commit=FALSE; + } +} + +void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type){ + if (cfg->type) + ms_free(cfg->type); + cfg->type=ms_strdup(type); + if (linphone_proxy_config_get_addr(cfg)==NULL){ + /*put a placeholder so that the sip setup gets saved into the config */ + linphone_proxy_config_set_server_addr(cfg,"sip:undefined"); + } +} + SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg){ return cfg->ssctx; } diff --git a/linphone/coreapi/sipsetup.c b/linphone/coreapi/sipsetup.c index 583e7e17e..56ea93946 100644 --- a/linphone/coreapi/sipsetup.c +++ b/linphone/coreapi/sipsetup.c @@ -98,9 +98,9 @@ int sip_setup_context_get_capabilities(SipSetupContext *ctx){ return ctx->funcs->capabilities; } -int sip_setup_new_account(SipSetup *funcs, const char *uri, const char *passwd){ - if (funcs->create_account) - return funcs->create_account(uri, passwd); +int sip_setup_context_create_account(SipSetupContext * ctx, const char *uri, const char *passwd){ + if (ctx->funcs->create_account) + return ctx->funcs->create_account(ctx,uri, passwd); else return -1; } diff --git a/linphone/coreapi/sipsetup.h b/linphone/coreapi/sipsetup.h index 38ef35d00..622cd8975 100644 --- a/linphone/coreapi/sipsetup.h +++ b/linphone/coreapi/sipsetup.h @@ -75,7 +75,7 @@ struct _SipSetup{ unsigned int capabilities; bool_t (*init)(void); void (*init_instance)(SipSetupContext *ctx); - int (*create_account)( const char *uri, const char *passwd); + int (*create_account)(SipSetupContext *ctx, const char *uri, const char *passwd); int (*login_account)(SipSetupContext *ctx, const char *uri, const char *passwd); int (*get_proxy)(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); int (*get_stun_servers)(SipSetupContext *ctx, char *stun1, char *stun2, size_t size); @@ -100,8 +100,8 @@ void sip_setup_register_all(void); SipSetup *sip_setup_lookup(const char *type_name); void sip_setup_unregister_all(void); -int sip_setup_new_account(SipSetup *s, const char *uri, const char *passwd); SipSetupContext * sip_setup_context_new(SipSetup *s, struct _LinphoneProxyConfig *cfg); +int sip_setup_context_create_account(SipSetupContext *ctx, const char *uri, const char *passwd); int sip_setup_context_get_capabilities(SipSetupContext *ctx); int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd); int sip_setup_context_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz); diff --git a/linphone/gtk-glade/Makefile.am b/linphone/gtk-glade/Makefile.am index 6aa91c7d5..1bcafbac6 100644 --- a/linphone/gtk-glade/Makefile.am +++ b/linphone/gtk-glade/Makefile.am @@ -8,7 +8,8 @@ GLADE_FILES= about.glade \ chatroom.glade \ call_logs.glade \ log.glade \ - buddylookup.glade + buddylookup.glade \ + waiting.glade PIXMAPS= linphone2.png \ linphone.png \ @@ -32,6 +33,7 @@ linphone_3_SOURCES= main.c\ logging.c \ update.c \ buddylookup.c \ + utils.c \ linphone.h linphone_3_LDADD=$(top_builddir)/oRTP/src/libortp.la \ diff --git a/linphone/gtk-glade/linphone.h b/linphone/gtk-glade/linphone.h index 22b8ca5b1..7fabcfc12 100644 --- a/linphone/gtk-glade/linphone.h +++ b/linphone/gtk-glade/linphone.h @@ -68,3 +68,4 @@ void linphone_gtk_check_for_new_version(void); const char *linphone_gtk_get_lang(const char *config_file); SipSetupContext* linphone_gtk_get_default_sip_setup_context(void); void linphone_gtk_show_buddy_lookup_window(SipSetupContext *ctx); +void * linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, const char *purpose, float progress); diff --git a/linphone/gtk-glade/main.c b/linphone/gtk-glade/main.c index e81588edb..5375eb14b 100644 --- a/linphone/gtk-glade/main.c +++ b/linphone/gtk-glade/main.c @@ -74,7 +74,8 @@ static LinphoneCoreVTable vtable={ .display_question=linphone_gtk_display_question, .call_log_updated=linphone_gtk_call_log_updated, .text_received=linphone_gtk_text_received, - .general_state=linphone_gtk_general_state + .general_state=linphone_gtk_general_state, + .waiting=linphone_gtk_wait }; static gboolean verbose=0; diff --git a/linphone/gtk-glade/utils.c b/linphone/gtk-glade/utils.c new file mode 100644 index 000000000..9941df2e8 --- /dev/null +++ b/linphone/gtk-glade/utils.c @@ -0,0 +1,70 @@ +/* +linphone, gtk-glade interface. +Copyright (C) 2008 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 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. +*/ + +#include "linphone.h" + +static void run_gtk(){ + while (gtk_events_pending ()) + gtk_main_iteration (); + +} + +void *linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, const char *purpose, float progress){ + GtkWidget *w; + switch(ws){ + case LinphoneWaitingStart: + w=linphone_gtk_create_window("waiting"); + gtk_window_set_transient_for(GTK_WINDOW(w),GTK_WINDOW(linphone_gtk_get_main_window())); + gtk_window_set_position(GTK_WINDOW(w),GTK_WIN_POS_CENTER_ON_PARENT); + if (purpose) { + gtk_progress_bar_set_text( + GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")), + purpose); + } + gtk_widget_show(w); + /*g_message("Creating waiting window");*/ + run_gtk(); + return w; + break; + case LinphoneWaitingProgress: + w=(GtkWidget*)ctx; + if (progress>=0){ + gtk_progress_bar_set_fraction( + GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")), + progress); + + + }else { + gtk_progress_bar_pulse( + GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")) + ); + } + /*g_message("Updating progress");*/ + run_gtk(); + g_usleep(50000); + return w; + break; + case LinphoneWaitingFinished: + w=(GtkWidget*)ctx; + gtk_widget_destroy(w); + return NULL; + break; + } + return NULL; +} diff --git a/linphone/gtk-glade/waiting.glade b/linphone/gtk-glade/waiting.glade new file mode 100644 index 000000000..65c2c0197 --- /dev/null +++ b/linphone/gtk-glade/waiting.glade @@ -0,0 +1,39 @@ + + + + + + GTK_WINDOW_POPUP + Linphone + False + linphone2.png + + + True + 0 + + + True + 12 + + + True + + + + + + + True + Please wait + True + GTK_JUSTIFY_CENTER + + + label_item + + + + + + diff --git a/linphone/mediastreamer2/configure.ac b/linphone/mediastreamer2/configure.ac index a9926ef0c..17dab6309 100644 --- a/linphone/mediastreamer2/configure.ac +++ b/linphone/mediastreamer2/configure.ac @@ -44,7 +44,13 @@ AC_MSG_CHECKING([warning make an error on compilation]) AC_ARG_ENABLE(strict, [ --enable-strict Enable error on compilation warning [default=no]], [wall_werror=$enableval], -[wall_werror=yes] +[ + if test "$USER" = "smorlat" ; then + wall_werror=yes + else + wall_werror=no + fi +] ) CFLAGS="-DORTP_INET6 $CFLAGS " diff --git a/linphone/mediastreamer2/tests/Makefile.am b/linphone/mediastreamer2/tests/Makefile.am index d55c96dc6..b6e16f9cf 100644 --- a/linphone/mediastreamer2/tests/Makefile.am +++ b/linphone/mediastreamer2/tests/Makefile.am @@ -8,7 +8,7 @@ echo_SOURCES=echo.c ring_SOURCES=ring.c videodisplay_SOURCES=videodisplay.c mtudiscover_SOURCES=mtudiscover.c -becnh_SOURCES=bench.c +bench_SOURCES=bench.c libexec_PROGRAMS=mediastream