diff --git a/coreapi/chat.c b/coreapi/chat.c index 3e6d374e2..1f8df2a14 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -288,6 +288,7 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) { cacheXml = xmlParseDoc((xmlChar*)cacheString); ms_free(cacheString); if (cacheXml) { + bool_t res; limeURIKeys_t associatedKeys; /* retrieve keys associated to the peer URI */ associatedKeys.peerURI = (uint8_t *)malloc(strlen(cr->peer)+1); @@ -295,13 +296,10 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) { associatedKeys.associatedZIDNumber = 0; associatedKeys.peerKeys = NULL; - if (lime_getCachedSndKeysByURI(cacheXml, &associatedKeys) != 0) { - lime_freeKeys(associatedKeys); - return FALSE; - } - + res = (lime_getCachedSndKeysByURI(cacheXml, &associatedKeys) == 0 && associatedKeys.associatedZIDNumber != 0); + lime_freeKeys(associatedKeys); xmlFreeDoc(cacheXml); - return TRUE; + return res; } } } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index bbb170a83..6c4f1dd6e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1513,6 +1513,13 @@ LINPHONE_PUBLIC LinphoneCore* linphone_chat_room_get_core(LinphoneChatRoom *cr); */ LINPHONE_PUBLIC uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr); +/** + * Returns true if lime is available for given peer + * + * @return true if zrtp secrets have already been shared and ready to use + */ + LINPHONE_PUBLIC bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr); + /** * Returns an list of chat rooms * @param[in] lc #LinphoneCore object diff --git a/coreapi/private.h b/coreapi/private.h index 20a4c5b73..d67c26341 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -591,7 +591,6 @@ int linphone_chat_room_upload_file(LinphoneChatMessage *msg); void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg); LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void); LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call); -bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr); /**/ struct _LinphoneProxyConfig diff --git a/gtk/chat.c b/gtk/chat.c index 008d356d3..2a2287b2c 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -468,6 +468,15 @@ static gboolean copy_uri_into_clipboard_handler(GtkMenuItem *menuitem, gpointer return FALSE; } +static void refresh_lime_icon(GtkWidget* chat_view, LinphoneChatRoom*cr) { + GtkWidget *lime_icon = linphone_gtk_get_widget(chat_view, "lime_icon"); + if (linphone_chat_room_lime_available(cr)) { + gtk_widget_show(lime_icon); + } else { + gtk_widget_hide(lime_icon); + } +} + static gint linphone_gtk_window_focused(GtkWidget* widget, GdkEvent *event, gpointer user_data) { // if we are in a chat, mark it as read GtkWidget *main_window=linphone_gtk_get_main_window(); @@ -477,6 +486,7 @@ static gint linphone_gtk_window_focused(GtkWidget* widget, GdkEvent *event, gpoi if (cr) { linphone_gtk_mark_chat_read(cr); } + refresh_lime_icon(w, cr); return FALSE; } @@ -559,6 +569,8 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres gtk_signal_connect(GTK_OBJECT(main_window), "focus-in-event", GTK_SIGNAL_FUNC(linphone_gtk_window_focused), NULL); + refresh_lime_icon(chat_view, cr); + return chat_view; } @@ -595,6 +607,8 @@ void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri, gtk_text_buffer_get_end_iter(text_buffer,&end); gtk_text_view_scroll_to_iter(text_view,&end,0,FALSE,1.0,0); } + refresh_lime_icon(chat_view, cr); + ms_free(from_str); ms_free(uri_str); ms_free(uri_only); diff --git a/gtk/chatroom_frame.ui b/gtk/chatroom_frame.ui index 9f5b66ef7..d7b8137a3 100644 --- a/gtk/chatroom_frame.ui +++ b/gtk/chatroom_frame.ui @@ -37,6 +37,20 @@ True False + 10 + + + True + False + 16 + linphone-security-ok + + + False + False + 0 + + True @@ -51,7 +65,7 @@ True True - 0 + 1 @@ -94,7 +108,7 @@ False False - 1 + 2