blob: 0bc3ca19af9370bb3c880984b46c48c1cff82445 [file] [log] [blame]
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001/*
Stepan Salenikovichbe87d2c2016-01-25 14:14:34 -05002 * Copyright (C) 2015-2016 Savoir-faire Linux Inc.
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05003 * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050018 */
19
20#include "currentcallview.h"
21
22#include <gtk/gtk.h>
Stepan Salenikovich7e283552015-12-21 16:17:52 -050023#include <glib/gi18n.h>
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050024#include <call.h>
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050025#include <callmodel.h>
Stepan Salenikovich36c025c2015-03-03 19:06:44 -050026#include "utils/drawing.h"
27#include "video/video_widget.h"
Stepan Salenikovich4ac89f12015-03-10 16:48:47 -040028#include <video/previewmanager.h>
Stepan Salenikovich6f687072015-03-26 10:43:37 -040029#include <contactmethod.h>
30#include <person.h>
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040031#include <globalinstances.h>
32#include "native/pixbufmanipulator.h"
Stepan Salenikovicha448f602015-05-29 13:33:06 -040033#include <media/media.h>
34#include <media/text.h>
35#include <media/textrecording.h>
36#include "models/gtkqtreemodel.h"
Stepan Salenikovich67112d12015-06-16 16:57:06 -040037#include "ringnotify.h"
Edric Milaret58e71072016-03-21 12:16:37 -040038#include <codecmodel.h>
Stepan Salenikovichf6f42652015-07-15 12:46:14 -040039#include <account.h>
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -050040#include "utils/files.h"
Stepan Salenikoviche178e632015-11-06 13:31:19 -050041#include <clutter-gtk/clutter-gtk.h>
Stepan Salenikovichd2cad062016-01-08 13:43:49 -050042#include "chatview.h"
Stepan Salenikovich07107e92016-05-06 10:35:17 -040043#include <itemdataroles.h>
44#include <numbercategory.h>
Olivier Gregoire66e4df72016-06-17 18:39:05 -040045#include <smartinfohub.h>
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050046
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -050047static constexpr int CONTROLS_FADE_TIMEOUT = 3000000; /* microseconds */
48static constexpr int FADE_DURATION = 500; /* miliseconds */
49
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050050struct _CurrentCallView
51{
52 GtkBox parent;
53};
54
55struct _CurrentCallViewClass
56{
57 GtkBoxClass parent_class;
58};
59
60typedef struct _CurrentCallViewPrivate CurrentCallViewPrivate;
61
62struct _CurrentCallViewPrivate
63{
Stepan Salenikoviche178e632015-11-06 13:31:19 -050064 GtkWidget *hbox_call_info;
65 GtkWidget *hbox_call_controls;
Olivier Gregoire66e4df72016-06-17 18:39:05 -040066 GtkWidget *vbox_call_smartInfo;
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050067 GtkWidget *image_peer;
Stepan Salenikovich07107e92016-05-06 10:35:17 -040068 GtkWidget *label_name;
Nicolas Jager2e467c32017-01-18 08:52:23 -050069 GtkWidget *label_bestId;
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050070 GtkWidget *label_status;
71 GtkWidget *label_duration;
Olivier Gregoire66e4df72016-06-17 18:39:05 -040072 GtkWidget *label_smartinfo_description;
73 GtkWidget *label_smartinfo_value;
74 GtkWidget *label_smartinfo_general_information;
Stepan Salenikovichd2cad062016-01-08 13:43:49 -050075 GtkWidget *paned_call;
Stepan Salenikovich36c025c2015-03-03 19:06:44 -050076 GtkWidget *frame_video;
77 GtkWidget *video_widget;
Stepan Salenikovichd2cad062016-01-08 13:43:49 -050078 GtkWidget *frame_chat;
Stepan Salenikovicha448f602015-05-29 13:33:06 -040079 GtkWidget *togglebutton_chat;
Stepan Salenikovich77baa522015-07-07 15:29:14 -040080 GtkWidget *button_hangup;
Stepan Salenikovich7e283552015-12-21 16:17:52 -050081 GtkWidget *scalebutton_quality;
82 GtkWidget *checkbutton_autoquality;
83
aviau039001d2016-09-29 16:39:05 -040084 /* The webkit_chat_container is created once, then reused for all chat
85 * views */
86 GtkWidget *webkit_chat_container;
87
Stepan Salenikovich7e283552015-12-21 16:17:52 -050088 /* flag used to keep track of the video quality scale pressed state;
89 * we do not want to update the codec bitrate until the user releases the
90 * scale button */
91 gboolean quality_scale_pressed;
Stepan Salenikovicha448f602015-05-29 13:33:06 -040092
93 Call *call;
Stepan Salenikovich36c025c2015-03-03 19:06:44 -050094
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050095 QMetaObject::Connection state_change_connection;
96 QMetaObject::Connection call_details_connection;
Stepan Salenikovichc5f08152015-03-19 00:53:23 -040097 QMetaObject::Connection local_renderer_connection;
98 QMetaObject::Connection remote_renderer_connection;
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -050099
100 GSettings *settings;
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500101
102 // for clutter animations and to know when to fade in/out the overlays
103 ClutterTransition *fade_info;
104 ClutterTransition *fade_controls;
105 gint64 time_last_mouse_motion;
106 guint timer_fade;
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400107
108 // smart info
109 QMetaObject::Connection smartinfo_refresh_connection;
110 guint smartinfo_action;
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500111};
112
113G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX);
114
115#define CURRENT_CALL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CURRENT_CALL_VIEW_TYPE, CurrentCallViewPrivate))
116
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500117enum {
118 VIDEO_DOUBLE_CLICKED,
119 LAST_SIGNAL
120};
121
122static guint current_call_view_signals[LAST_SIGNAL] = { 0 };
123
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500124static void
125current_call_view_dispose(GObject *object)
126{
127 CurrentCallView *view;
128 CurrentCallViewPrivate *priv;
129
130 view = CURRENT_CALL_VIEW(object);
131 priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
132
133 QObject::disconnect(priv->state_change_connection);
134 QObject::disconnect(priv->call_details_connection);
Stepan Salenikovichc5f08152015-03-19 00:53:23 -0400135 QObject::disconnect(priv->local_renderer_connection);
136 QObject::disconnect(priv->remote_renderer_connection);
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400137 QObject::disconnect(priv->smartinfo_refresh_connection);
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500138 g_clear_object(&priv->settings);
139
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500140 g_source_remove(priv->timer_fade);
141
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400142 auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo");
143 g_signal_handler_disconnect(display_smartinfo, priv->smartinfo_action);
144
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500145 G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object);
146}
147
148static void
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500149show_chat_view(CurrentCallView *self)
150{
151 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
152 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
153
154 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE);
155}
156
157static void
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400158chat_toggled(GtkToggleButton *togglebutton, CurrentCallView *self)
159{
160 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
161 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
162
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400163 if (gtk_toggle_button_get_active(togglebutton)) {
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500164 gtk_widget_show_all(priv->frame_chat);
165 gtk_widget_grab_focus(priv->frame_chat);
Stepan Salenikovicha5129f62015-11-05 15:10:59 -0500166 } else {
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500167 gtk_widget_hide(priv->frame_chat);
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400168 }
169}
170
Stepan Salenikovichdaf3cb32016-10-12 16:39:42 -0400171static gboolean
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500172map_boolean_to_orientation(GValue *value, GVariant *variant, G_GNUC_UNUSED gpointer user_data)
173{
174 if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
175 if (g_variant_get_boolean(variant)) {
176 // true, chat should be horizontal (to the right)
177 g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL);
178 } else {
179 // false, chat should be vertical (at the bottom)
180 g_value_set_enum(value, GTK_ORIENTATION_VERTICAL);
181 }
182 return TRUE;
183 }
184 return FALSE;
185}
186
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500187static gboolean
188timeout_check_last_motion_event(CurrentCallView *self)
189{
190 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), G_SOURCE_REMOVE);
191 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
192
193 auto current_time = g_get_monotonic_time();
194 if (current_time - priv->time_last_mouse_motion >= CONTROLS_FADE_TIMEOUT) {
195 // timeout has passed, hide the controls
196 if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->fade_info)) == CLUTTER_TIMELINE_BACKWARD) {
197 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_FORWARD);
198 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_FORWARD);
199 if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->fade_info))) {
200 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_info));
201 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_controls));
202 clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_info));
203 clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_controls));
204 }
205 }
206 }
207
208 return G_SOURCE_CONTINUE;
209}
210
211static gboolean
212mouse_moved(CurrentCallView *self)
213{
214 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE);
215 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
216
217 priv->time_last_mouse_motion = g_get_monotonic_time();
218
219 // since the mouse moved, make sure the controls are shown
220 if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->fade_info)) == CLUTTER_TIMELINE_FORWARD) {
221 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD);
222 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD);
223 if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->fade_info))) {
224 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_info));
225 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->fade_controls));
226 clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_info));
227 clutter_timeline_start(CLUTTER_TIMELINE(priv->fade_controls));
228 }
229 }
230
231 return FALSE; // propogate event
232}
233
234static ClutterTransition *
235create_fade_out_transition()
236{
237 auto transition = clutter_property_transition_new("opacity");
238 clutter_transition_set_from(transition, G_TYPE_UINT, 255);
239 clutter_transition_set_to(transition, G_TYPE_UINT, 0);
240 clutter_timeline_set_duration(CLUTTER_TIMELINE(transition), FADE_DURATION);
241 clutter_timeline_set_repeat_count(CLUTTER_TIMELINE(transition), 0);
242 clutter_timeline_set_progress_mode(CLUTTER_TIMELINE(transition), CLUTTER_EASE_IN_OUT_CUBIC);
243 return transition;
244}
245
Stepan Salenikovich5ed1b492015-11-13 14:03:31 -0500246static gboolean
247video_widget_focus(GtkWidget *widget, GtkDirectionType direction, CurrentCallView *self)
248{
249 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE);
250 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
251
252 // if this widget already has focus, we want the focus to move to the next widget, otherwise we
253 // will get stuck in a focus loop on the buttons
254 if (gtk_widget_has_focus(widget))
255 return FALSE;
256
257 // otherwise we want the focus to go to and change between the call control buttons
258 if (gtk_widget_child_focus(GTK_WIDGET(priv->hbox_call_controls), direction)) {
259 // selected a child, make sure call controls are shown
260 mouse_moved(self);
261 return TRUE;
262 }
263
264 // did not select the next child, propogate the event
265 return FALSE;
266}
267
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500268static GtkBox *
269gtk_scale_button_get_box(GtkScaleButton *button)
270{
271 GtkWidget *box = NULL;
272 if (auto dock = gtk_scale_button_get_popup(button)) {
273 // the dock is a popover which contains the box
274 box = gtk_bin_get_child(GTK_BIN(dock));
275 if (box) {
276 if (GTK_IS_FRAME(box)) {
277 // support older versions of gtk; the box used to be in a frame
278 box = gtk_bin_get_child(GTK_BIN(box));
279 }
280 }
281 }
282
283 return GTK_BOX(box);
284}
285
286/**
287 * This gets the GtkScaleButtonScale widget (which is a GtkScale) from the
288 * given GtkScaleButton in order to be able to modify its properties and connect
289 * to its signals
290 */
291static GtkScale *
292gtk_scale_button_get_scale(GtkScaleButton *button)
293{
294 GtkScale *scale = NULL;
295
296 if (auto box = gtk_scale_button_get_box(button)) {
297 GList *children = gtk_container_get_children(GTK_CONTAINER(box));
298 for (GList *c = children; c && !scale; c = c->next) {
299 if (GTK_IS_SCALE(c->data))
300 scale = GTK_SCALE(c->data);
301 }
302 g_list_free(children);
303 }
304
305 return scale;
306}
307
308static void
309set_quality(Call *call, gboolean auto_quality_on, double desired_quality)
310{
311 /* set auto quality true or false, also set the bitrate and quality values;
312 * the slider is from 0 to 100, use the min and max vals to scale each value accordingly */
313 if (const auto& codecModel = call->account()->codecModel()) {
314 const auto& videoCodecs = codecModel->videoCodecs();
315
316 for (int i=0; i < videoCodecs->rowCount();i++) {
317 const auto& idx = videoCodecs->index(i,0);
318
319 if (auto_quality_on) {
320 // g_debug("enable auto quality");
321 videoCodecs->setData(idx, "true", CodecModel::Role::AUTO_QUALITY_ENABLED);
322 } else {
323 auto min_bitrate = idx.data(static_cast<int>(CodecModel::Role::MIN_BITRATE)).toInt();
324 auto max_bitrate = idx.data(static_cast<int>(CodecModel::Role::MAX_BITRATE)).toInt();
325 auto min_quality = idx.data(static_cast<int>(CodecModel::Role::MIN_QUALITY)).toInt();
326 auto max_quality = idx.data(static_cast<int>(CodecModel::Role::MAX_QUALITY)).toInt();
327
328 // g_debug("bitrate min: %d, max: %d, quality min: %d, max: %d", min_bitrate, max_bitrate, min_quality, max_quality);
329
330 double bitrate;
331 bitrate = min_bitrate + (double)(max_bitrate - min_bitrate)*(desired_quality/100.0);
332 if (bitrate < 0) bitrate = 0;
333
334 double quality;
335 // note: a lower value means higher quality
336 quality = (double)min_quality - (min_quality - max_quality)*(desired_quality/100.0);
337 if (quality < 0) quality = 0;
338
339 // g_debug("disable auto quality; %% quality: %d; bitrate: %d; quality: %d", (int)desired_quality, (int)bitrate, (int)quality);
340 videoCodecs->setData(idx, "false", CodecModel::Role::AUTO_QUALITY_ENABLED);
341 videoCodecs->setData(idx, QString::number((int)bitrate), CodecModel::Role::BITRATE);
342 videoCodecs->setData(idx, QString::number((int)quality), CodecModel::Role::QUALITY);
343 }
344 }
345 codecModel << CodecModel::EditAction::SAVE;
346 }
347}
348
349static void
350autoquality_toggled(GtkToggleButton *button, CurrentCallView *self)
351{
352 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
353 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
354
355 gboolean auto_quality_on = gtk_toggle_button_get_active(button);
356
357 auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality));
358 auto plus_button = gtk_scale_button_get_plus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality));
359 auto minus_button = gtk_scale_button_get_minus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality));
360
361 gtk_widget_set_sensitive(GTK_WIDGET(scale), !auto_quality_on);
362 gtk_widget_set_sensitive(plus_button, !auto_quality_on);
363 gtk_widget_set_sensitive(minus_button, !auto_quality_on);
364
365 double desired_quality = gtk_scale_button_get_value(GTK_SCALE_BUTTON(priv->scalebutton_quality));
366
367 if (priv->call)
368 set_quality(priv->call, auto_quality_on, desired_quality);
369}
370
371static void
372quality_changed(GtkScaleButton *button, G_GNUC_UNUSED gdouble value, CurrentCallView *self)
373{
374 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
375 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
376
377 /* no need to upate quality if auto quality is enabled */
378 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality))) return;
379
380 /* only update if the scale button is released, to reduce the number of updates */
381 if (priv->quality_scale_pressed) return;
382
383 /* we get the value directly from the widget, in case this function is not
384 * called from the event */
385 if (priv->call)
386 set_quality(priv->call, FALSE, gtk_scale_button_get_value(button));
387}
388
389static gboolean
390quality_button_pressed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, CurrentCallView *self)
391{
392 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE);
393 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
394
395 priv->quality_scale_pressed = TRUE;
396
397 return GDK_EVENT_PROPAGATE;
398}
399
400static gboolean
401quality_button_released(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, CurrentCallView *self)
402{
403 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE);
404 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
405
406 priv->quality_scale_pressed = FALSE;
407
408 /* now make sure the quality gets updated */
409 quality_changed(GTK_SCALE_BUTTON(priv->scalebutton_quality), 0, self);
410
411 return GDK_EVENT_PROPAGATE;
412}
413
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400414static void
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500415current_call_view_init(CurrentCallView *view)
416{
417 gtk_widget_init_template(GTK_WIDGET(view));
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400418
419 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
420
Guillaume Roguezbf686102017-04-11 12:27:34 -0400421 // CSS styles
422 auto provider = gtk_css_provider_new();
Stepan Salenikovicha06e4432017-04-14 11:12:34 -0400423 gtk_css_provider_load_from_data(provider,
424 ".smartinfo-block-style { color: #8ae234; background-color: rgba(1, 1, 1, 0.33); }",
425 -1, nullptr
426 );
Guillaume Roguezbf686102017-04-11 12:27:34 -0400427 gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()),
428 GTK_STYLE_PROVIDER(provider),
429 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
430
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500431 /* create video widget and overlay the call info and controls on it */
432 priv->video_widget = video_widget_new();
433 gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget);
434 gtk_widget_show_all(priv->frame_video);
435
436 auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->video_widget));
437 auto actor_info = gtk_clutter_actor_new_with_contents(priv->hbox_call_info);
438 auto actor_controls = gtk_clutter_actor_new_with_contents(priv->hbox_call_controls);
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400439 auto actor_smartInfo = gtk_clutter_actor_new_with_contents(priv->vbox_call_smartInfo);
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500440
441 clutter_actor_add_child(stage, actor_info);
442 clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL);
443 clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START);
444
445 clutter_actor_add_child(stage, actor_controls);
446 clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER);
447 clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END);
448
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400449 clutter_actor_add_child(stage, actor_smartInfo);
450 clutter_actor_set_x_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_END);
451 clutter_actor_set_y_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_START);
452 ClutterMargin clutter_margin_smartInfo;
453 clutter_margin_smartInfo.top = 50;
454 clutter_margin_smartInfo.right = 10;
455 clutter_actor_set_margin (actor_smartInfo, &clutter_margin_smartInfo);
456
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500457 /* add fade in and out states to the info and controls */
458 priv->time_last_mouse_motion = g_get_monotonic_time();
459 priv->fade_info = create_fade_out_transition();
460 priv->fade_controls = create_fade_out_transition();
461 clutter_actor_add_transition(actor_info, "fade_info", priv->fade_info);
462 clutter_actor_add_transition(actor_controls, "fade_controls", priv->fade_controls);
463 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD);
464 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD);
465 clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_info));
466 clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_controls));
467
468 /* have a timer check every 1 second if the controls should fade out */
469 priv->timer_fade = g_timeout_add(1000, (GSourceFunc)timeout_check_last_motion_event, view);
470
471 /* connect to the mouse motion event to reset the last moved time */
472 g_signal_connect_swapped(priv->video_widget, "motion-notify-event", G_CALLBACK(mouse_moved), view);
473 g_signal_connect_swapped(priv->video_widget, "button-press-event", G_CALLBACK(mouse_moved), view);
474 g_signal_connect_swapped(priv->video_widget, "button-release-event", G_CALLBACK(mouse_moved), view);
475
Stepan Salenikovich5ed1b492015-11-13 14:03:31 -0500476 /* manually handle the focus of the video widget to be able to focus on the call controls */
477 g_signal_connect(priv->video_widget, "focus", G_CALLBACK(video_widget_focus), view);
478
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500479 /* toggle whether or not the chat is displayed */
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400480 g_signal_connect(priv->togglebutton_chat, "toggled", G_CALLBACK(chat_toggled), view);
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400481
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500482 /* bind the chat orientation to the gsetting */
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500483 priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL);
484 g_settings_bind_with_mapping(priv->settings, "chat-pane-horizontal",
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500485 priv->paned_call, "orientation",
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500486 G_SETTINGS_BIND_GET,
487 map_boolean_to_orientation,
488 nullptr, nullptr, nullptr);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500489
490 g_signal_connect(priv->scalebutton_quality, "value-changed", G_CALLBACK(quality_changed), view);
491 /* customize the quality button scale */
492 if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(priv->scalebutton_quality))) {
493 priv->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality", "Auto"));
494 gtk_widget_show(priv->checkbutton_autoquality);
495 gtk_box_pack_start(GTK_BOX(scale_box), priv->checkbutton_autoquality, FALSE, TRUE, 0);
496 g_signal_connect(priv->checkbutton_autoquality, "toggled", G_CALLBACK(autoquality_toggled), view);
497 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality), TRUE);
498 }
499 if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality))) {
500 g_signal_connect(scale, "button-press-event", G_CALLBACK(quality_button_pressed), view);
501 g_signal_connect(scale, "button-release-event", G_CALLBACK(quality_button_released), view);
502 }
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500503}
504
505static void
506current_call_view_class_init(CurrentCallViewClass *klass)
507{
508 G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose;
509
510 gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass),
511 "/cx/ring/RingGnome/currentcallview.ui");
512
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500513 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_info);
514 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_controls);
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400515 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, vbox_call_smartInfo);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500516 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, image_peer);
Stepan Salenikovich07107e92016-05-06 10:35:17 -0400517 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_name);
Nicolas Jager2e467c32017-01-18 08:52:23 -0500518 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_bestId);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500519 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status);
520 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration);
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400521 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_description);
522 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_value);
523 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_general_information);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500524 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, paned_call);
Stepan Salenikovich36c025c2015-03-03 19:06:44 -0500525 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500526 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_chat);
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400527 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat);
Stepan Salenikovich77baa522015-07-07 15:29:14 -0400528 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, button_hangup);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500529 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, scalebutton_quality);
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500530
531 current_call_view_signals[VIDEO_DOUBLE_CLICKED] = g_signal_new (
532 "video-double-clicked",
533 G_TYPE_FROM_CLASS(klass),
534 (GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION),
535 0,
536 nullptr,
537 nullptr,
538 g_cclosure_marshal_VOID__VOID,
539 G_TYPE_NONE, 0);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500540}
541
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500542static void
543update_state(CurrentCallView *view, Call *call)
544{
545 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
546
Stepan Salenikovich7ec8fe82015-06-02 18:26:39 -0400547 gchar *status = g_strdup_printf("%s", call->toHumanStateName().toUtf8().constData());
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500548
Stepan Salenikovich7ec8fe82015-06-02 18:26:39 -0400549 gtk_label_set_text(GTK_LABEL(priv->label_status), status);
550
551 g_free(status);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500552}
553
554static void
555update_details(CurrentCallView *view, Call *call)
556{
557 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
558
559 /* update call duration */
560 QByteArray ba_length = call->length().toLocal8Bit();
561 gtk_label_set_text(GTK_LABEL(priv->label_duration), ba_length.constData());
562}
563
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400564static void
565update_smartInfo(CurrentCallView *view)
566{
567 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
568
569 if (!SmartInfoHub::instance().isConference()) {
570 gchar* general_information = g_strdup_printf("Call ID: %s", SmartInfoHub::instance().callID().toStdString().c_str());
571 gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_general_information), general_information);
572 g_free(general_information);
573
574 gchar* description = g_strdup_printf("You\n"
575 "Framerate:\n"
576 "Video codec:\n"
577 "Audio codec:\n"
578 "Resolution:\n\n"
579 "Peer\n"
580 "Framerate:\n"
581 "Video codec:\n"
582 "Audio codec:\n"
583 "Resolution:");
584 gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_description),description);
585 g_free(description);
586
587 gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d\n\n\n%f\n%s\n%s\n%dx%d",
588 (double)SmartInfoHub::instance().localFps(),
589 SmartInfoHub::instance().localVideoCodec().toStdString().c_str(),
590 SmartInfoHub::instance().localAudioCodec().toStdString().c_str(),
591 SmartInfoHub::instance().localWidth(),
592 SmartInfoHub::instance().localHeight(),
593 (double)SmartInfoHub::instance().remoteFps(),
594 SmartInfoHub::instance().remoteVideoCodec().toStdString().c_str(),
595 SmartInfoHub::instance().remoteAudioCodec().toStdString().c_str(),
596 SmartInfoHub::instance().remoteWidth(),
597 SmartInfoHub::instance().remoteHeight());
598 gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_value),value);
599 g_free(value);
600 } else {
601 gchar* general_information = g_strdup_printf("Conference ID: %s", SmartInfoHub::instance().callID().toStdString().c_str());
602 gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_general_information), general_information);
603 g_free(general_information);
604
605 gchar* description = g_strdup_printf("You\n"
606 "Framerate:\n"
607 "Video codec:\n"
608 "Audio codec:\n"
609 "Resolution:");
610 gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_description),description);
611 g_free(description);
612
613 gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d",
614 (double)SmartInfoHub::instance().localFps(),
615 SmartInfoHub::instance().localVideoCodec().toStdString().c_str(),
616 SmartInfoHub::instance().localAudioCodec().toStdString().c_str(),
617 SmartInfoHub::instance().localWidth(),
618 SmartInfoHub::instance().localHeight());
619 gtk_label_set_text(GTK_LABEL(priv->label_smartinfo_value),value);
620 g_free(value);
621 }
622}
623
624
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500625static gboolean
626on_button_press_in_video_event(GtkWidget *self, GdkEventButton *event, CurrentCallView *view)
627{
628 g_return_val_if_fail(IS_VIDEO_WIDGET(self), FALSE);
629 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
630
631 /* on double click */
632 if (event->type == GDK_2BUTTON_PRESS) {
633 g_debug("double click in video");
634 g_signal_emit(G_OBJECT(view), current_call_view_signals[VIDEO_DOUBLE_CLICKED], 0);
635 }
636
637 return GDK_EVENT_PROPAGATE;
638}
639
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400640static void
641toggle_smartinfo(GSimpleAction* action, G_GNUC_UNUSED GVariant* state, GtkWidget* vbox_call_smartInfo)
642{
643 if (g_variant_get_boolean(g_action_get_state(G_ACTION(action)))) {
644 gtk_widget_show(vbox_call_smartInfo);
645 } else {
646 gtk_widget_hide(vbox_call_smartInfo);
647 }
648}
649
Stepan Salenikovich09e0b782016-09-07 16:28:50 -0400650static void
651set_call_info(CurrentCallView *view, Call *call) {
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500652 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
653
Stepan Salenikovich09e0b782016-09-07 16:28:50 -0400654 priv->call = call;
Stepan Salenikovich6f687072015-03-26 10:43:37 -0400655
656 /* get call image */
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -0400657 QVariant var_i = GlobalInstances::pixmapManipulator().callPhoto(priv->call, QSize(60, 60), false);
Stepan Salenikovich6f687072015-03-26 10:43:37 -0400658 std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>();
659 gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_peer), image.get());
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500660
661 /* get name */
Stepan Salenikovich09e0b782016-09-07 16:28:50 -0400662 auto name = call->formattedName();
663 gtk_label_set_text(GTK_LABEL(priv->label_name), name.toUtf8().constData());
Stepan Salenikovich07107e92016-05-06 10:35:17 -0400664
Nicolas Jager4a1f0642017-01-17 14:01:19 -0500665 /* get contact best id, if different from name */
666 auto contactId = call->peerContactMethod()->getBestId();
667 if (name != contactId) {
668 auto cat_contactId = g_strdup_printf("(%s) %s"
Stepan Salenikovich07107e92016-05-06 10:35:17 -0400669 ,priv->call->peerContactMethod()->category()->name().toUtf8().constData()
Nicolas Jager4a1f0642017-01-17 14:01:19 -0500670 ,contactId.toUtf8().constData());
Nicolas Jager2e467c32017-01-18 08:52:23 -0500671 gtk_label_set_text(GTK_LABEL(priv->label_bestId), cat_contactId);
Nicolas Jager4a1f0642017-01-17 14:01:19 -0500672 g_free(cat_contactId);
Nicolas Jager2e467c32017-01-18 08:52:23 -0500673 gtk_widget_show(priv->label_bestId);
Stepan Salenikovich07107e92016-05-06 10:35:17 -0400674 }
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500675
676 /* change some things depending on call state */
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400677 update_state(view, priv->call);
678 update_details(view, priv->call);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500679
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400680 priv->smartinfo_refresh_connection = QObject::connect(
681 &SmartInfoHub::instance(),
682 &SmartInfoHub::changed,
683 [view, priv]() { update_smartInfo(view); }
684 );
685
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500686 priv->state_change_connection = QObject::connect(
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400687 priv->call,
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500688 &Call::stateChanged,
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400689 [view, priv]() { update_state(view, priv->call); }
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500690 );
691
692 priv->call_details_connection = QObject::connect(
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400693 priv->call,
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500694 static_cast<void (Call::*)(void)>(&Call::changed),
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400695 [view, priv]() { update_details(view, priv->call); }
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500696 );
Stepan Salenikovich36c025c2015-03-03 19:06:44 -0500697
Stepan Salenikovich36c025c2015-03-03 19:06:44 -0500698 /* check if we already have a renderer */
Stepan Salenikovich0f693232015-04-22 10:45:08 -0400699 video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400700 priv->call->videoRenderer(),
Stepan Salenikovich0f693232015-04-22 10:45:08 -0400701 VIDEO_RENDERER_REMOTE);
Stepan Salenikovich36c025c2015-03-03 19:06:44 -0500702
Stepan Salenikovich8e5c9d02015-03-11 14:07:10 -0400703 /* callback for remote renderer */
Stepan Salenikovichc5f08152015-03-19 00:53:23 -0400704 priv->remote_renderer_connection = QObject::connect(
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400705 priv->call,
Stepan Salenikovich9c1f6682015-03-09 16:21:28 -0400706 &Call::videoStarted,
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400707 [priv](Video::Renderer *renderer) {
Stepan Salenikovich0f693232015-04-22 10:45:08 -0400708 video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
709 renderer,
710 VIDEO_RENDERER_REMOTE);
Stepan Salenikovich36c025c2015-03-03 19:06:44 -0500711 }
712 );
Stepan Salenikovich4ac89f12015-03-10 16:48:47 -0400713
Stepan Salenikovich8e5c9d02015-03-11 14:07:10 -0400714 /* local renderer */
Guillaume Roguez5d1514b2015-10-22 15:55:31 -0400715 if (Video::PreviewManager::instance().isPreviewing())
Stepan Salenikovich0f693232015-04-22 10:45:08 -0400716 video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
Guillaume Roguez5d1514b2015-10-22 15:55:31 -0400717 Video::PreviewManager::instance().previewRenderer(),
Stepan Salenikovich0f693232015-04-22 10:45:08 -0400718 VIDEO_RENDERER_LOCAL);
Stepan Salenikovich8e5c9d02015-03-11 14:07:10 -0400719
720 /* callback for local renderer */
Stepan Salenikovichc5f08152015-03-19 00:53:23 -0400721 priv->local_renderer_connection = QObject::connect(
Guillaume Roguez5d1514b2015-10-22 15:55:31 -0400722 &Video::PreviewManager::instance(),
Stepan Salenikovich8e5c9d02015-03-11 14:07:10 -0400723 &Video::PreviewManager::previewStarted,
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400724 [priv](Video::Renderer *renderer) {
Stepan Salenikovich0f693232015-04-22 10:45:08 -0400725 video_widget_push_new_renderer(VIDEO_WIDGET(priv->video_widget),
726 renderer,
727 VIDEO_RENDERER_LOCAL);
Stepan Salenikovich8e5c9d02015-03-11 14:07:10 -0400728 }
729 );
Stepan Salenikovichbfe9ac62015-03-11 12:49:20 -0400730
Julien Grossholtza0d4f102015-10-22 14:24:17 -0400731 /* handle video widget button click event */
732 g_signal_connect(priv->video_widget, "button-press-event", G_CALLBACK(video_widget_on_button_press_in_screen_event), priv->call);
733
734 /* handle video widget drag and drop*/
735 g_signal_connect(priv->video_widget, "drag-data-received", G_CALLBACK(video_widget_on_drag_data_received), priv->call);
736
Stepan Salenikovichbfe9ac62015-03-11 12:49:20 -0400737 /* catch double click to make full screen */
738 g_signal_connect(priv->video_widget, "button-press-event",
739 G_CALLBACK(on_button_press_in_video_event),
740 view);
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400741
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400742 /* handle smartinfo in right click menu */
743 auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), "display-smartinfo");
744 priv->smartinfo_action = g_signal_connect(display_smartinfo,
745 "notify::state",
746 G_CALLBACK(toggle_smartinfo),
747 priv->vbox_call_smartInfo);
748
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500749 /* check if auto quality is enabled or not; */
750 if (const auto& codecModel = priv->call->account()->codecModel()) {
751 const auto& videoCodecs = codecModel->videoCodecs();
752 if (videoCodecs->rowCount() > 0) {
753 /* we only need to check the first codec since by default it is ON for all, and the
754 * gnome client sets its ON or OFF for all codecs as well */
755 const auto& idx = videoCodecs->index(0,0);
756 auto auto_quality_enabled = idx.data(static_cast<int>(CodecModel::Role::AUTO_QUALITY_ENABLED)).toString() == "true";
757 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality), auto_quality_enabled);
758
759 // TODO: save the manual quality setting in the client and set the slider to that value here;
760 // the daemon resets the bitrate/quality between each call, and the default may be
761 // different for each codec, so there is no reason to check it here
762 }
763 }
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500764
765 /* init chat view */
aviau039001d2016-09-29 16:39:05 -0400766 auto chat_view = chat_view_new_call(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container), priv->call);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500767 gtk_container_add(GTK_CONTAINER(priv->frame_chat), chat_view);
768
769 /* check if there were any chat notifications and open the chat view if so */
Stepan Salenikovich26cd1602016-01-20 13:43:17 -0500770 if (ring_notify_close_chat_notification(priv->call->peerContactMethod()))
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500771 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE);
772
773 /* show chat view on any new incoming messages */
774 g_signal_connect_swapped(chat_view, "new-messages-displayed", G_CALLBACK(show_chat_view), view);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500775}
Stepan Salenikovich09e0b782016-09-07 16:28:50 -0400776
777GtkWidget *
aviau039001d2016-09-29 16:39:05 -0400778current_call_view_new(Call *call, WebKitChatContainer *webkit_chat_container)
Stepan Salenikovich09e0b782016-09-07 16:28:50 -0400779{
780 auto self = g_object_new(CURRENT_CALL_VIEW_TYPE, NULL);
aviau039001d2016-09-29 16:39:05 -0400781 CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
782 priv->webkit_chat_container = GTK_WIDGET(webkit_chat_container);
Stepan Salenikovich09e0b782016-09-07 16:28:50 -0400783 set_call_info(CURRENT_CALL_VIEW(self), call);
784
785 return GTK_WIDGET(self);
786}
787
788Call*
789current_call_view_get_call(CurrentCallView *self)
790{
791 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), nullptr);
792 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
793
794 return priv->call;
795}