From fab5b9b712a9681854eb5e6a0b548f7579905375 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 7 Nov 2011 12:22:14 +0100 Subject: [PATCH] support to display encryption --- coreapi/linphonecall.c | 22 +++++++----- coreapi/linphonecore.h | 5 ++- coreapi/private.h | 3 +- gtk/incall_view.c | 35 +++++++++++++++++-- gtk/main.ui | 79 ++++++++++++++++++++++++++---------------- 5 files changed, 99 insertions(+), 45 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index bbaeba7bd..c8943cc7a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -86,7 +86,8 @@ const char* linphone_call_get_authentication_token(LinphoneCall *call){ bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call){ return call->auth_token_verified; } -bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) { + +static bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) { // Check ZRTP encryption in audiostream if (!call->audiostream_encrypted) { return FALSE; @@ -104,14 +105,16 @@ bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) { } void propagate_encryption_changed(LinphoneCall *call){ - if (call->core->vtable.call_encryption_changed == NULL) return; - + LinphoneCore *lc=call->core; if (!linphone_call_are_all_streams_encrypted(call)) { ms_message("Some streams are not encrypted"); - call->core->vtable.call_encryption_changed(call->core, call, FALSE, call->auth_token); + if (lc->vtable.call_encryption_changed) + lc->vtable.call_encryption_changed(call->core, call, FALSE, call->auth_token); } else { ms_message("All streams are encrypted"); - call->core->vtable.call_encryption_changed(call->core, call, TRUE, call->auth_token); + call->current_params.media_encryption=LinphoneMediaEncryptionZRTP; + if (lc->vtable.call_encryption_changed) + lc->vtable.call_encryption_changed(call->core, call, TRUE, call->auth_token); } } @@ -131,7 +134,7 @@ static void linphone_call_audiostream_encryption_changed(void *data, bool_t encr LinphoneCall *call = (LinphoneCall *)data; call->audiostream_encrypted=encrypted; - + if (encrypted && call->core->vtable.display_status != NULL) { snprintf(status,sizeof(status)-1,_("Authentication token is %s"),call->auth_token); call->core->vtable.display_status(call->core, status); @@ -719,7 +722,7 @@ bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp){ return cp->has_video; } -enum LinphoneMediaEncryption linphone_call_params_get_media_encryption(LinphoneCallParams *cp) { +enum LinphoneMediaEncryption linphone_call_params_get_media_encryption(const LinphoneCallParams *cp) { return cp->media_encryption; } @@ -1259,8 +1262,11 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut call->playing_ringbacktone=send_ringbacktone; call->up_bw=linphone_core_get_upload_bandwidth(lc); - if (ortp_zrtp_available()) { + if (call->params.media_encryption==LinphoneMediaEncryptionZRTP) { OrtpZrtpParams params; + /*will be set later when zrtp is activated*/ + call->current_params.media_encryption=LinphoneMediaEncryptionNone; + params.zid=get_hexa_zrtp_identifier(lc); params.zid_file=lc->zrtp_secrets_cache; audio_stream_enable_zrtp(call->audiostream,¶ms); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 8b747659e..e52a0b5f9 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -185,8 +185,8 @@ typedef struct _LinphoneCallParams LinphoneCallParams; LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); -enum LinphoneMediaEncryption linphone_call_params_get_media_encryption(LinphoneCallParams *cp); -void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, enum LinphoneMediaEncryption e); +LinphoneMediaEncryption linphone_call_params_get_media_encryption(const LinphoneCallParams *cp); +void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, LinphoneMediaEncryption e); void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp); bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp); @@ -267,7 +267,6 @@ float linphone_call_get_play_volume(LinphoneCall *call); float linphone_call_get_record_volume(LinphoneCall *call); float linphone_call_get_current_quality(LinphoneCall *call); float linphone_call_get_average_quality(LinphoneCall *call); -bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call); const char* linphone_call_get_authentication_token(LinphoneCall *call); bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call); void linphone_call_send_vfu_request(LinphoneCall *call); diff --git a/coreapi/private.h b/coreapi/private.h index 216d26f15..bd04c82bb 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -60,11 +60,12 @@ struct _LinphoneCallParams{ LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */ int audio_bw; /* bandwidth limit for audio stream */ + LinphoneMediaEncryption media_encryption; bool_t has_video; bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/ bool_t in_conference; /*in conference mode */ bool_t pad; - enum LinphoneMediaEncryption media_encryption; + }; struct _LinphoneCall diff --git a/gtk/incall_view.c b/gtk/incall_view.c index 852a6f570..af216f208 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -78,15 +78,19 @@ static void linphone_gtk_in_call_set_animation_image(GtkWidget *callview, const GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation"); GList *elem=gtk_container_get_children(GTK_CONTAINER(container)); GtkWidget *image; - if (!is_stock) + + if (!is_stock){ + if (image_name==NULL){ + gtk_widget_hide(container); + } image=create_pixmap(image_name); - else + }else image=gtk_image_new_from_stock(image_name,GTK_ICON_SIZE_DIALOG); if (elem) gtk_widget_destroy((GtkWidget*)elem->data); gtk_widget_show(image); gtk_container_add(GTK_CONTAINER(container),image); - + gtk_widget_show_all(container); } static void linphone_gtk_in_call_set_animation_spinner(GtkWidget *callview){ @@ -97,6 +101,7 @@ static void linphone_gtk_in_call_set_animation_spinner(GtkWidget *callview){ gtk_widget_destroy((GtkWidget*)elem->data); gtk_widget_show(spinner); gtk_container_add(GTK_CONTAINER(container),spinner); + gtk_widget_set_size_request(spinner, 20,20); gtk_spinner_start(GTK_SPINNER(spinner)); } @@ -421,6 +426,29 @@ void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call, gboolean va } } +static void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call){ + GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call); + GtkWidget *encryption_box=linphone_gtk_get_widget(callview,"encryption_box"); + GtkWidget *label=linphone_gtk_get_widget(callview,"encryption_label"); + LinphoneMediaEncryption me=linphone_call_params_get_media_encryption(linphone_call_get_current_params(call)); + switch(me){ + case LinphoneMediaEncryptionSRTP: + gtk_label_set_markup(GTK_LABEL(label),_("Secured by SRTP")); + gtk_widget_show_all(encryption_box); + break; + case LinphoneMediaEncryptionZRTP: + { + gchar *text=g_strdup_printf(_("Secured by ZRTP - [auth token: %s]"),linphone_call_get_authentication_token(call)); + gtk_label_set_markup(GTK_LABEL(label),text); + g_free(text); + gtk_widget_show_all(encryption_box); + } + break; + default: + gtk_widget_hide(encryption_box); + } +} + void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){ GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call); GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status"); @@ -444,6 +472,7 @@ void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){ g_object_set_data(G_OBJECT(callview),"taskid",GINT_TO_POINTER(taskid)); } linphone_gtk_in_call_view_enable_audio_view(call, !in_conf); + linphone_gtk_in_call_view_show_encryption(call); if (in_conf) linphone_gtk_set_in_conference(call); } diff --git a/gtk/main.ui b/gtk/main.ui index 9c393b54c..1a3784f3b 100644 --- a/gtk/main.ui +++ b/gtk/main.ui @@ -1,7 +1,6 @@ - - + False @@ -100,29 +99,53 @@ True False - + True False - + + + + + False + False + 0 + + + + + True + False + label + center + + + True + True + 1 + + + + + False + + True False - - - + gtk-dialog-authentication + 1 - True - True + False + False 0 - + True False label - center True @@ -130,11 +153,14 @@ 1 + + + - True - True - 0 + False + False + 2 @@ -194,7 +220,7 @@ False False - 1 + 3 @@ -235,7 +261,7 @@ False False - 2 + 4 @@ -262,7 +288,7 @@ False False - 3 + 5 @@ -583,8 +609,6 @@ False False - True - True @@ -676,8 +700,6 @@ True False False - True - True @@ -734,8 +756,6 @@ True True - automatic - automatic True @@ -745,6 +765,9 @@ + + + @@ -770,8 +793,6 @@ True False False - True - True @@ -975,13 +996,15 @@ True True never - automatic True True False + + + @@ -1485,8 +1508,6 @@ False False - True - True 1 @@ -1501,8 +1522,6 @@ False False - True - True 1