Commit 27d916ee authored by Simon Morlat's avatar Simon Morlat

enforce "media_encryption_mandatory" policy for incoming calls too.

add toggle button for this into gtk interface.
parent a302d7ed
......@@ -344,7 +344,7 @@ static void call_accepted(SalOp *op){
linphone_call_set_state(call,LinphoneCallConnected,"Connected");
if (call->referer) linphone_core_notify_refer_state(lc,call->referer,call);
}
if (md && !sal_media_description_empty(md)){
if (md && !sal_media_description_empty(md) && !linphone_core_incompatible_security(lc,md)){
if (sal_media_description_has_dir(md,SalStreamSendOnly) ||
sal_media_description_has_dir(md,SalStreamInactive)){
if (lc->vtable.display_status){
......@@ -393,7 +393,7 @@ static void call_accepted(SalOp *op){
}else{
/*send a bye*/
ms_error("Incompatible SDP offer received in 200Ok, need to abort the call");
linphone_core_abort_call(lc,call,_("Incompatible, check codecs..."));
linphone_core_abort_call(lc,call,_("Incompatible, check codecs or security settings..."));
}
}
......
......@@ -65,6 +65,7 @@ static void linphone_core_run_hooks(LinphoneCore *lc);
static void linphone_core_free_hooks(LinphoneCore *lc);
#include "enum.h"
const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
void linphone_core_get_local_ip(LinphoneCore *lc, const char *dest, char *result);
static void toggle_video_preview(LinphoneCore *lc, bool_t val);
......@@ -2549,6 +2550,19 @@ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){
return FALSE;
}
bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md){
if (linphone_core_is_media_encryption_mandatory(lc) && linphone_core_get_media_encryption(lc)==LinphoneMediaEncryptionSRTP){
int i;
for(i=0;i<md->nstreams;i++){
SalStreamDescription *sd=&md->streams[i];
if (sd->proto!=SalProtoRtpSavp){
return TRUE;
}
}
}
return FALSE;
}
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){
char *barmesg;
char *tmp;
......@@ -2560,10 +2574,12 @@ void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){
linphone_call_make_local_media_description(lc,call);
sal_call_set_local_media_description(call->op,call->localdesc);
md=sal_call_get_final_media_description(call->op);
if (md && sal_media_description_empty(md)){
sal_call_decline(call->op,SalReasonMedia,NULL);
linphone_call_unref(call);
return;
if (md){
if (sal_media_description_empty(md) || linphone_core_incompatible_security(lc,md)){
sal_call_decline(call->op,SalReasonMedia,NULL);
linphone_call_unref(call);
return;
}
}
from_parsed=linphone_address_new(sal_op_get_from(call->op));
......
......@@ -299,6 +299,7 @@ int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call);
int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md);
extern SalCallbacks linphone_sal_callbacks;
void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg, LinphoneReason error);
bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
......
This diff is collapsed.
......@@ -880,19 +880,35 @@ void linphone_gtk_ui_level_toggled(GtkWidget *w) {
linphone_gtk_ui_level_adapt(top);
}
static void linphone_gtk_set_media_encryption_mandatory_sensitive(GtkWidget *propbox, gboolean val){
GtkWidget *w=linphone_gtk_get_widget(propbox,"media_encryption_mandatory");
gtk_widget_set_sensitive(w,val);
}
static void linphone_gtk_media_encryption_changed(GtkWidget *combo){
char *selected=gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *toplevel=gtk_widget_get_toplevel(combo);
if (selected!=NULL){
if (strcasecmp(selected,"SRTP")==0)
if (strcasecmp(selected,"SRTP")==0){
linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionSRTP);
else if (strcasecmp(selected,"ZRTP")==0)
linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,TRUE);
}else if (strcasecmp(selected,"ZRTP")==0){
linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionZRTP);
else linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionNone);
linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,FALSE);
}
else {
linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionNone);
linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,FALSE);
}
g_free(selected);
}else g_warning("gtk_combo_box_get_active_text() returned NULL");
}
void linphone_gtk_set_media_encryption_mandatory(GtkWidget *button){
linphone_core_set_media_encryption_mandatory(linphone_gtk_get_core(),gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
}
static void linphone_gtk_show_media_encryption(GtkWidget *pb){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *combo=linphone_gtk_get_widget(pb,"media_encryption_combo");
......@@ -928,21 +944,30 @@ static void linphone_gtk_show_media_encryption(GtkWidget *pb){
/*hide this setting*/
gtk_widget_hide(combo);
gtk_widget_hide(linphone_gtk_get_widget(pb,"media_encryption_label"));
gtk_widget_hide(linphone_gtk_get_widget(pb,"media_encryption_mandatory"));
}else{
LinphoneMediaEncryption menc=linphone_core_get_media_encryption(lc);
switch(menc){
case LinphoneMediaEncryptionNone:
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0);
linphone_gtk_set_media_encryption_mandatory_sensitive(pb,FALSE);
break;
case LinphoneMediaEncryptionSRTP:
if (srtp_id!=-1) gtk_combo_box_set_active(GTK_COMBO_BOX(combo),srtp_id);
if (srtp_id!=-1) {
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),srtp_id);
linphone_gtk_set_media_encryption_mandatory_sensitive(pb,TRUE);
}
break;
case LinphoneMediaEncryptionZRTP:
if (zrtp_id!=-1) gtk_combo_box_set_active(GTK_COMBO_BOX(combo),zrtp_id);
if (zrtp_id!=-1) {
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),zrtp_id);
linphone_gtk_set_media_encryption_mandatory_sensitive(pb,FALSE);
}
break;
}
g_signal_connect(G_OBJECT(combo),"changed",(GCallback)linphone_gtk_media_encryption_changed,NULL);
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb,"media_encryption_mandatory")),linphone_core_is_media_encryption_mandatory(lc));
g_object_unref(G_OBJECT(model));
}
......
mediastreamer2 @ 1ac1a481
Subproject commit 6874ac86f173b5cf57b87e5ee529652ba6676295
Subproject commit 1ac1a481d8b8ae72cba1d908b315e5e1f6b0da16
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment