Commit 2a740938 authored by Simon Morlat's avatar Simon Morlat
Browse files

srtp/zrtp combo box compatible for gtk 2.22

parent 9d7b2181
......@@ -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) {
......
......@@ -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);
/**
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<requires lib="gtk+" version="2.22"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">500</property>
<property name="upper">3001</property>
......@@ -53,6 +53,7 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="liststore1"/>
<object class="GtkListStore" id="model1">
<columns>
<!-- column-name gchararray -->
......@@ -406,13 +407,10 @@
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="media_encryption_combo">
<object class="GtkComboBox" id="media_encryption_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
<items>
<item translatable="yes">None</item>
</items>
</object>
<packing>
<property name="left_attach">1</property>
......
......@@ -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){
......
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