blob: 578761e2b1e3d381c47025d74496fbb12d549738 [file] [log] [blame]
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001/*
Guillaume Roguez77c579d2018-01-30 15:54:02 -05002 * Copyright (C) 2015-2018 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
Sébastien Blin55bff9d2017-10-03 15:15:23 -040022// Gtk
23#include <clutter-gtk/clutter-gtk.h>
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050024#include <gtk/gtk.h>
Stepan Salenikovich7e283552015-12-21 16:17:52 -050025#include <glib/gi18n.h>
Sébastien Blin55bff9d2017-10-03 15:15:23 -040026
27// Lrc
Sébastien Blin55bff9d2017-10-03 15:15:23 -040028#include <api/conversationmodel.h>
29#include <api/contact.h>
30#include <api/contactmodel.h>
31#include <api/newcallmodel.h>
Sébastien Blinceb98632018-07-23 13:59:18 -040032#include <api/newcodecmodel.h>
Sébastien Blin55bff9d2017-10-03 15:15:23 -040033#include <globalinstances.h>
Olivier Gregoire66e4df72016-06-17 18:39:05 -040034#include <smartinfohub.h>
Sébastien Blin55bff9d2017-10-03 15:15:23 -040035#include <video/previewmanager.h>
36
37// Client
38#include "chatview.h"
39#include "native/pixbufmanipulator.h"
40#include "ringnotify.h"
41#include "utils/drawing.h"
42#include "utils/files.h"
43#include "video/video_widget.h"
44
Sébastien Blin784f2a32018-05-30 17:31:13 -040045#include <iostream>
46
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050047namespace { namespace details
48{
49class CppImpl;
50}}
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -050051
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050052struct _CurrentCallView
53{
54 GtkBox parent;
55};
56
57struct _CurrentCallViewClass
58{
59 GtkBoxClass parent_class;
60};
61
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050062struct CurrentCallViewPrivate
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050063{
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;
AmarOke7c02972017-07-17 15:21:20 -040080 GtkWidget *togglebutton_muteaudio;
81 GtkWidget *togglebutton_mutevideo;
Sébastien Blin784f2a32018-05-30 17:31:13 -040082 GtkWidget *togglebutton_transfer;
83 GtkWidget* siptransfer_popover;
84 GtkWidget* siptransfer_filter_entry;
85 GtkWidget* list_conversations;
AmarOke7c02972017-07-17 15:21:20 -040086 GtkWidget *togglebutton_hold;
Sébastien Blin55bff9d2017-10-03 15:15:23 -040087 GtkWidget *togglebutton_record;
Stepan Salenikovich77baa522015-07-07 15:29:14 -040088 GtkWidget *button_hangup;
Stepan Salenikovich7e283552015-12-21 16:17:52 -050089 GtkWidget *scalebutton_quality;
90 GtkWidget *checkbutton_autoquality;
Sébastien Blin366243f2017-11-03 14:14:54 -040091 GtkWidget *chat_view;
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050092 GtkWidget *webkit_chat_container; // The webkit_chat_container is created once, then reused for all chat views
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -050093
94 GSettings *settings;
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -050095
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050096 details::CppImpl* cpp; ///< Non-UI and C++ only code
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050097};
98
99G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX);
100
101#define CURRENT_CALL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CURRENT_CALL_VIEW_TYPE, CurrentCallViewPrivate))
102
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500103enum {
104 VIDEO_DOUBLE_CLICKED,
105 LAST_SIGNAL
106};
107
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500108//==============================================================================
109
110namespace { namespace details
111{
112
113static constexpr int CONTROLS_FADE_TIMEOUT = 3000000; /* microseconds */
114static constexpr int FADE_DURATION = 500; /* miliseconds */
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500115static guint current_call_view_signals[LAST_SIGNAL] = { 0 };
116
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500117namespace // Helpers
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500118{
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400119
Stepan Salenikovichdaf3cb32016-10-12 16:39:42 -0400120static gboolean
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500121map_boolean_to_orientation(GValue* value, GVariant* variant, G_GNUC_UNUSED gpointer user_data)
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500122{
123 if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
124 if (g_variant_get_boolean(variant)) {
125 // true, chat should be horizontal (to the right)
126 g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL);
127 } else {
128 // false, chat should be vertical (at the bottom)
129 g_value_set_enum(value, GTK_ORIENTATION_VERTICAL);
130 }
131 return TRUE;
132 }
133 return FALSE;
134}
135
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500136static ClutterTransition*
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500137create_fade_out_transition()
138{
139 auto transition = clutter_property_transition_new("opacity");
140 clutter_transition_set_from(transition, G_TYPE_UINT, 255);
141 clutter_transition_set_to(transition, G_TYPE_UINT, 0);
142 clutter_timeline_set_duration(CLUTTER_TIMELINE(transition), FADE_DURATION);
143 clutter_timeline_set_repeat_count(CLUTTER_TIMELINE(transition), 0);
144 clutter_timeline_set_progress_mode(CLUTTER_TIMELINE(transition), CLUTTER_EASE_IN_OUT_CUBIC);
145 return transition;
146}
147
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500148static GtkBox *
149gtk_scale_button_get_box(GtkScaleButton *button)
150{
151 GtkWidget *box = NULL;
152 if (auto dock = gtk_scale_button_get_popup(button)) {
153 // the dock is a popover which contains the box
154 box = gtk_bin_get_child(GTK_BIN(dock));
155 if (box) {
156 if (GTK_IS_FRAME(box)) {
157 // support older versions of gtk; the box used to be in a frame
158 box = gtk_bin_get_child(GTK_BIN(box));
159 }
160 }
161 }
162
163 return GTK_BOX(box);
164}
165
166/**
167 * This gets the GtkScaleButtonScale widget (which is a GtkScale) from the
168 * given GtkScaleButton in order to be able to modify its properties and connect
169 * to its signals
170 */
171static GtkScale *
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500172gtk_scale_button_get_scale(GtkScaleButton* button)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500173{
174 GtkScale *scale = NULL;
175
176 if (auto box = gtk_scale_button_get_box(button)) {
177 GList *children = gtk_container_get_children(GTK_CONTAINER(box));
178 for (GList *c = children; c && !scale; c = c->next) {
179 if (GTK_IS_SCALE(c->data))
180 scale = GTK_SCALE(c->data);
181 }
182 g_list_free(children);
183 }
184
185 return scale;
186}
187
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500188} // namespace
189
190class CppImpl
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500191{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500192public:
193 explicit CppImpl(CurrentCallView& widget);
194 ~CppImpl();
195
196 void init();
197 void setup(WebKitChatContainer* chat_widget,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400198 AccountInfoPointer const & account_info,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500199 lrc::api::conversation::Info* conversation);
Sébastien Blin784f2a32018-05-30 17:31:13 -0400200 void add_transfer_contact(const std::string& uri);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500201
202 void insertControls();
203 void checkControlsFading();
204
205 CurrentCallView* self = nullptr; // The GTK widget itself
206 CurrentCallViewPrivate* widgets = nullptr;
207
208 lrc::api::conversation::Info* conversation = nullptr;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400209 AccountInfoPointer const *accountInfo = nullptr;
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500210
211 QMetaObject::Connection state_change_connection;
212 QMetaObject::Connection local_renderer_connection;
213 QMetaObject::Connection remote_renderer_connection;
214 QMetaObject::Connection new_message_connection;
215 QMetaObject::Connection smartinfo_refresh_connection;
216
217 // for clutter animations and to know when to fade in/out the overlays
218 ClutterTransition* fade_info = nullptr;
219 ClutterTransition* fade_controls = nullptr;
220 gint64 time_last_mouse_motion = 0;
221 guint timer_fade = 0;
222
223 /* flag used to keep track of the video quality scale pressed state;
224 * we do not want to update the codec bitrate until the user releases the
225 * scale button */
226 gboolean quality_scale_pressed = FALSE;
227 gulong insert_controls_id = 0;
228 guint smartinfo_action = 0;
229
230private:
231 CppImpl() = delete;
232 CppImpl(const CppImpl&) = delete;
233 CppImpl& operator=(const CppImpl&) = delete;
234
235 void setCallInfo();
236 void updateDetails();
237 void updateState();
238 void updateNameAndPhoto();
239 void updateSmartInfo();
240};
241
242inline namespace gtk_callbacks
243{
244
245static void
Sébastien Blinceb98632018-07-23 13:59:18 -0400246set_call_quality(CurrentCallView* view, bool auto_quality_on, double desired_quality)
247{
248 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
249
250 auto videoCodecs = (*priv->cpp->accountInfo)->codecModel->getVideoCodecs();
251 for (const auto& codec : videoCodecs) {
252 if (auto_quality_on) {
253 (*priv->cpp->accountInfo)->codecModel->autoQuality(codec.id, true);
254 } else {
255 (*priv->cpp->accountInfo)->codecModel->autoQuality(codec.id, false);
256 double min_bitrate = 0., max_bitrate = 0., min_quality = 0., max_quality = 0.;
257 try {
258 min_bitrate = std::stoi(codec.min_bitrate);
259 max_bitrate = std::stoi(codec.max_bitrate);
260 min_quality = std::stoi(codec.min_quality);
261 max_quality = std::stoi(codec.max_quality);
262 } catch (...) {
263 g_error("Cannot convert a codec value to an int, abort");
264 break;
265 }
266
267 double bitrate = min_bitrate + (max_bitrate - min_bitrate)*(desired_quality/100.0);
268 if (bitrate < 0) bitrate = 0;
269 (*priv->cpp->accountInfo)->codecModel->bitrate(codec.id, bitrate);
270
271 // note: a lower value means higher quality
272 double quality = min_quality - (min_quality - max_quality)*(desired_quality/100.0);
273 if (quality < 0) quality = 0;
274 (*priv->cpp->accountInfo)->codecModel->quality(codec.id, quality);
275 }
276 }
277}
278
279static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500280on_new_chat_interactions(CurrentCallView* view)
281{
282 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
283 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
284
285 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE);
286}
287
288static void
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400289set_record_animation(CurrentCallViewPrivate* priv)
290{
291 auto callToRender = priv->cpp->conversation->callId;
292 if (!priv->cpp->conversation->confId.empty())
293 callToRender = priv->cpp->conversation->confId;
Sébastien Blin07f844a2018-07-12 12:07:39 -0400294 bool nextStatus = (*priv->cpp->accountInfo)->callModel->isRecording(callToRender);
295 bool currentStatus = (*priv->cpp->accountInfo)->callModel->isRecording(callToRender);
296 if (nextStatus != currentStatus) {
297 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_record),
298 (*priv->cpp->accountInfo)->callModel->isRecording(callToRender));
299 }
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400300}
301
302static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500303on_togglebutton_chat_toggled(GtkToggleButton* widget, CurrentCallView* view)
304{
305 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
306 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
307
308 if (gtk_toggle_button_get_active(widget)) {
309 gtk_widget_show_all(priv->frame_chat);
310 gtk_widget_grab_focus(priv->frame_chat);
311 } else {
312 gtk_widget_hide(priv->frame_chat);
313 }
314}
315
316static gboolean
317on_timer_fade_timeout(CurrentCallView* view)
318{
319 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), G_SOURCE_REMOVE);
320 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
321 priv->cpp->checkControlsFading();
322 return G_SOURCE_CONTINUE;
323}
324
325static void
326on_size_allocate(CurrentCallView* view)
327{
328 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
329 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
330
331 priv->cpp->insertControls();
332}
333
334static void
335on_button_hangup_clicked(CurrentCallView* view)
336{
337 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
338 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Sébastien Blind460d702018-07-03 10:15:42 -0400339 (*priv->cpp->accountInfo)->callModel->hangUp(priv->cpp->conversation->callId);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500340}
341
342static void
343on_togglebutton_hold_clicked(CurrentCallView* view)
344{
345 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
346 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
347
348 auto callToHold = priv->cpp->conversation->callId;
349 if (!priv->cpp->conversation->confId.empty())
350 callToHold = priv->cpp->conversation->confId;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400351 (*priv->cpp->accountInfo)->callModel->togglePause(callToHold);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500352}
353
354static void
355on_togglebutton_record_clicked(CurrentCallView* view)
356{
357 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
358 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
359
360 auto callToRecord = priv->cpp->conversation->callId;
361 if (!priv->cpp->conversation->confId.empty())
362 callToRecord = priv->cpp->conversation->confId;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400363 (*priv->cpp->accountInfo)->callModel->toggleAudioRecord(callToRecord);
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400364
365 set_record_animation(priv);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500366}
367
368static void
369on_togglebutton_muteaudio_clicked(CurrentCallView* view)
370{
371 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
372 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
373
374 auto callToMute = priv->cpp->conversation->callId;
375 if (!priv->cpp->conversation->confId.empty())
376 callToMute = priv->cpp->conversation->confId;
377 //auto muteAudioBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio);
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400378 (*priv->cpp->accountInfo)->callModel->toggleMedia(callToMute,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500379 lrc::api::NewCallModel::Media::AUDIO);
380
381 auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio);
382 auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio");
383 if (gtk_toggle_button_get_active(togglebutton))
384 image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio");
385 gtk_button_set_image(GTK_BUTTON(togglebutton), image);
386}
387
388static void
389on_togglebutton_mutevideo_clicked(CurrentCallView* view)
390{
391 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
392 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
393
394 auto callToMute = priv->cpp->conversation->callId;
395 if (!priv->cpp->conversation->confId.empty())
396 callToMute = priv->cpp->conversation->confId;
397 //auto muteVideoBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo);
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400398 (*priv->cpp->accountInfo)->callModel->toggleMedia(callToMute,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500399 lrc::api::NewCallModel::Media::VIDEO);
400
401 auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo);
402 auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video");
403 if (gtk_toggle_button_get_active(togglebutton))
404 image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video");
405 gtk_button_set_image(GTK_BUTTON(togglebutton), image);
406}
407
408static gboolean
409on_mouse_moved(CurrentCallView* view)
410{
411 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
412 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
413
414 priv->cpp->time_last_mouse_motion = g_get_monotonic_time();
415
416 // since the mouse moved, make sure the controls are shown
417 if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->cpp->fade_info)) == CLUTTER_TIMELINE_FORWARD) {
418 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->cpp->fade_info), CLUTTER_TIMELINE_BACKWARD);
419 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->cpp->fade_controls), CLUTTER_TIMELINE_BACKWARD);
420 if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->cpp->fade_info))) {
421 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->cpp->fade_info));
422 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->cpp->fade_controls));
423 clutter_timeline_start(CLUTTER_TIMELINE(priv->cpp->fade_info));
424 clutter_timeline_start(CLUTTER_TIMELINE(priv->cpp->fade_controls));
425 }
426 }
427
Hugo Lefeuvre36425312018-07-24 16:46:01 -0400428 return FALSE; // propagate event
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500429}
430
431static void
432on_autoquality_toggled(GtkToggleButton* button, CurrentCallView* view)
433{
434 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
435 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500436
437 gboolean auto_quality_on = gtk_toggle_button_get_active(button);
438
439 auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality));
440 auto plus_button = gtk_scale_button_get_plus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality));
441 auto minus_button = gtk_scale_button_get_minus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality));
442
443 gtk_widget_set_sensitive(GTK_WIDGET(scale), !auto_quality_on);
444 gtk_widget_set_sensitive(plus_button, !auto_quality_on);
445 gtk_widget_set_sensitive(minus_button, !auto_quality_on);
Sébastien Blin3667fa62017-11-23 09:11:53 -0500446
447 double desired_quality = gtk_scale_button_get_value(GTK_SCALE_BUTTON(priv->scalebutton_quality));
448
Sébastien Blinceb98632018-07-23 13:59:18 -0400449 set_call_quality(view, auto_quality_on, desired_quality);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500450}
451
452static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500453on_quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value,
454 CurrentCallView* view)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500455{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500456 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
457 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500458
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400459 /* no need to update quality if auto quality is enabled */
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500460 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality))) return;
461
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400462 /* update only if the scale button is released (reduces the number of updates) */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500463 if (priv->cpp->quality_scale_pressed) return;
Sébastien Blin3667fa62017-11-23 09:11:53 -0500464
Sébastien Blinceb98632018-07-23 13:59:18 -0400465 set_call_quality(view, false, gtk_scale_button_get_value(button));
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500466}
467
468static gboolean
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500469on_quality_button_pressed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event,
470 CurrentCallView* view)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500471{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500472 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
473 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
474
475 priv->cpp->quality_scale_pressed = TRUE;
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500476
477 return GDK_EVENT_PROPAGATE;
478}
479
480static gboolean
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500481on_quality_button_released(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event,
482 CurrentCallView* view)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500483{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500484 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
485 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
486
487 priv->cpp->quality_scale_pressed = FALSE;
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500488
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400489 // make sure the quality gets updated
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500490 on_quality_changed(GTK_SCALE_BUTTON(priv->scalebutton_quality), 0, view);
491
492 return GDK_EVENT_PROPAGATE;
493}
494
495static gboolean
496on_video_widget_focus(GtkWidget* widget, GtkDirectionType direction, CurrentCallView* view)
497{
498 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
499 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
500
501 // if this widget already has focus, we want the focus to move to the next widget, otherwise we
502 // will get stuck in a focus loop on the buttons
503 if (gtk_widget_has_focus(widget))
504 return FALSE;
505
506 // otherwise we want the focus to go to and change between the call control buttons
507 if (gtk_widget_child_focus(GTK_WIDGET(priv->hbox_call_controls), direction)) {
508 // selected a child, make sure call controls are shown
509 on_mouse_moved(view);
510 return TRUE;
511 }
512
Hugo Lefeuvre36425312018-07-24 16:46:01 -0400513 // did not select the next child, propagate the event
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500514 return FALSE;
515}
516
517static gboolean
518on_button_press_in_video_event(GtkWidget* widget, GdkEventButton *event, CurrentCallView* view)
519{
520 g_return_val_if_fail(IS_VIDEO_WIDGET(widget), FALSE);
521 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
522
523 // on double click
524 if (event->type == GDK_2BUTTON_PRESS) {
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500525 g_signal_emit(G_OBJECT(view), current_call_view_signals[VIDEO_DOUBLE_CLICKED], 0);
526 }
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500527
528 return GDK_EVENT_PROPAGATE;
529}
530
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400531static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500532on_toggle_smartinfo(GSimpleAction* action, G_GNUC_UNUSED GVariant* state, GtkWidget* vbox_call_smartInfo)
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400533{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500534 if (g_variant_get_boolean(g_action_get_state(G_ACTION(action)))) {
535 gtk_widget_show(vbox_call_smartInfo);
536 } else {
537 gtk_widget_hide(vbox_call_smartInfo);
538 }
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400539}
540
Sébastien Blin784f2a32018-05-30 17:31:13 -0400541static void
542transfer_to_peer(CurrentCallViewPrivate* priv, const std::string& peerUri)
543{
544 if (peerUri == priv->cpp->conversation->participants.front()) {
545 g_warning("avoid to transfer to the same call, abort.");
546#if GTK_CHECK_VERSION(3,22,0)
547 gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover));
548#else
549 gtk_widget_hide(GTK_WIDGET(priv->siptransfer_popover));
550#endif
551 return;
552 }
553 try {
554 // If a call is already present with a peer, try an attended transfer.
555 auto callInfo = (*priv->cpp->accountInfo)->callModel->getCallFromURI(peerUri, true);
556 (*priv->cpp->accountInfo)->callModel->transferToCall(
557 priv->cpp->conversation->callId, callInfo.id);
558 } catch (std::out_of_range&) {
559 // No current call found with this URI, perform a blind transfer
560 (*priv->cpp->accountInfo)->callModel->transfer(
561 priv->cpp->conversation->callId, peerUri);
562 }
563#if GTK_CHECK_VERSION(3,22,0)
564 gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover));
565#else
566 gtk_widget_hide(GTK_WIDGET(priv->siptransfer_popover));
567#endif
568}
569
570static void
571on_siptransfer_filter_activated(CurrentCallView* self)
572{
573 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
574 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
575
576 transfer_to_peer(priv, gtk_entry_get_text(GTK_ENTRY(priv->siptransfer_filter_entry)));
577}
578
579static GtkLabel*
580get_sip_address_label(GtkListBoxRow* row)
581{
582 auto* row_children = gtk_container_get_children(GTK_CONTAINER(row));
583 auto* box_infos = g_list_first(row_children)->data;
584 auto* children = gtk_container_get_children(GTK_CONTAINER(box_infos));
585 return GTK_LABEL(g_list_last(children)->data);
586}
587
588static void
589transfer_to_conversation(GtkListBox*, GtkListBoxRow* row, CurrentCallView* self)
590{
591 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
592 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
593 auto* sip_address = get_sip_address_label(row);
594 transfer_to_peer(priv, gtk_label_get_text(GTK_LABEL(sip_address)));
595}
596
597static void
598filter_transfer_list(CurrentCallView *self)
599{
600 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
601 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
602
603 std::string currentFilter = gtk_entry_get_text(GTK_ENTRY(priv->siptransfer_filter_entry));
604
605 auto row = 0;
606 while (GtkWidget* children = GTK_WIDGET(gtk_list_box_get_row_at_index(GTK_LIST_BOX(priv->list_conversations), row))) {
607 auto* sip_address = get_sip_address_label(GTK_LIST_BOX_ROW(children));;
608 if (row == 0) {
609 // Update searching item
610 if (currentFilter.empty() || currentFilter == priv->cpp->conversation->participants.front()) {
611 // Hide temporary item if filter is empty or same number
612 gtk_widget_hide(children);
613 } else {
614 // Else, show the temporary item (and select it)
615 gtk_label_set_text(GTK_LABEL(sip_address), currentFilter.c_str());
616 gtk_widget_show_all(children);
617 gtk_list_box_select_row(GTK_LIST_BOX(priv->list_conversations), GTK_LIST_BOX_ROW(children));
618 }
619 } else {
620 // It's a contact
621 std::string item_address = gtk_label_get_text(GTK_LABEL(sip_address));
622
623 if (item_address == priv->cpp->conversation->participants.front())
624 // if item is the current conversation, hide it
625 gtk_widget_hide(children);
626 else if (currentFilter.empty())
627 // filter is empty, show all items
628 gtk_widget_show_all(children);
629 else if (item_address.find(currentFilter) == std::string::npos || item_address == currentFilter)
630 // avoid duplicates and unwanted numbers
631 gtk_widget_hide(children);
632 else
633 // Item is filtered
634 gtk_widget_show_all(children);
635 }
636 ++row;
637 }
638}
639
640static void
641on_button_transfer_clicked(CurrentCallView *self)
642{
643 // Show and init list
644 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
645 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
646 gtk_popover_set_relative_to(GTK_POPOVER(priv->siptransfer_popover), GTK_WIDGET(priv->togglebutton_transfer));
647#if GTK_CHECK_VERSION(3,22,0)
648 gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover));
649#else
650 gtk_widget_show_all(GTK_WIDGET(priv->siptransfer_popover));
651#endif
652 gtk_widget_show_all(priv->siptransfer_popover);
653 filter_transfer_list(self);
654}
655
656static void
657on_siptransfer_text_changed(GtkSearchEntry*, CurrentCallView* self)
658{
659 filter_transfer_list(self);
660}
661
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500662} // namespace gtk_callbacks
663
664CppImpl::CppImpl(CurrentCallView& widget)
665 : self {&widget}
666 , widgets {CURRENT_CALL_VIEW_GET_PRIVATE(&widget)}
667{}
668
669CppImpl::~CppImpl()
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400670{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500671 QObject::disconnect(state_change_connection);
672 QObject::disconnect(local_renderer_connection);
673 QObject::disconnect(remote_renderer_connection);
674 QObject::disconnect(smartinfo_refresh_connection);
675 QObject::disconnect(new_message_connection);
676 g_clear_object(&widgets->settings);
677
678 g_source_remove(timer_fade);
679
680 auto* display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),
681 "display-smartinfo");
682 g_signal_handler_disconnect(display_smartinfo, smartinfo_action);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400683}
684
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500685void
686CppImpl::init()
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400687{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500688 // CSS styles
689 auto provider = gtk_css_provider_new();
690 gtk_css_provider_load_from_data(provider,
Sébastien Blin784f2a32018-05-30 17:31:13 -0400691 ".search-entry-style { border: 0; border-radius: 0; } \
692 .smartinfo-block-style { color: #8ae234; background-color: rgba(1, 1, 1, 0.33); } \
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500693 @keyframes blink { 0% {opacity: 1;} 49% {opacity: 1;} 50% {opacity: 0;} 100% {opacity: 0;} } \
694 .record-button { background: rgba(0, 0, 0, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \
695 .record-button:checked { animation: blink 1s; animation-iteration-count: infinite; } \
696 .call-button { background: rgba(0, 0, 0, 0.35); border-radius: 50%; border: 0; transition: all 0.3s ease; } \
697 .call-button:hover { background: rgba(0, 0, 0, 0.2); } \
698 .call-button:disabled { opacity: 0.2; } \
699 .can-be-disabled:checked { background: rgba(219, 58, 55, 1); } \
700 .hangup-button-style { background: rgba(219, 58, 55, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \
701 .hangup-button-style:hover { background: rgba(219, 39, 25, 1); }",
702 -1, nullptr
703 );
704 gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()),
705 GTK_STYLE_PROVIDER(provider),
706 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
707
708 widgets->video_widget = video_widget_new();
709 gtk_container_add(GTK_CONTAINER(widgets->frame_video), widgets->video_widget);
710 gtk_widget_show_all(widgets->frame_video);
711
712 // add the overlay controls only once the view has been allocated a size to prevent size
713 // allocation warnings in the log
714 insert_controls_id = g_signal_connect(self, "size-allocate", G_CALLBACK(on_size_allocate), nullptr);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400715}
716
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500717void
718CppImpl::setup(WebKitChatContainer* chat_widget,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400719 AccountInfoPointer const & account_info,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500720 lrc::api::conversation::Info* conv_info)
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400721{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500722 widgets->webkit_chat_container = GTK_WIDGET(chat_widget);
723 conversation = conv_info;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400724 accountInfo = &account_info;
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500725 setCallInfo();
Sébastien Blin784f2a32018-05-30 17:31:13 -0400726
727 if ((*accountInfo)->profileInfo.type == lrc::api::profile::Type::RING)
728 gtk_widget_hide(widgets->togglebutton_transfer);
729 else {
730 // Remove previous list
731 while (GtkWidget* children = GTK_WIDGET(gtk_list_box_get_row_at_index(GTK_LIST_BOX(widgets->list_conversations), 10)))
732 gtk_container_remove(GTK_CONTAINER(widgets->list_conversations), children);
733 // Fill with SIP contacts
734 add_transfer_contact(""); // Temporary item
735 for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations(lrc::api::profile::Type::SIP))
736 add_transfer_contact(c.participants.front());
737 gtk_widget_show_all(widgets->list_conversations);
738 gtk_widget_show(widgets->togglebutton_transfer);
739 }
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400740
741 set_record_animation(widgets);
Sébastien Blin784f2a32018-05-30 17:31:13 -0400742}
743
744void
745CppImpl::add_transfer_contact(const std::string& uri)
746{
747 auto* box_item = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
748 auto pixbufmanipulator = Interfaces::PixbufManipulator();
749 auto image_buf = pixbufmanipulator.generateAvatar("", uri.empty() ? uri : "sip" + uri);
750 auto scaled = pixbufmanipulator.scaleAndFrame(image_buf.get(), QSize(48, 48));
751 auto* avatar = gtk_image_new_from_pixbuf(scaled.get());
752 auto* address = gtk_label_new(uri.c_str());
753 gtk_container_add(GTK_CONTAINER(box_item), GTK_WIDGET(avatar));
754 gtk_container_add(GTK_CONTAINER(box_item), GTK_WIDGET(address));
755 gtk_list_box_insert(GTK_LIST_BOX(widgets->list_conversations), GTK_WIDGET(box_item), -1);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400756}
757
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500758void
759CppImpl::setCallInfo()
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400760{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500761 // change some things depending on call state
762 updateState();
763 updateDetails();
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400764
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500765 // NOTE/TODO we need to rewrite the video_widget file to use the new LRC.
766 g_signal_connect(widgets->video_widget, "button-press-event",
767 G_CALLBACK(video_widget_on_button_press_in_screen_event), nullptr);
768
769 // check if we already have a renderer
770 auto callToRender = conversation->callId;
771 if (!conversation->confId.empty())
772 callToRender = conversation->confId;
773 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400774 (*accountInfo)->callModel->getRenderer(callToRender),
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500775 VIDEO_RENDERER_REMOTE);
776
777 // local renderer
778 if (Video::PreviewManager::instance().isPreviewing())
779 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
780 Video::PreviewManager::instance().previewRenderer(),
781 VIDEO_RENDERER_LOCAL);
782
783 // callback for local renderer
784 local_renderer_connection = QObject::connect(
785 &Video::PreviewManager::instance(),
786 &Video::PreviewManager::previewStarted,
787 [this] (Video::Renderer* renderer) {
788 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
789 renderer,
790 VIDEO_RENDERER_LOCAL);
791 }
792 );
793
794 smartinfo_refresh_connection = QObject::connect(
795 &SmartInfoHub::instance(),
796 &SmartInfoHub::changed,
797 [this] { updateSmartInfo(); }
798 );
799
800 remote_renderer_connection = QObject::connect(
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400801 &*(*accountInfo)->callModel,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500802 &lrc::api::NewCallModel::remotePreviewStarted,
803 [this] (const std::string& callId, Video::Renderer* renderer) {
804 if (conversation->callId == callId) {
805 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
806 renderer,
807 VIDEO_RENDERER_REMOTE);
808 }
809 });
810
811 state_change_connection = QObject::connect(
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400812 &*(*accountInfo)->callModel,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500813 &lrc::api::NewCallModel::callStatusChanged,
814 [this] (const std::string& callId) {
815 if (callId == conversation->callId) {
816 updateState();
817 updateNameAndPhoto();
818 }
819 });
820
821 new_message_connection = QObject::connect(
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400822 &*(*accountInfo)->conversationModel,
Nicolas Jager6635b0d2018-01-24 12:25:28 -0500823 &lrc::api::ConversationModel::newInteraction,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500824 [this] (const std::string& uid, uint64_t msgId, lrc::api::interaction::Info msg) {
825 Q_UNUSED(uid)
826 Q_UNUSED(msgId)
827 Q_UNUSED(msg)
828 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_chat), TRUE);
829 });
830
831 // catch double click to make full screen
832 g_signal_connect(widgets->video_widget, "button-press-event",
833 G_CALLBACK(on_button_press_in_video_event), self);
834
835 // handle smartinfo in right click menu
836 auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),
837 "display-smartinfo");
838 smartinfo_action = g_signal_connect(display_smartinfo,
839 "notify::state",
840 G_CALLBACK(on_toggle_smartinfo),
841 widgets->vbox_call_smartInfo);
842
843 // init chat view
844 widgets->chat_view = chat_view_new(WEBKIT_CHAT_CONTAINER(widgets->webkit_chat_container),
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400845 *accountInfo, conversation);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500846 gtk_container_add(GTK_CONTAINER(widgets->frame_chat), widgets->chat_view);
847
848 g_signal_connect_swapped(widgets->chat_view, "new-interactions-displayed",
849 G_CALLBACK(on_new_chat_interactions), self);
850 chat_view_set_header_visible(CHAT_VIEW(widgets->chat_view), FALSE);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400851}
852
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500853void
854CppImpl::insertControls()
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500855{
Stepan Salenikovich88092932017-05-15 18:19:00 -0400856 /* only add the controls once */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500857 g_signal_handler_disconnect(self, insert_controls_id);
858 insert_controls_id = 0;
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500859
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500860 auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(widgets->video_widget));
861 auto actor_info = gtk_clutter_actor_new_with_contents(widgets->hbox_call_info);
862 auto actor_controls = gtk_clutter_actor_new_with_contents(widgets->hbox_call_controls);
863 auto actor_smartInfo = gtk_clutter_actor_new_with_contents(widgets->vbox_call_smartInfo);
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500864
865 clutter_actor_add_child(stage, actor_info);
866 clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL);
867 clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START);
868
869 clutter_actor_add_child(stage, actor_controls);
870 clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER);
871 clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END);
872
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400873 clutter_actor_add_child(stage, actor_smartInfo);
874 clutter_actor_set_x_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_END);
875 clutter_actor_set_y_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_START);
876 ClutterMargin clutter_margin_smartInfo;
877 clutter_margin_smartInfo.top = 50;
878 clutter_margin_smartInfo.right = 10;
philippegorleya7337942017-07-04 15:29:42 -0400879 clutter_margin_smartInfo.left = 10;
880 clutter_margin_smartInfo.bottom = 10;
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400881 clutter_actor_set_margin (actor_smartInfo, &clutter_margin_smartInfo);
882
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500883 /* add fade in and out states to the info and controls */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500884 time_last_mouse_motion = g_get_monotonic_time();
885 fade_info = create_fade_out_transition();
886 fade_controls = create_fade_out_transition();
887 clutter_actor_add_transition(actor_info, "fade_info", fade_info);
888 clutter_actor_add_transition(actor_controls, "fade_controls", fade_controls);
889 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_info), CLUTTER_TIMELINE_BACKWARD);
890 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_controls), CLUTTER_TIMELINE_BACKWARD);
891 clutter_timeline_stop(CLUTTER_TIMELINE(fade_info));
892 clutter_timeline_stop(CLUTTER_TIMELINE(fade_controls));
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500893
894 /* have a timer check every 1 second if the controls should fade out */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500895 timer_fade = g_timeout_add(1000, (GSourceFunc)on_timer_fade_timeout, self);
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500896
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400897 /* connect the controllers (new model) */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500898 g_signal_connect_swapped(widgets->button_hangup, "clicked", G_CALLBACK(on_button_hangup_clicked), self);
Sébastien Blin784f2a32018-05-30 17:31:13 -0400899 g_signal_connect_swapped(widgets->togglebutton_transfer, "clicked", G_CALLBACK(on_button_transfer_clicked), self);
900 g_signal_connect_swapped(widgets->siptransfer_filter_entry, "activate", G_CALLBACK(on_siptransfer_filter_activated), self);
901 g_signal_connect(widgets->siptransfer_filter_entry, "search-changed", G_CALLBACK(on_siptransfer_text_changed), self);
902 g_signal_connect(widgets->list_conversations, "row-activated", G_CALLBACK(transfer_to_conversation), self);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500903 g_signal_connect_swapped(widgets->togglebutton_hold, "clicked", G_CALLBACK(on_togglebutton_hold_clicked), self);
904 g_signal_connect_swapped(widgets->togglebutton_muteaudio, "clicked", G_CALLBACK(on_togglebutton_muteaudio_clicked), self);
905 g_signal_connect_swapped(widgets->togglebutton_record, "clicked", G_CALLBACK(on_togglebutton_record_clicked), self);
906 g_signal_connect_swapped(widgets->togglebutton_mutevideo, "clicked", G_CALLBACK(on_togglebutton_mutevideo_clicked), self);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400907
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500908 /* connect to the mouse motion event to reset the last moved time */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500909 g_signal_connect_swapped(widgets->video_widget, "motion-notify-event", G_CALLBACK(on_mouse_moved), self);
910 g_signal_connect_swapped(widgets->video_widget, "button-press-event", G_CALLBACK(on_mouse_moved), self);
911 g_signal_connect_swapped(widgets->video_widget, "button-release-event", G_CALLBACK(on_mouse_moved), self);
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500912
Stepan Salenikovich5ed1b492015-11-13 14:03:31 -0500913 /* manually handle the focus of the video widget to be able to focus on the call controls */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500914 g_signal_connect(widgets->video_widget, "focus", G_CALLBACK(on_video_widget_focus), self);
Stepan Salenikovich5ed1b492015-11-13 14:03:31 -0500915
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400916
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500917 /* toggle whether or not the chat is displayed */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500918 g_signal_connect(widgets->togglebutton_chat, "toggled", G_CALLBACK(on_togglebutton_chat_toggled), self);
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400919
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500920 /* bind the chat orientation to the gsetting */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500921 widgets->settings = g_settings_new_full(get_ring_schema(), nullptr, nullptr);
922 g_settings_bind_with_mapping(widgets->settings, "chat-pane-horizontal",
923 widgets->paned_call, "orientation",
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500924 G_SETTINGS_BIND_GET,
925 map_boolean_to_orientation,
926 nullptr, nullptr, nullptr);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500927
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500928 g_signal_connect(widgets->scalebutton_quality, "value-changed", G_CALLBACK(on_quality_changed), self);
929
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500930 /* customize the quality button scale */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500931 if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(widgets->scalebutton_quality))) {
932 widgets->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality",
933 "Auto"));
934 gtk_widget_show(widgets->checkbutton_autoquality);
935 gtk_box_pack_start(GTK_BOX(scale_box), widgets->checkbutton_autoquality, FALSE, TRUE, 0);
936 g_signal_connect(widgets->checkbutton_autoquality, "toggled", G_CALLBACK(on_autoquality_toggled), self);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500937 }
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500938 if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(widgets->scalebutton_quality))) {
939 g_signal_connect(scale, "button-press-event", G_CALLBACK(on_quality_button_pressed), self);
940 g_signal_connect(scale, "button-release-event", G_CALLBACK(on_quality_button_released), self);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500941 }
Stepan Salenikovich88092932017-05-15 18:19:00 -0400942
Sébastien Blin78551352018-08-16 13:55:30 -0400943 g_signal_connect(widgets->video_widget, "drag-data-received",
944 G_CALLBACK(video_widget_on_drag_data_received), nullptr);
945
Sébastien Blinceb98632018-07-23 13:59:18 -0400946 auto videoCodecs = (*accountInfo)->codecModel->getVideoCodecs();
947 if (!videoCodecs.empty()) {
948 bool autoQualityEnabled = videoCodecs.front().auto_quality_enabled;
949 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->checkbutton_autoquality),
950 autoQualityEnabled);
951 } else {
952 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->checkbutton_autoquality),
953 false);
954 }
Sébastien Blin3667fa62017-11-23 09:11:53 -0500955
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400956 // Get if the user wants to show the smartInfo box
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500957 auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),
958 "display-smartinfo");
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400959 if (g_variant_get_boolean(g_action_get_state(G_ACTION(display_smartinfo)))) {
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500960 gtk_widget_show(widgets->vbox_call_smartInfo);
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400961 } else {
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500962 gtk_widget_hide(widgets->vbox_call_smartInfo);
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400963 }
Stepan Salenikovich88092932017-05-15 18:19:00 -0400964}
965
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500966void
967CppImpl::updateDetails()
968{
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400969 if (!conversation) {
970 g_warning("Could not update currentcallview details (null conversation)");
971 return;
972 }
973
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500974 auto callRendered = conversation->callId;
975
976 if (!conversation->confId.empty())
977 callRendered = conversation->confId;
978
979 gtk_label_set_text(GTK_LABEL(widgets->label_duration),
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400980 (*accountInfo)->callModel->getFormattedCallDuration(callRendered).c_str());
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500981
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400982 auto call = (*accountInfo)->callModel->getCall(callRendered);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500983 gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_muteaudio),
984 (call.type != lrc::api::call::Type::CONFERENCE));
985 gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_mutevideo),
986 (call.type != lrc::api::call::Type::CONFERENCE));
987}
988
989void
990CppImpl::updateState()
991{
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400992 if (!conversation) {
993 g_warning("Could not update currentcallview state (null conversation)");
994 return;
995 }
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500996
997 auto callId = conversation->callId;
998
999 try {
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001000 auto call = (*accountInfo)->callModel->getCall(callId);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001001
1002 auto pauseBtn = GTK_TOGGLE_BUTTON(widgets->togglebutton_hold);
1003 auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/pause");
1004 if (call.status == lrc::api::call::Status::PAUSED)
1005 image = gtk_image_new_from_resource ("/cx/ring/RingGnome/play");
1006 gtk_button_set_image(GTK_BUTTON(pauseBtn), image);
1007
1008 auto audioButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio);
1009 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio), call.audioMuted);
1010 auto imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio");
1011 if (call.audioMuted)
1012 imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio");
1013 gtk_button_set_image(GTK_BUTTON(audioButton), imageMuteAudio);
1014
1015 auto videoButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo);
1016 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo), call.videoMuted);
1017 auto imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video");
1018 if (call.videoMuted)
1019 imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video");
1020 gtk_button_set_image(GTK_BUTTON(videoButton), imageMuteVideo);
1021
1022 gchar *status = g_strdup_printf("%s", lrc::api::call::to_string(call.status).c_str());
1023 gtk_label_set_text(GTK_LABEL(widgets->label_status), status);
1024 g_free(status);
1025 } catch (std::out_of_range& e) {
1026 g_warning("Can't update state for callId=%s", callId.c_str());
1027 }
1028}
1029
1030void
1031CppImpl::updateNameAndPhoto()
1032{
1033 QVariant var_i = GlobalInstances::pixmapManipulator().conversationPhoto(
1034 *conversation,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001035 **(accountInfo),
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001036 QSize(60, 60),
1037 false
1038 );
1039 std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>();
1040 gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->image_peer), image.get());
1041
1042 try {
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001043 auto contactInfo = (*accountInfo)->contactModel->getContact(conversation->participants.front());
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001044 auto name = contactInfo.profileInfo.alias;
1045 gtk_label_set_text(GTK_LABEL(widgets->label_name), name.c_str());
1046
1047 auto bestId = contactInfo.registeredName;
1048 if (name != bestId) {
1049 gtk_label_set_text(GTK_LABEL(widgets->label_bestId), bestId.c_str());
1050 gtk_widget_show(widgets->label_bestId);
1051 }
1052 } catch (const std::out_of_range&) {
1053 // ContactModel::getContact() exception
1054 }
1055}
1056
1057void
1058CppImpl::updateSmartInfo()
1059{
1060 if (!SmartInfoHub::instance().isConference()) {
1061 gchar* general_information = g_strdup_printf(
1062 "Call ID: %s", SmartInfoHub::instance().callID().toStdString().c_str());
1063 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_general_information), general_information);
1064 g_free(general_information);
1065
1066 gchar* description = g_strdup_printf("You\n"
1067 "Framerate:\n"
1068 "Video codec:\n"
1069 "Audio codec:\n"
1070 "Resolution:\n\n"
1071 "Peer\n"
1072 "Framerate:\n"
1073 "Video codec:\n"
1074 "Audio codec:\n"
1075 "Resolution:");
1076 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_description),description);
1077 g_free(description);
1078
1079 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",
1080 (double)SmartInfoHub::instance().localFps(),
1081 SmartInfoHub::instance().localVideoCodec().toStdString().c_str(),
1082 SmartInfoHub::instance().localAudioCodec().toStdString().c_str(),
1083 SmartInfoHub::instance().localWidth(),
1084 SmartInfoHub::instance().localHeight(),
1085 (double)SmartInfoHub::instance().remoteFps(),
1086 SmartInfoHub::instance().remoteVideoCodec().toStdString().c_str(),
1087 SmartInfoHub::instance().remoteAudioCodec().toStdString().c_str(),
1088 SmartInfoHub::instance().remoteWidth(),
1089 SmartInfoHub::instance().remoteHeight());
1090 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_value),value);
1091 g_free(value);
1092 } else {
1093 gchar* general_information = g_strdup_printf(
1094 "Conference ID: %s", SmartInfoHub::instance().callID().toStdString().c_str());
1095 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_general_information), general_information);
1096 g_free(general_information);
1097
1098 gchar* description = g_strdup_printf("You\n"
1099 "Framerate:\n"
1100 "Video codec:\n"
1101 "Audio codec:\n"
1102 "Resolution:");
1103 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_description),description);
1104 g_free(description);
1105
1106 gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d",
1107 (double)SmartInfoHub::instance().localFps(),
1108 SmartInfoHub::instance().localVideoCodec().toStdString().c_str(),
1109 SmartInfoHub::instance().localAudioCodec().toStdString().c_str(),
1110 SmartInfoHub::instance().localWidth(),
1111 SmartInfoHub::instance().localHeight());
1112 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_value),value);
1113 g_free(value);
1114 }
1115}
1116
1117void
1118CppImpl::checkControlsFading()
1119{
1120 auto current_time = g_get_monotonic_time();
1121 if (current_time - time_last_mouse_motion >= CONTROLS_FADE_TIMEOUT) {
1122 // timeout has passed, hide the controls
1123 if (clutter_timeline_get_direction(CLUTTER_TIMELINE(fade_info)) == CLUTTER_TIMELINE_BACKWARD) {
1124 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_info), CLUTTER_TIMELINE_FORWARD);
1125 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_controls), CLUTTER_TIMELINE_FORWARD);
1126 if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(fade_info))) {
1127 clutter_timeline_rewind(CLUTTER_TIMELINE(fade_info));
1128 clutter_timeline_rewind(CLUTTER_TIMELINE(fade_controls));
1129 clutter_timeline_start(CLUTTER_TIMELINE(fade_info));
1130 clutter_timeline_start(CLUTTER_TIMELINE(fade_controls));
1131 }
1132 }
1133 }
1134
1135 updateDetails();
1136}
1137
1138}} // namespace <anonymous>::details
1139
1140//==============================================================================
1141
1142lrc::api::conversation::Info
1143current_call_view_get_conversation(CurrentCallView *self)
1144{
1145 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), lrc::api::conversation::Info());
1146 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
1147 return *priv->cpp->conversation;
1148}
1149
1150GtkWidget *
1151current_call_view_get_chat_view(CurrentCallView *self)
1152{
1153 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), nullptr);
1154 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
1155 return priv->chat_view;
1156}
1157
1158//==============================================================================
1159
Stepan Salenikovich88092932017-05-15 18:19:00 -04001160static void
1161current_call_view_init(CurrentCallView *view)
1162{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001163 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich88092932017-05-15 18:19:00 -04001164 gtk_widget_init_template(GTK_WIDGET(view));
1165
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001166 // CppImpl ctor
1167 priv->cpp = new details::CppImpl {*view};
1168 priv->cpp->init();
1169}
Stepan Salenikovich88092932017-05-15 18:19:00 -04001170
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001171static void
1172current_call_view_dispose(GObject *object)
1173{
1174 auto* view = CURRENT_CALL_VIEW(object);
1175 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich88092932017-05-15 18:19:00 -04001176
Hugo Lefeuvreedad8832018-05-14 16:36:06 -04001177 // navbar was hidden during setCallInfo, we need to make it visible again before view destruction
1178 auto children = gtk_container_get_children(GTK_CONTAINER(priv->frame_chat));
1179 auto chat_view = children->data;
1180 chat_view_set_header_visible(CHAT_VIEW(chat_view), TRUE);
1181
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001182 delete priv->cpp;
1183 priv->cpp = nullptr;
Stepan Salenikovich88092932017-05-15 18:19:00 -04001184
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001185 G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001186}
1187
1188static void
1189current_call_view_class_init(CurrentCallViewClass *klass)
1190{
1191 G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose;
1192
1193 gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass),
1194 "/cx/ring/RingGnome/currentcallview.ui");
1195
Stepan Salenikoviche178e632015-11-06 13:31:19 -05001196 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_info);
1197 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_controls);
Olivier Gregoire66e4df72016-06-17 18:39:05 -04001198 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, vbox_call_smartInfo);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001199 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, image_peer);
Stepan Salenikovich07107e92016-05-06 10:35:17 -04001200 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_name);
Nicolas Jager2e467c32017-01-18 08:52:23 -05001201 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_bestId);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001202 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status);
1203 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration);
Olivier Gregoire66e4df72016-06-17 18:39:05 -04001204 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_description);
1205 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_value);
1206 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_general_information);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -05001207 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, paned_call);
Stepan Salenikovich36c025c2015-03-03 19:06:44 -05001208 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -05001209 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_chat);
Stepan Salenikovicha448f602015-05-29 13:33:06 -04001210 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat);
Sébastien Blin784f2a32018-05-30 17:31:13 -04001211 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_transfer);
AmarOke7c02972017-07-17 15:21:20 -04001212 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_hold);
1213 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_muteaudio);
Sébastien Blin55bff9d2017-10-03 15:15:23 -04001214 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_record);
AmarOke7c02972017-07-17 15:21:20 -04001215 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_mutevideo);
Stepan Salenikovich77baa522015-07-07 15:29:14 -04001216 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, button_hangup);
Stepan Salenikovich7e283552015-12-21 16:17:52 -05001217 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, scalebutton_quality);
Sébastien Blin784f2a32018-05-30 17:31:13 -04001218 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, siptransfer_popover);
1219 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, siptransfer_filter_entry);
1220 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, list_conversations);
Stepan Salenikoviche1b54892015-12-13 22:18:44 -05001221
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001222 details::current_call_view_signals[VIDEO_DOUBLE_CLICKED] = g_signal_new (
Stepan Salenikoviche1b54892015-12-13 22:18:44 -05001223 "video-double-clicked",
1224 G_TYPE_FROM_CLASS(klass),
1225 (GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION),
1226 0,
1227 nullptr,
1228 nullptr,
1229 g_cclosure_marshal_VOID__VOID,
1230 G_TYPE_NONE, 0);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001231}
1232
Stepan Salenikovich09e0b782016-09-07 16:28:50 -04001233GtkWidget *
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001234current_call_view_new(WebKitChatContainer* chat_widget,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001235 AccountInfoPointer const & accountInfo,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001236 lrc::api::conversation::Info* conversation)
Stepan Salenikovich09e0b782016-09-07 16:28:50 -04001237{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001238 auto* self = g_object_new(CURRENT_CALL_VIEW_TYPE, NULL);
1239 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
1240
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001241 priv->cpp->setup(chat_widget, accountInfo, conversation);
Stepan Salenikovich09e0b782016-09-07 16:28:50 -04001242 return GTK_WIDGET(self);
1243}