From c1b1d0120b079af160453684b00fa8c440a8b40c Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 12 Feb 2010 11:31:23 +0100 Subject: [PATCH 1/4] add linphone_proxy_config_normalize_number to linphonecore.h --- coreapi/linphonecore.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 05dd32203..e592089dd 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -377,6 +377,10 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg); SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg); +/** + * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 + */ +int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len); /** * @} From 7721c8c68069c7155d64bd7b6c17adc54056593e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 12 Feb 2010 12:01:39 +0100 Subject: [PATCH 2/4] optimize logging to file. --- gtk-glade/logging.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/gtk-glade/logging.c b/gtk-glade/logging.c index 856937349..4bd09281c 100644 --- a/gtk-glade/logging.c +++ b/gtk-glade/logging.c @@ -72,14 +72,14 @@ static FILE *linphone_gtk_log_init() static gboolean _log_init = FALSE; const char *dst_fname; - dst_fname = linphone_gtk_get_ui_config("logfile",NULL); - /* For anything to happen, we need a logfile configuration variable, - this is our trigger */ - if (dst_fname) { - /* If we haven't initialised yet, arrange for _logdir to contain a - directory that has been created and _logfname to contain the - path to a file to which we will log */ - if (!_log_init) { + if (!_log_init) { + dst_fname = linphone_gtk_get_ui_config("logfile",NULL); + /* For anything to happen, we need a logfile configuration variable, + this is our trigger */ + if (dst_fname) { + /* arrange for _logdir to contain a + directory that has been created and _logfname to contain the + path to a file to which we will log */ #ifdef WIN32 const char *appdata=getenv("LOCALAPPDATA"); if (appdata) { @@ -103,7 +103,7 @@ static FILE *linphone_gtk_log_init() open the file so that we will be appending to it. */ if (_logdir[0] != '\0') { snprintf(_logfname, sizeof(_logfname), "%s%c%s", - _logdir, PATH_SEPARATOR, dst_fname); + _logdir, PATH_SEPARATOR, dst_fname); /* If the constant LOGFILE_ROTATION is greater than zero, then we kick away a simple rotation that will ensure that there are never more than LOGFILE_ROTATION+1 old copies of the @@ -122,9 +122,9 @@ static FILE *linphone_gtk_log_init() have to loop in reverse here. */ for (i=LOGFILE_ROTATION-1;i>=0;i--) { snprintf(old_fname, sizeof(old_fname), "%s%c%s.%d", - _logdir, PATH_SEPARATOR, dst_fname, i); + _logdir, PATH_SEPARATOR, dst_fname, i); snprintf(new_fname, sizeof(new_fname), "%s%c%s.%d", - _logdir, PATH_SEPARATOR, dst_fname, i+1); + _logdir, PATH_SEPARATOR, dst_fname, i+1); if (ortp_file_exist(old_fname)==0) { if (ortp_file_exist(new_fname)==0) unlink(new_fname); @@ -135,7 +135,7 @@ static FILE *linphone_gtk_log_init() sure to remove the old .0 also, since otherwise rename() would not work as expected. */ snprintf(new_fname, sizeof(new_fname), "%s%c%s.%d", - _logdir, PATH_SEPARATOR, dst_fname, 0); + _logdir, PATH_SEPARATOR, dst_fname, 0); if (ortp_file_exist(new_fname)==0) unlink(new_fname); rename(_logfname, new_fname); @@ -143,11 +143,10 @@ static FILE *linphone_gtk_log_init() /* Start a new log file and mark that we have now initialised */ _logfile = fopen(_logfname, "w"); fprintf(_logfile, "%s\n", LOGFILE_MARKER_START); - _log_init = TRUE; } } + _log_init = TRUE; } - return _logfile; } From f6768244cd08e39b80c15d4781a7d45da7462f93 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 12 Feb 2010 12:01:48 +0100 Subject: [PATCH 3/4] fix memory leaks in linphonec, due to api change with linphone_core_add_auth_info(). --- console/commands.c | 1 + console/linphonec.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/console/commands.c b/console/commands.c index cb684511c..d32e62667 100644 --- a/console/commands.c +++ b/console/commands.c @@ -1384,6 +1384,7 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){ snprintf(realm,sizeof(realm)-1,"\"%s\"",from->url->host); info=linphone_auth_info_new(from->url->username,NULL,passwd,NULL,NULL); linphone_core_add_auth_info(lc,info); + linphone_auth_info_destroy(info); } osip_from_free(from); } diff --git a/console/linphonec.c b/console/linphonec.c index 81fccea14..2e0ca8342 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -827,6 +827,8 @@ linphonec_prompt_for_auth_final(LinphoneCore *lc) */ linphone_auth_info_set_passwd(pending_auth, input); linphone_core_add_auth_info(lc, pending_auth); + linphone_auth_info_destroy(pending_auth); + auth_stack.elem[auth_stack.nitems-1]=0; --(auth_stack.nitems); #ifdef HAVE_READLINE /* From 01cd17d3c6798af285180aec762761aec2b969a8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 12 Feb 2010 12:15:58 +0100 Subject: [PATCH 4/4] fix crash in log window after it is closed by the user. --- gtk-glade/log.glade | 31 +++++++++++++++++-------------- gtk-glade/logging.c | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/gtk-glade/log.glade b/gtk-glade/log.glade index 0dfc558de..fc7206433 100644 --- a/gtk-glade/log.glade +++ b/gtk-glade/log.glade @@ -1,15 +1,15 @@ - - - + + + 540 290 5 Linphone debug window - GTK_WIN_POS_CENTER_ON_PARENT + center-on-parent linphone2.png - GDK_WINDOW_TYPE_HINT_DIALOG + dialog False False @@ -21,17 +21,17 @@ True True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_CORNER_BOTTOM_LEFT + never + automatic + bottom-left True - GTK_SHADOW_IN + in True True False - GTK_WRAP_WORD + word @@ -42,27 +42,30 @@ True - GTK_BUTTONBOX_END + end + gtk-close True True True - gtk-close True - 0 + + False + False 1 False - GTK_PACK_END + end + 0 diff --git a/gtk-glade/logging.c b/gtk-glade/logging.c index 4bd09281c..5864375f2 100644 --- a/gtk-glade/logging.c +++ b/gtk-glade/logging.c @@ -213,12 +213,29 @@ static void linphone_gtk_log_file(OrtpLogLevel lev, const char *msg) } } + + +static gboolean delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) +{ + gtk_widget_hide (widget); + return TRUE; +} + +void linphone_gtk_log_hide(){ + if (log_window) + gtk_widget_hide(log_window); +} + void linphone_gtk_create_log_window(void){ GtkTextBuffer *b; log_window=linphone_gtk_create_window("log"); b=gtk_text_view_get_buffer(GTK_TEXT_VIEW(linphone_gtk_get_widget(log_window,"textview"))); gtk_text_buffer_create_tag(b,"red","foreground","red",NULL); gtk_text_buffer_create_tag(b,"orange","foreground","orange",NULL); + /*prevent the log window from being destroyed*/ + g_signal_connect (G_OBJECT (log_window), "delete-event", + G_CALLBACK (delete_event_cb), NULL); + } void linphone_gtk_destroy_log_window(void){