diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3398bf822..a13e3921d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -559,6 +559,8 @@ static void sip_config_read(LinphoneCore *lc) break; } } + /*this is to filter out unsupported encryption schemes*/ + linphone_core_set_media_encryption(lc,linphone_core_get_media_encryption(lc)); /*for tuning or test*/ lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0); @@ -4436,13 +4438,24 @@ bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, Linphone return FALSE; } -void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc) { - if (menc == LinphoneMediaEncryptionSRTP) - lp_config_set_string(lc->config,"sip","media_encryption","srtp"); - else if (menc == LinphoneMediaEncryptionZRTP) - lp_config_set_string(lc->config,"sip","media_encryption","zrtp"); - else - lp_config_set_string(lc->config,"sip","media_encryption","none"); +int linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc) { + const char *type="none"; + int ret=0; + if (menc == LinphoneMediaEncryptionSRTP){ + if (!ortp_srtp_supported()){ + ms_warning("SRTP not supported by library."); + type="none"; + ret=-1; + }else type="srtp"; + }else if (menc == LinphoneMediaEncryptionZRTP){ + if (!ortp_zrtp_available()){ + ms_warning("ZRTP not supported by library."); + type="none"; + ret=-1; + }else type="zrtp"; + } + lp_config_set_string(lc->config,"sip","media_encryption",type); + return ret; } LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc) { diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 047e6792b..f6da27f9d 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1046,8 +1046,8 @@ bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, Linphone /** * Choose media encryption policy to be used for RTP packets */ -void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc); -enum LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); +int linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc); +LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc); /** diff --git a/gtk/parameters.ui b/gtk/parameters.ui index d853a4bb0..400622632 100644 --- a/gtk/parameters.ui +++ b/gtk/parameters.ui @@ -1,6 +1,6 @@ - + 500 3001 @@ -53,6 +53,7 @@ 1 10 + @@ -406,13 +407,10 @@ - + True False 0 - - None - 1 diff --git a/gtk/propertybox.c b/gtk/propertybox.c index aece58048..8bacff9f5 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -804,7 +804,7 @@ void linphone_gtk_ui_level_toggled(GtkWidget *w) { } static void linphone_gtk_media_encryption_changed(GtkWidget *combo){ - const char *selected=gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); + char *selected=gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); LinphoneCore *lc=linphone_gtk_get_core(); if (selected!=NULL){ if (strcasecmp(selected,"SRTP")==0) @@ -812,6 +812,7 @@ static void linphone_gtk_media_encryption_changed(GtkWidget *combo){ else if (strcasecmp(selected,"ZRTP")==0) linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionZRTP); else linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionNone); + g_free(selected); }else g_warning("gtk_combo_box_get_active_text() returned NULL"); } @@ -820,14 +821,28 @@ static void linphone_gtk_show_media_encryption(GtkWidget *pb){ GtkWidget *combo=linphone_gtk_get_widget(pb,"media_encryption_combo"); bool_t no_enc=TRUE; int srtp_id=-1,zrtp_id=-1; - + GtkTreeModel *model; + GtkListStore *store; + GtkTreeIter iter; + GtkCellRenderer *renderer=gtk_cell_renderer_text_new(); + + model=GTK_TREE_MODEL((store=gtk_list_store_new(1,G_TYPE_STRING))); + gtk_combo_box_set_model(GTK_COMBO_BOX(combo),model); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo),renderer,TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),renderer,"text",0,NULL); + + gtk_list_store_append(store,&iter); + gtk_list_store_set(store,&iter,0,_("None"),-1); + if (linphone_core_media_encryption_supported(lc,LinphoneMediaEncryptionSRTP)){ - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),_("SRTP")); + gtk_list_store_append(store,&iter); + gtk_list_store_set(store,&iter,0,_("SRTP"),-1); srtp_id=1; no_enc=FALSE; } if (linphone_core_media_encryption_supported(lc,LinphoneMediaEncryptionZRTP)){ - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),_("ZRTP")); + gtk_list_store_append(store,&iter); + gtk_list_store_set(store,&iter,0,_("ZRTP"),-1); no_enc=FALSE; if (srtp_id!=-1) zrtp_id=2; else zrtp_id=1; @@ -851,6 +866,7 @@ static void linphone_gtk_show_media_encryption(GtkWidget *pb){ } g_signal_connect(G_OBJECT(combo),"changed",(GCallback)linphone_gtk_media_encryption_changed,NULL); } + g_object_unref(G_OBJECT(model)); } void linphone_gtk_show_parameters(void){