Commit 70dc0b75 authored by Sébastien Blin's avatar Sébastien Blin Committed by Philippe Gorley

generalsettingsview: add an option to disable images loading in the chatview

Displaying images in the chatview can lead to unwanted requests, the
user must be able to disable this functionnality.

Change-Id: I522b22fc603ff6adb36bcb7a560fa8d7a1b9bdb7
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 23c09e04
......@@ -26,6 +26,10 @@
<summary>Display the chat to the rigth (default) or at the bottom.</summary>
<description>If the chat pane is horizontal then the chat is displayed to the right of the video; otherwise it will be displayed bellow it.</description>
</key>
<key name="enable-display-links" type="b">
<default>true</default>
<summary>Enable chatview to display external images.</summary>
</key>
<key name="enable-call-notifications" type="b">
<default>true</default>
<summary>Enable notifications for incoming calls.</summary>
......
......@@ -34,6 +34,7 @@
#include "numbercategory.h"
#include <QtCore/QDateTime>
#include "utils/calling.h"
#include "utils/files.h"
#include "webkitchatcontainer.h"
// LRC
......@@ -67,6 +68,8 @@ struct _ChatViewPrivate
GtkWidget *button_placecall;
GtkWidget *button_send_invitation;
GSettings *settings;
/* only one of the three following pointers should be non void;
* either this is an in-call chat (and so the in-call chat APIs will be used)
* or it is an out of call chat (and so the account chat APIs will be used) */
......@@ -157,6 +160,18 @@ get_active_contactmethod(ChatView *self)
return nullptr;
}
static void
display_links_toggled(ChatView *self)
{
auto priv = CHAT_VIEW_GET_PRIVATE(self);
if (priv->webkit_chat_container) {
webkit_chat_container_set_display_links(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
g_settings_get_boolean(priv->settings, "enable-display-links")
);
}
}
static void
placecall_clicked(ChatView *self)
{
......@@ -249,6 +264,7 @@ chat_view_init(ChatView *view)
gtk_widget_init_template(GTK_WIDGET(view));
ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(view);
priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL);
g_signal_connect(priv->button_close_chatview, "clicked", G_CALLBACK(hide_chat_view), view);
g_signal_connect_swapped(priv->button_placecall, "clicked", G_CALLBACK(placecall_clicked), view);
......@@ -597,6 +613,8 @@ webkit_chat_container_ready(ChatView* self)
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container)
);
display_links_toggled(self);
/* print the text recordings */
if (priv->call) {
print_text_recording(priv->call->peerContactMethod()->textRecording(), self);
......
......@@ -56,6 +56,7 @@ struct _GeneralSettingsViewPrivate
GtkWidget *checkbutton_bringtofront;
GtkWidget *checkbutton_callnotifications;
GtkWidget *checkbutton_chatnotifications;
GtkWidget *checkbutton_chatdisplaylinks;
GtkWidget *checkbutton_searchentryplacescall;
GtkWidget *radiobutton_chatright;
GtkWidget *radiobutton_chatbottom;
......@@ -157,6 +158,9 @@ general_settings_view_init(GeneralSettingsView *self)
g_settings_bind(priv->settings, "enable-call-notifications",
priv->checkbutton_callnotifications, "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "enable-display-links",
priv->checkbutton_chatdisplaylinks, "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "enable-chat-notifications",
priv->checkbutton_chatnotifications, "active",
G_SETTINGS_BIND_DEFAULT);
......@@ -192,6 +196,7 @@ general_settings_view_class_init(GeneralSettingsViewClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_showstatusicon);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_bringtofront);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_callnotifications);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_chatdisplaylinks);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_chatnotifications);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_searchentryplacescall);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, radiobutton_chatright);
......
......@@ -485,6 +485,22 @@ webkit_chat_container_new()
return (GtkWidget *)view;
}
void
webkit_chat_container_set_display_links(WebKitChatContainer *view, bool display)
{
WebKitChatContainerPrivate *priv = WEBKIT_CHAT_CONTAINER_GET_PRIVATE(view);
gchar* function_call = g_strdup_printf("ring.chatview.setDisplayLinks(%s);",
display ? "true" : "false");
webkit_web_view_run_javascript(
WEBKIT_WEB_VIEW(priv->webview_chat),
function_call,
NULL,
NULL,
NULL
);
}
void
webkit_chat_container_clear_sender_images(WebKitChatContainer *view)
{
......
......@@ -45,5 +45,6 @@ void webkit_chat_container_print_new_message (WebKitChatContainer *view,
void webkit_chat_container_update_message (WebKitChatContainer *view, const QModelIndex &idx);
void webkit_chat_container_set_sender_image (WebKitChatContainer *view, ContactMethod *sender_contact_method, QVariant sender_image);
gboolean webkit_chat_container_is_ready (WebKitChatContainer *view);
void webkit_chat_container_set_display_links (WebKitChatContainer *view, bool display);
G_END_DECLS
......@@ -127,6 +127,14 @@
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_chatdisplaylinks">
<property name="label" translatable="yes">Show images and videos in chat window.</property>
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_searchentryplacescall">
<property name="label" translatable="yes">Entering a number in the search entry will place a new call.</property>
......
......@@ -73,6 +73,11 @@ ring.chatview = (function(){
var dev = {}; // ring.chatview.dev namespace
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame;
var messages = document.querySelector("#messages");
var displayLinksEnabled = false;
function setDisplayLinks(display) {
displayLinksEnabled = display;
}
/**
* Transform a date to a string group likes 1 hour ago.
......@@ -443,7 +448,7 @@ ring.chatview = (function(){
// Set the variables
chatview_message_text.innerHTML = getMessageHtml(message_text);
if (new_message)
if (new_message && displayLinksEnabled)
displayLinks(chatview_message_text);
chatview_message_sender.textContent = message_sender + ": ";
chatview_message_delivery_status.innerHTML = getMessageDeliveryStatusText(message_delivery_status);
......@@ -563,6 +568,7 @@ ring.chatview = (function(){
clearMessages: clearMessages,
clearSenderImages: clearSenderImages,
sendMessage: sendMessage,
setDisplayLinks: setDisplayLinks,
}
})();
......
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