]> sjero.net Git - linphone/commitdiff
support to display encryption
authorSimon Morlat <simon.morlat@linphone.org>
Mon, 7 Nov 2011 11:22:14 +0000 (12:22 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Mon, 7 Nov 2011 11:22:14 +0000 (12:22 +0100)
coreapi/linphonecall.c
coreapi/linphonecore.h
coreapi/private.h
gtk/incall_view.c
gtk/main.ui

index bbaeba7bd4c066f7aa300e0407bf8bd34f56c54f..c8943cc7a8b8041d4cda452c2c53b62c32d5dedb 100644 (file)
@@ -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,&params);
index 8b747659e2929203c6a284f4250772e2f72204ac..e52a0b5f9698977f1a96c3876567f600b7ad4651 100644 (file)
@@ -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);
index 216d26f15d1147ed70e9f35fa375f362474c6d76..bd04c82bb36f0e92e39ad3c7a8858655253093e7 100644 (file)
 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
index 852a6f570598831f757dc0ec3e537b17748d2a24..af216f208d91316f4833a6dd96cf670bdcfcb4f1 100644 (file)
@@ -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);
 }
 
index 9c393b54c76405c7bc29aeae2bd73f31610a3e59..1a3784f3b3b4189e577077a7ad14a8c8dc3a7075 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy toplevel-contextual -->
+  <requires lib="gtk+" version="2.24"/>
   <object class="GtkWindow" id="dummy_conf_window">
     <property name="can_focus">False</property>
     <child>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkHBox" id="incall_hbox1">
+                  <object class="GtkVBox" id="in_call_animation">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkVBox" id="in_call_animation">
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="in_call_uri">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">label</property>
+                    <property name="justify">center</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="encryption_box">
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImage" id="image12">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
+                        <property name="stock">gtk-dialog-authentication</property>
+                        <property name="icon-size">1</property>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="in_call_uri">
+                      <object class="GtkLabel" id="encryption_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes">label</property>
-                        <property name="justify">center</property>
                       </object>
                       <packing>
                         <property name="expand">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
                 <child>
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">1</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
                 <child>
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">2</property>
+                    <property name="position">4</property>
                   </packing>
                 </child>
                 <child>
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">3</property>
+                    <property name="position">5</property>
                   </packing>
                 </child>
               </object>
                                     <property name="invisible_char">●</property>
                                     <property name="primary_icon_activatable">False</property>
                                     <property name="secondary_icon_activatable">False</property>
-                                    <property name="primary_icon_sensitive">True</property>
-                                    <property name="secondary_icon_sensitive">True</property>
                                     <signal name="activate" handler="linphone_gtk_uri_bar_activate" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="invisible_char_set">True</property>
                                     <property name="primary_icon_activatable">False</property>
                                     <property name="secondary_icon_activatable">False</property>
-                                    <property name="primary_icon_sensitive">True</property>
-                                    <property name="secondary_icon_sensitive">True</property>
                                     <signal name="changed" handler="linphone_gtk_show_friends" swapped="no"/>
                                   </object>
                                   <packing>
                               <object class="GtkScrolledWindow" id="scrolledwindow1">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property name="hscrollbar_policy">automatic</property>
-                                <property name="vscrollbar_policy">automatic</property>
                                 <child>
                                   <object class="GtkTreeView" id="contact_list">
                                     <property name="visible">True</property>
                                     <signal name="cursor-changed" handler="linphone_gtk_contact_clicked" swapped="no"/>
                                     <signal name="row-activated" handler="linphone_gtk_contact_activated" swapped="no"/>
                                     <signal name="popup-menu" handler="linphone_gtk_popup_contact_menu" swapped="no"/>
+                                    <child internal-child="selection">
+                                      <object class="GtkTreeSelection" id="treeview-selection1"/>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
                                         <property name="invisible_char_set">True</property>
                                         <property name="primary_icon_activatable">False</property>
                                         <property name="secondary_icon_activatable">False</property>
-                                        <property name="primary_icon_sensitive">True</property>
-                                        <property name="secondary_icon_sensitive">True</property>
                                         <signal name="activate" handler="linphone_gtk_directory_search_activate" swapped="no"/>
                                         <signal name="icon-press" handler="linphone_gtk_directory_search_activate" swapped="no"/>
                                         <signal name="focus-in-event" handler="linphone_gtk_directory_search_focus_in" swapped="no"/>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="hscrollbar_policy">never</property>
-                                <property name="vscrollbar_policy">automatic</property>
                                 <child>
                                   <object class="GtkTreeView" id="logs_view">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="headers_visible">False</property>
                                     <signal name="row-activated" handler="linphone_gtk_history_row_activated" swapped="no"/>
+                                    <child internal-child="selection">
+                                      <object class="GtkTreeSelection" id="treeview-selection2"/>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
                                         <property name="invisible_char">●</property>
                                         <property name="primary_icon_activatable">False</property>
                                         <property name="secondary_icon_activatable">False</property>
-                                        <property name="primary_icon_sensitive">True</property>
-                                        <property name="secondary_icon_sensitive">True</property>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>
                                         <property name="invisible_char">●</property>
                                         <property name="primary_icon_activatable">False</property>
                                         <property name="secondary_icon_activatable">False</property>
-                                        <property name="primary_icon_sensitive">True</property>
-                                        <property name="secondary_icon_sensitive">True</property>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>