blob: e95d9de8dd1642e3d272e3b8538da06a945b7f74 [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
Hugo Lefeuvre55d24732018-09-13 14:20:10 -040045// std
46#include <memory> // for std::shared_ptr
47#include <string>
Sébastien Blin784f2a32018-05-30 17:31:13 -040048
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050049namespace { namespace details
50{
51class CppImpl;
52}}
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -050053
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050054struct _CurrentCallView
55{
56 GtkBox parent;
57};
58
59struct _CurrentCallViewClass
60{
61 GtkBoxClass parent_class;
62};
63
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050064struct CurrentCallViewPrivate
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050065{
Stepan Salenikoviche178e632015-11-06 13:31:19 -050066 GtkWidget *hbox_call_info;
67 GtkWidget *hbox_call_controls;
Olivier Gregoire66e4df72016-06-17 18:39:05 -040068 GtkWidget *vbox_call_smartInfo;
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050069 GtkWidget *image_peer;
Stepan Salenikovich07107e92016-05-06 10:35:17 -040070 GtkWidget *label_name;
Nicolas Jager2e467c32017-01-18 08:52:23 -050071 GtkWidget *label_bestId;
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050072 GtkWidget *label_status;
73 GtkWidget *label_duration;
Olivier Gregoire66e4df72016-06-17 18:39:05 -040074 GtkWidget *label_smartinfo_description;
75 GtkWidget *label_smartinfo_value;
76 GtkWidget *label_smartinfo_general_information;
Stepan Salenikovichd2cad062016-01-08 13:43:49 -050077 GtkWidget *paned_call;
Stepan Salenikovich36c025c2015-03-03 19:06:44 -050078 GtkWidget *frame_video;
79 GtkWidget *video_widget;
Stepan Salenikovichd2cad062016-01-08 13:43:49 -050080 GtkWidget *frame_chat;
Stepan Salenikovicha448f602015-05-29 13:33:06 -040081 GtkWidget *togglebutton_chat;
AmarOke7c02972017-07-17 15:21:20 -040082 GtkWidget *togglebutton_muteaudio;
83 GtkWidget *togglebutton_mutevideo;
Sébastien Blin784f2a32018-05-30 17:31:13 -040084 GtkWidget *togglebutton_transfer;
85 GtkWidget* siptransfer_popover;
86 GtkWidget* siptransfer_filter_entry;
87 GtkWidget* list_conversations;
AmarOke7c02972017-07-17 15:21:20 -040088 GtkWidget *togglebutton_hold;
Sébastien Blin55bff9d2017-10-03 15:15:23 -040089 GtkWidget *togglebutton_record;
Stepan Salenikovich77baa522015-07-07 15:29:14 -040090 GtkWidget *button_hangup;
Stepan Salenikovich7e283552015-12-21 16:17:52 -050091 GtkWidget *scalebutton_quality;
92 GtkWidget *checkbutton_autoquality;
Sébastien Blin366243f2017-11-03 14:14:54 -040093 GtkWidget *chat_view;
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050094 GtkWidget *webkit_chat_container; // The webkit_chat_container is created once, then reused for all chat views
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -050095
96 GSettings *settings;
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -050097
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -050098 details::CppImpl* cpp; ///< Non-UI and C++ only code
Stepan Salenikovichc64523b2015-02-27 16:31:00 -050099};
100
101G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX);
102
103#define CURRENT_CALL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CURRENT_CALL_VIEW_TYPE, CurrentCallViewPrivate))
104
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500105enum {
106 VIDEO_DOUBLE_CLICKED,
107 LAST_SIGNAL
108};
109
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500110//==============================================================================
111
112namespace { namespace details
113{
114
115static constexpr int CONTROLS_FADE_TIMEOUT = 3000000; /* microseconds */
116static constexpr int FADE_DURATION = 500; /* miliseconds */
Stepan Salenikoviche1b54892015-12-13 22:18:44 -0500117static guint current_call_view_signals[LAST_SIGNAL] = { 0 };
118
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500119namespace // Helpers
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500120{
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400121
Stepan Salenikovichdaf3cb32016-10-12 16:39:42 -0400122static gboolean
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500123map_boolean_to_orientation(GValue* value, GVariant* variant, G_GNUC_UNUSED gpointer user_data)
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500124{
125 if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
126 if (g_variant_get_boolean(variant)) {
127 // true, chat should be horizontal (to the right)
128 g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL);
129 } else {
130 // false, chat should be vertical (at the bottom)
131 g_value_set_enum(value, GTK_ORIENTATION_VERTICAL);
132 }
133 return TRUE;
134 }
135 return FALSE;
136}
137
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500138static ClutterTransition*
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500139create_fade_out_transition()
140{
141 auto transition = clutter_property_transition_new("opacity");
142 clutter_transition_set_from(transition, G_TYPE_UINT, 255);
143 clutter_transition_set_to(transition, G_TYPE_UINT, 0);
144 clutter_timeline_set_duration(CLUTTER_TIMELINE(transition), FADE_DURATION);
145 clutter_timeline_set_repeat_count(CLUTTER_TIMELINE(transition), 0);
146 clutter_timeline_set_progress_mode(CLUTTER_TIMELINE(transition), CLUTTER_EASE_IN_OUT_CUBIC);
147 return transition;
148}
149
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500150static GtkBox *
151gtk_scale_button_get_box(GtkScaleButton *button)
152{
153 GtkWidget *box = NULL;
154 if (auto dock = gtk_scale_button_get_popup(button)) {
155 // the dock is a popover which contains the box
156 box = gtk_bin_get_child(GTK_BIN(dock));
157 if (box) {
158 if (GTK_IS_FRAME(box)) {
159 // support older versions of gtk; the box used to be in a frame
160 box = gtk_bin_get_child(GTK_BIN(box));
161 }
162 }
163 }
164
165 return GTK_BOX(box);
166}
167
168/**
169 * This gets the GtkScaleButtonScale widget (which is a GtkScale) from the
170 * given GtkScaleButton in order to be able to modify its properties and connect
171 * to its signals
172 */
173static GtkScale *
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500174gtk_scale_button_get_scale(GtkScaleButton* button)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500175{
176 GtkScale *scale = NULL;
177
178 if (auto box = gtk_scale_button_get_box(button)) {
179 GList *children = gtk_container_get_children(GTK_CONTAINER(box));
180 for (GList *c = children; c && !scale; c = c->next) {
181 if (GTK_IS_SCALE(c->data))
182 scale = GTK_SCALE(c->data);
183 }
184 g_list_free(children);
185 }
186
187 return scale;
188}
189
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500190} // namespace
191
192class CppImpl
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500193{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500194public:
195 explicit CppImpl(CurrentCallView& widget);
196 ~CppImpl();
197
198 void init();
199 void setup(WebKitChatContainer* chat_widget,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400200 AccountInfoPointer const & account_info,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500201 lrc::api::conversation::Info* conversation);
Sébastien Blin784f2a32018-05-30 17:31:13 -0400202 void add_transfer_contact(const std::string& uri);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500203
204 void insertControls();
205 void checkControlsFading();
206
207 CurrentCallView* self = nullptr; // The GTK widget itself
208 CurrentCallViewPrivate* widgets = nullptr;
209
210 lrc::api::conversation::Info* conversation = nullptr;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400211 AccountInfoPointer const *accountInfo = nullptr;
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500212
213 QMetaObject::Connection state_change_connection;
214 QMetaObject::Connection local_renderer_connection;
215 QMetaObject::Connection remote_renderer_connection;
216 QMetaObject::Connection new_message_connection;
217 QMetaObject::Connection smartinfo_refresh_connection;
218
219 // for clutter animations and to know when to fade in/out the overlays
220 ClutterTransition* fade_info = nullptr;
221 ClutterTransition* fade_controls = nullptr;
222 gint64 time_last_mouse_motion = 0;
223 guint timer_fade = 0;
224
225 /* flag used to keep track of the video quality scale pressed state;
226 * we do not want to update the codec bitrate until the user releases the
227 * scale button */
228 gboolean quality_scale_pressed = FALSE;
229 gulong insert_controls_id = 0;
230 guint smartinfo_action = 0;
231
232private:
233 CppImpl() = delete;
234 CppImpl(const CppImpl&) = delete;
235 CppImpl& operator=(const CppImpl&) = delete;
236
237 void setCallInfo();
238 void updateDetails();
239 void updateState();
240 void updateNameAndPhoto();
241 void updateSmartInfo();
242};
243
244inline namespace gtk_callbacks
245{
246
247static void
Sébastien Blinceb98632018-07-23 13:59:18 -0400248set_call_quality(CurrentCallView* view, bool auto_quality_on, double desired_quality)
249{
250 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
251
252 auto videoCodecs = (*priv->cpp->accountInfo)->codecModel->getVideoCodecs();
253 for (const auto& codec : videoCodecs) {
254 if (auto_quality_on) {
255 (*priv->cpp->accountInfo)->codecModel->autoQuality(codec.id, true);
256 } else {
257 (*priv->cpp->accountInfo)->codecModel->autoQuality(codec.id, false);
258 double min_bitrate = 0., max_bitrate = 0., min_quality = 0., max_quality = 0.;
259 try {
260 min_bitrate = std::stoi(codec.min_bitrate);
261 max_bitrate = std::stoi(codec.max_bitrate);
262 min_quality = std::stoi(codec.min_quality);
263 max_quality = std::stoi(codec.max_quality);
264 } catch (...) {
265 g_error("Cannot convert a codec value to an int, abort");
266 break;
267 }
268
269 double bitrate = min_bitrate + (max_bitrate - min_bitrate)*(desired_quality/100.0);
270 if (bitrate < 0) bitrate = 0;
271 (*priv->cpp->accountInfo)->codecModel->bitrate(codec.id, bitrate);
272
273 // note: a lower value means higher quality
274 double quality = min_quality - (min_quality - max_quality)*(desired_quality/100.0);
275 if (quality < 0) quality = 0;
276 (*priv->cpp->accountInfo)->codecModel->quality(codec.id, quality);
277 }
278 }
279}
280
281static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500282on_new_chat_interactions(CurrentCallView* view)
283{
284 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
285 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
286
287 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_chat), TRUE);
288}
289
290static void
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400291set_record_animation(CurrentCallViewPrivate* priv)
292{
293 auto callToRender = priv->cpp->conversation->callId;
294 if (!priv->cpp->conversation->confId.empty())
295 callToRender = priv->cpp->conversation->confId;
Sébastien Blin07f844a2018-07-12 12:07:39 -0400296 bool nextStatus = (*priv->cpp->accountInfo)->callModel->isRecording(callToRender);
297 bool currentStatus = (*priv->cpp->accountInfo)->callModel->isRecording(callToRender);
298 if (nextStatus != currentStatus) {
299 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->togglebutton_record),
300 (*priv->cpp->accountInfo)->callModel->isRecording(callToRender));
301 }
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400302}
303
304static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500305on_togglebutton_chat_toggled(GtkToggleButton* widget, CurrentCallView* view)
306{
307 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
308 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
309
310 if (gtk_toggle_button_get_active(widget)) {
311 gtk_widget_show_all(priv->frame_chat);
312 gtk_widget_grab_focus(priv->frame_chat);
313 } else {
314 gtk_widget_hide(priv->frame_chat);
315 }
316}
317
318static gboolean
319on_timer_fade_timeout(CurrentCallView* view)
320{
321 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), G_SOURCE_REMOVE);
322 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
323 priv->cpp->checkControlsFading();
324 return G_SOURCE_CONTINUE;
325}
326
327static void
328on_size_allocate(CurrentCallView* view)
329{
330 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
331 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
332
333 priv->cpp->insertControls();
334}
335
336static void
337on_button_hangup_clicked(CurrentCallView* view)
338{
339 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
340 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Sébastien Blind460d702018-07-03 10:15:42 -0400341 (*priv->cpp->accountInfo)->callModel->hangUp(priv->cpp->conversation->callId);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500342}
343
344static void
345on_togglebutton_hold_clicked(CurrentCallView* view)
346{
347 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
348 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
349
350 auto callToHold = priv->cpp->conversation->callId;
351 if (!priv->cpp->conversation->confId.empty())
352 callToHold = priv->cpp->conversation->confId;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400353 (*priv->cpp->accountInfo)->callModel->togglePause(callToHold);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500354}
355
356static void
357on_togglebutton_record_clicked(CurrentCallView* view)
358{
359 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
360 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
361
362 auto callToRecord = priv->cpp->conversation->callId;
363 if (!priv->cpp->conversation->confId.empty())
364 callToRecord = priv->cpp->conversation->confId;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400365 (*priv->cpp->accountInfo)->callModel->toggleAudioRecord(callToRecord);
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400366
367 set_record_animation(priv);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500368}
369
370static void
371on_togglebutton_muteaudio_clicked(CurrentCallView* view)
372{
373 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
374 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
375
376 auto callToMute = priv->cpp->conversation->callId;
377 if (!priv->cpp->conversation->confId.empty())
378 callToMute = priv->cpp->conversation->confId;
379 //auto muteAudioBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio);
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400380 (*priv->cpp->accountInfo)->callModel->toggleMedia(callToMute,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500381 lrc::api::NewCallModel::Media::AUDIO);
382
383 auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_muteaudio);
384 auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio");
385 if (gtk_toggle_button_get_active(togglebutton))
386 image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio");
387 gtk_button_set_image(GTK_BUTTON(togglebutton), image);
388}
389
390static void
391on_togglebutton_mutevideo_clicked(CurrentCallView* view)
392{
393 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
394 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
395
396 auto callToMute = priv->cpp->conversation->callId;
397 if (!priv->cpp->conversation->confId.empty())
398 callToMute = priv->cpp->conversation->confId;
399 //auto muteVideoBtn = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo);
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400400 (*priv->cpp->accountInfo)->callModel->toggleMedia(callToMute,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500401 lrc::api::NewCallModel::Media::VIDEO);
402
403 auto togglebutton = GTK_TOGGLE_BUTTON(priv->togglebutton_mutevideo);
404 auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video");
405 if (gtk_toggle_button_get_active(togglebutton))
406 image = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video");
407 gtk_button_set_image(GTK_BUTTON(togglebutton), image);
408}
409
410static gboolean
411on_mouse_moved(CurrentCallView* view)
412{
413 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
414 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
415
416 priv->cpp->time_last_mouse_motion = g_get_monotonic_time();
417
418 // since the mouse moved, make sure the controls are shown
419 if (clutter_timeline_get_direction(CLUTTER_TIMELINE(priv->cpp->fade_info)) == CLUTTER_TIMELINE_FORWARD) {
420 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->cpp->fade_info), CLUTTER_TIMELINE_BACKWARD);
421 clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->cpp->fade_controls), CLUTTER_TIMELINE_BACKWARD);
422 if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(priv->cpp->fade_info))) {
423 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->cpp->fade_info));
424 clutter_timeline_rewind(CLUTTER_TIMELINE(priv->cpp->fade_controls));
425 clutter_timeline_start(CLUTTER_TIMELINE(priv->cpp->fade_info));
426 clutter_timeline_start(CLUTTER_TIMELINE(priv->cpp->fade_controls));
427 }
428 }
429
Hugo Lefeuvre36425312018-07-24 16:46:01 -0400430 return FALSE; // propagate event
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500431}
432
433static void
434on_autoquality_toggled(GtkToggleButton* button, CurrentCallView* view)
435{
436 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
437 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500438
439 gboolean auto_quality_on = gtk_toggle_button_get_active(button);
440
441 auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality));
442 auto plus_button = gtk_scale_button_get_plus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality));
443 auto minus_button = gtk_scale_button_get_minus_button(GTK_SCALE_BUTTON(priv->scalebutton_quality));
444
445 gtk_widget_set_sensitive(GTK_WIDGET(scale), !auto_quality_on);
446 gtk_widget_set_sensitive(plus_button, !auto_quality_on);
447 gtk_widget_set_sensitive(minus_button, !auto_quality_on);
Sébastien Blin3667fa62017-11-23 09:11:53 -0500448
449 double desired_quality = gtk_scale_button_get_value(GTK_SCALE_BUTTON(priv->scalebutton_quality));
450
Sébastien Blinceb98632018-07-23 13:59:18 -0400451 set_call_quality(view, auto_quality_on, desired_quality);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500452}
453
454static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500455on_quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value,
456 CurrentCallView* view)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500457{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500458 g_return_if_fail(IS_CURRENT_CALL_VIEW(view));
459 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500460
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400461 /* no need to update quality if auto quality is enabled */
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500462 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality))) return;
463
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400464 /* update only if the scale button is released (reduces the number of updates) */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500465 if (priv->cpp->quality_scale_pressed) return;
Sébastien Blin3667fa62017-11-23 09:11:53 -0500466
Sébastien Blinceb98632018-07-23 13:59:18 -0400467 set_call_quality(view, false, gtk_scale_button_get_value(button));
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500468}
469
470static gboolean
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500471on_quality_button_pressed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event,
472 CurrentCallView* view)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500473{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500474 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
475 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
476
477 priv->cpp->quality_scale_pressed = TRUE;
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500478
479 return GDK_EVENT_PROPAGATE;
480}
481
482static gboolean
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500483on_quality_button_released(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event,
484 CurrentCallView* view)
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500485{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500486 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
487 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
488
489 priv->cpp->quality_scale_pressed = FALSE;
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500490
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400491 // make sure the quality gets updated
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500492 on_quality_changed(GTK_SCALE_BUTTON(priv->scalebutton_quality), 0, view);
493
494 return GDK_EVENT_PROPAGATE;
495}
496
497static gboolean
498on_video_widget_focus(GtkWidget* widget, GtkDirectionType direction, CurrentCallView* view)
499{
500 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
501 auto priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
502
503 // if this widget already has focus, we want the focus to move to the next widget, otherwise we
504 // will get stuck in a focus loop on the buttons
505 if (gtk_widget_has_focus(widget))
506 return FALSE;
507
508 // otherwise we want the focus to go to and change between the call control buttons
509 if (gtk_widget_child_focus(GTK_WIDGET(priv->hbox_call_controls), direction)) {
510 // selected a child, make sure call controls are shown
511 on_mouse_moved(view);
512 return TRUE;
513 }
514
Hugo Lefeuvre36425312018-07-24 16:46:01 -0400515 // did not select the next child, propagate the event
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500516 return FALSE;
517}
518
519static gboolean
520on_button_press_in_video_event(GtkWidget* widget, GdkEventButton *event, CurrentCallView* view)
521{
522 g_return_val_if_fail(IS_VIDEO_WIDGET(widget), FALSE);
523 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE);
524
525 // on double click
526 if (event->type == GDK_2BUTTON_PRESS) {
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500527 g_signal_emit(G_OBJECT(view), current_call_view_signals[VIDEO_DOUBLE_CLICKED], 0);
528 }
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500529
530 return GDK_EVENT_PROPAGATE;
531}
532
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400533static void
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500534on_toggle_smartinfo(GSimpleAction* action, G_GNUC_UNUSED GVariant* state, GtkWidget* vbox_call_smartInfo)
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400535{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500536 if (g_variant_get_boolean(g_action_get_state(G_ACTION(action)))) {
537 gtk_widget_show(vbox_call_smartInfo);
538 } else {
539 gtk_widget_hide(vbox_call_smartInfo);
540 }
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400541}
542
Sébastien Blin784f2a32018-05-30 17:31:13 -0400543static void
544transfer_to_peer(CurrentCallViewPrivate* priv, const std::string& peerUri)
545{
546 if (peerUri == priv->cpp->conversation->participants.front()) {
547 g_warning("avoid to transfer to the same call, abort.");
548#if GTK_CHECK_VERSION(3,22,0)
549 gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover));
550#else
551 gtk_widget_hide(GTK_WIDGET(priv->siptransfer_popover));
552#endif
553 return;
554 }
555 try {
556 // If a call is already present with a peer, try an attended transfer.
557 auto callInfo = (*priv->cpp->accountInfo)->callModel->getCallFromURI(peerUri, true);
558 (*priv->cpp->accountInfo)->callModel->transferToCall(
559 priv->cpp->conversation->callId, callInfo.id);
560 } catch (std::out_of_range&) {
561 // No current call found with this URI, perform a blind transfer
562 (*priv->cpp->accountInfo)->callModel->transfer(
563 priv->cpp->conversation->callId, peerUri);
564 }
565#if GTK_CHECK_VERSION(3,22,0)
566 gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover));
567#else
568 gtk_widget_hide(GTK_WIDGET(priv->siptransfer_popover));
569#endif
570}
571
572static void
573on_siptransfer_filter_activated(CurrentCallView* self)
574{
575 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
576 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
577
578 transfer_to_peer(priv, gtk_entry_get_text(GTK_ENTRY(priv->siptransfer_filter_entry)));
579}
580
581static GtkLabel*
582get_sip_address_label(GtkListBoxRow* row)
583{
584 auto* row_children = gtk_container_get_children(GTK_CONTAINER(row));
585 auto* box_infos = g_list_first(row_children)->data;
586 auto* children = gtk_container_get_children(GTK_CONTAINER(box_infos));
587 return GTK_LABEL(g_list_last(children)->data);
588}
589
590static void
591transfer_to_conversation(GtkListBox*, GtkListBoxRow* row, CurrentCallView* self)
592{
593 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
594 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
595 auto* sip_address = get_sip_address_label(row);
596 transfer_to_peer(priv, gtk_label_get_text(GTK_LABEL(sip_address)));
597}
598
599static void
600filter_transfer_list(CurrentCallView *self)
601{
602 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
603 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
604
605 std::string currentFilter = gtk_entry_get_text(GTK_ENTRY(priv->siptransfer_filter_entry));
606
607 auto row = 0;
608 while (GtkWidget* children = GTK_WIDGET(gtk_list_box_get_row_at_index(GTK_LIST_BOX(priv->list_conversations), row))) {
609 auto* sip_address = get_sip_address_label(GTK_LIST_BOX_ROW(children));;
610 if (row == 0) {
611 // Update searching item
612 if (currentFilter.empty() || currentFilter == priv->cpp->conversation->participants.front()) {
613 // Hide temporary item if filter is empty or same number
614 gtk_widget_hide(children);
615 } else {
616 // Else, show the temporary item (and select it)
617 gtk_label_set_text(GTK_LABEL(sip_address), currentFilter.c_str());
618 gtk_widget_show_all(children);
619 gtk_list_box_select_row(GTK_LIST_BOX(priv->list_conversations), GTK_LIST_BOX_ROW(children));
620 }
621 } else {
622 // It's a contact
623 std::string item_address = gtk_label_get_text(GTK_LABEL(sip_address));
624
625 if (item_address == priv->cpp->conversation->participants.front())
626 // if item is the current conversation, hide it
627 gtk_widget_hide(children);
628 else if (currentFilter.empty())
629 // filter is empty, show all items
630 gtk_widget_show_all(children);
631 else if (item_address.find(currentFilter) == std::string::npos || item_address == currentFilter)
632 // avoid duplicates and unwanted numbers
633 gtk_widget_hide(children);
634 else
635 // Item is filtered
636 gtk_widget_show_all(children);
637 }
638 ++row;
639 }
640}
641
642static void
643on_button_transfer_clicked(CurrentCallView *self)
644{
645 // Show and init list
646 g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
647 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
648 gtk_popover_set_relative_to(GTK_POPOVER(priv->siptransfer_popover), GTK_WIDGET(priv->togglebutton_transfer));
649#if GTK_CHECK_VERSION(3,22,0)
650 gtk_popover_popdown(GTK_POPOVER(priv->siptransfer_popover));
651#else
652 gtk_widget_show_all(GTK_WIDGET(priv->siptransfer_popover));
653#endif
654 gtk_widget_show_all(priv->siptransfer_popover);
655 filter_transfer_list(self);
656}
657
658static void
659on_siptransfer_text_changed(GtkSearchEntry*, CurrentCallView* self)
660{
661 filter_transfer_list(self);
662}
663
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500664} // namespace gtk_callbacks
665
666CppImpl::CppImpl(CurrentCallView& widget)
667 : self {&widget}
668 , widgets {CURRENT_CALL_VIEW_GET_PRIVATE(&widget)}
669{}
670
671CppImpl::~CppImpl()
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400672{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500673 QObject::disconnect(state_change_connection);
674 QObject::disconnect(local_renderer_connection);
675 QObject::disconnect(remote_renderer_connection);
676 QObject::disconnect(smartinfo_refresh_connection);
677 QObject::disconnect(new_message_connection);
678 g_clear_object(&widgets->settings);
679
680 g_source_remove(timer_fade);
681
682 auto* display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),
683 "display-smartinfo");
684 g_signal_handler_disconnect(display_smartinfo, smartinfo_action);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400685}
686
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500687void
688CppImpl::init()
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400689{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500690 // CSS styles
691 auto provider = gtk_css_provider_new();
692 gtk_css_provider_load_from_data(provider,
Sébastien Blin784f2a32018-05-30 17:31:13 -0400693 ".search-entry-style { border: 0; border-radius: 0; } \
694 .smartinfo-block-style { color: #8ae234; background-color: rgba(1, 1, 1, 0.33); } \
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500695 @keyframes blink { 0% {opacity: 1;} 49% {opacity: 1;} 50% {opacity: 0;} 100% {opacity: 0;} } \
696 .record-button { background: rgba(0, 0, 0, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \
697 .record-button:checked { animation: blink 1s; animation-iteration-count: infinite; } \
698 .call-button { background: rgba(0, 0, 0, 0.35); border-radius: 50%; border: 0; transition: all 0.3s ease; } \
699 .call-button:hover { background: rgba(0, 0, 0, 0.2); } \
700 .call-button:disabled { opacity: 0.2; } \
701 .can-be-disabled:checked { background: rgba(219, 58, 55, 1); } \
702 .hangup-button-style { background: rgba(219, 58, 55, 1); border-radius: 50%; border: 0; transition: all 0.3s ease; } \
703 .hangup-button-style:hover { background: rgba(219, 39, 25, 1); }",
704 -1, nullptr
705 );
706 gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()),
707 GTK_STYLE_PROVIDER(provider),
708 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
709
710 widgets->video_widget = video_widget_new();
711 gtk_container_add(GTK_CONTAINER(widgets->frame_video), widgets->video_widget);
712 gtk_widget_show_all(widgets->frame_video);
713
714 // add the overlay controls only once the view has been allocated a size to prevent size
715 // allocation warnings in the log
716 insert_controls_id = g_signal_connect(self, "size-allocate", G_CALLBACK(on_size_allocate), nullptr);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400717}
718
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500719void
720CppImpl::setup(WebKitChatContainer* chat_widget,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400721 AccountInfoPointer const & account_info,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500722 lrc::api::conversation::Info* conv_info)
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400723{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500724 widgets->webkit_chat_container = GTK_WIDGET(chat_widget);
725 conversation = conv_info;
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400726 accountInfo = &account_info;
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500727 setCallInfo();
Sébastien Blin784f2a32018-05-30 17:31:13 -0400728
729 if ((*accountInfo)->profileInfo.type == lrc::api::profile::Type::RING)
730 gtk_widget_hide(widgets->togglebutton_transfer);
731 else {
732 // Remove previous list
733 while (GtkWidget* children = GTK_WIDGET(gtk_list_box_get_row_at_index(GTK_LIST_BOX(widgets->list_conversations), 10)))
734 gtk_container_remove(GTK_CONTAINER(widgets->list_conversations), children);
735 // Fill with SIP contacts
736 add_transfer_contact(""); // Temporary item
737 for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations(lrc::api::profile::Type::SIP))
738 add_transfer_contact(c.participants.front());
739 gtk_widget_show_all(widgets->list_conversations);
740 gtk_widget_show(widgets->togglebutton_transfer);
741 }
Sébastien Blin31cc01e2018-06-08 10:51:03 -0400742
743 set_record_animation(widgets);
Sébastien Blin784f2a32018-05-30 17:31:13 -0400744}
745
746void
747CppImpl::add_transfer_contact(const std::string& uri)
748{
749 auto* box_item = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
750 auto pixbufmanipulator = Interfaces::PixbufManipulator();
751 auto image_buf = pixbufmanipulator.generateAvatar("", uri.empty() ? uri : "sip" + uri);
752 auto scaled = pixbufmanipulator.scaleAndFrame(image_buf.get(), QSize(48, 48));
753 auto* avatar = gtk_image_new_from_pixbuf(scaled.get());
754 auto* address = gtk_label_new(uri.c_str());
755 gtk_container_add(GTK_CONTAINER(box_item), GTK_WIDGET(avatar));
756 gtk_container_add(GTK_CONTAINER(box_item), GTK_WIDGET(address));
757 gtk_list_box_insert(GTK_LIST_BOX(widgets->list_conversations), GTK_WIDGET(box_item), -1);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400758}
759
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500760void
761CppImpl::setCallInfo()
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400762{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500763 // change some things depending on call state
764 updateState();
765 updateDetails();
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400766
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500767 // NOTE/TODO we need to rewrite the video_widget file to use the new LRC.
768 g_signal_connect(widgets->video_widget, "button-press-event",
769 G_CALLBACK(video_widget_on_button_press_in_screen_event), nullptr);
770
771 // check if we already have a renderer
772 auto callToRender = conversation->callId;
773 if (!conversation->confId.empty())
774 callToRender = conversation->confId;
775 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400776 (*accountInfo)->callModel->getRenderer(callToRender),
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500777 VIDEO_RENDERER_REMOTE);
778
779 // local renderer
780 if (Video::PreviewManager::instance().isPreviewing())
781 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
782 Video::PreviewManager::instance().previewRenderer(),
783 VIDEO_RENDERER_LOCAL);
784
785 // callback for local renderer
786 local_renderer_connection = QObject::connect(
787 &Video::PreviewManager::instance(),
788 &Video::PreviewManager::previewStarted,
789 [this] (Video::Renderer* renderer) {
790 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
791 renderer,
792 VIDEO_RENDERER_LOCAL);
793 }
794 );
795
796 smartinfo_refresh_connection = QObject::connect(
797 &SmartInfoHub::instance(),
798 &SmartInfoHub::changed,
799 [this] { updateSmartInfo(); }
800 );
801
802 remote_renderer_connection = QObject::connect(
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400803 &*(*accountInfo)->callModel,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500804 &lrc::api::NewCallModel::remotePreviewStarted,
805 [this] (const std::string& callId, Video::Renderer* renderer) {
806 if (conversation->callId == callId) {
807 video_widget_push_new_renderer(VIDEO_WIDGET(widgets->video_widget),
808 renderer,
809 VIDEO_RENDERER_REMOTE);
810 }
811 });
812
813 state_change_connection = QObject::connect(
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400814 &*(*accountInfo)->callModel,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500815 &lrc::api::NewCallModel::callStatusChanged,
816 [this] (const std::string& callId) {
817 if (callId == conversation->callId) {
818 updateState();
819 updateNameAndPhoto();
820 }
821 });
822
823 new_message_connection = QObject::connect(
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400824 &*(*accountInfo)->conversationModel,
Nicolas Jager6635b0d2018-01-24 12:25:28 -0500825 &lrc::api::ConversationModel::newInteraction,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500826 [this] (const std::string& uid, uint64_t msgId, lrc::api::interaction::Info msg) {
827 Q_UNUSED(uid)
828 Q_UNUSED(msgId)
829 Q_UNUSED(msg)
830 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_chat), TRUE);
831 });
832
833 // catch double click to make full screen
834 g_signal_connect(widgets->video_widget, "button-press-event",
835 G_CALLBACK(on_button_press_in_video_event), self);
836
837 // handle smartinfo in right click menu
838 auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),
839 "display-smartinfo");
840 smartinfo_action = g_signal_connect(display_smartinfo,
841 "notify::state",
842 G_CALLBACK(on_toggle_smartinfo),
843 widgets->vbox_call_smartInfo);
844
845 // init chat view
846 widgets->chat_view = chat_view_new(WEBKIT_CHAT_CONTAINER(widgets->webkit_chat_container),
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400847 *accountInfo, conversation);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500848 gtk_container_add(GTK_CONTAINER(widgets->frame_chat), widgets->chat_view);
849
850 g_signal_connect_swapped(widgets->chat_view, "new-interactions-displayed",
851 G_CALLBACK(on_new_chat_interactions), self);
852 chat_view_set_header_visible(CHAT_VIEW(widgets->chat_view), FALSE);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400853}
854
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500855void
856CppImpl::insertControls()
Stepan Salenikovichc64523b2015-02-27 16:31:00 -0500857{
Stepan Salenikovich88092932017-05-15 18:19:00 -0400858 /* only add the controls once */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500859 g_signal_handler_disconnect(self, insert_controls_id);
860 insert_controls_id = 0;
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500861
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500862 auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(widgets->video_widget));
863 auto actor_info = gtk_clutter_actor_new_with_contents(widgets->hbox_call_info);
864 auto actor_controls = gtk_clutter_actor_new_with_contents(widgets->hbox_call_controls);
865 auto actor_smartInfo = gtk_clutter_actor_new_with_contents(widgets->vbox_call_smartInfo);
Stepan Salenikoviche178e632015-11-06 13:31:19 -0500866
867 clutter_actor_add_child(stage, actor_info);
868 clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL);
869 clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START);
870
871 clutter_actor_add_child(stage, actor_controls);
872 clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER);
873 clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END);
874
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400875 clutter_actor_add_child(stage, actor_smartInfo);
876 clutter_actor_set_x_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_END);
877 clutter_actor_set_y_align(actor_smartInfo, CLUTTER_ACTOR_ALIGN_START);
878 ClutterMargin clutter_margin_smartInfo;
879 clutter_margin_smartInfo.top = 50;
880 clutter_margin_smartInfo.right = 10;
philippegorleya7337942017-07-04 15:29:42 -0400881 clutter_margin_smartInfo.left = 10;
882 clutter_margin_smartInfo.bottom = 10;
Olivier Gregoire66e4df72016-06-17 18:39:05 -0400883 clutter_actor_set_margin (actor_smartInfo, &clutter_margin_smartInfo);
884
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500885 /* add fade in and out states to the info and controls */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500886 time_last_mouse_motion = g_get_monotonic_time();
887 fade_info = create_fade_out_transition();
888 fade_controls = create_fade_out_transition();
889 clutter_actor_add_transition(actor_info, "fade_info", fade_info);
890 clutter_actor_add_transition(actor_controls, "fade_controls", fade_controls);
891 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_info), CLUTTER_TIMELINE_BACKWARD);
892 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_controls), CLUTTER_TIMELINE_BACKWARD);
893 clutter_timeline_stop(CLUTTER_TIMELINE(fade_info));
894 clutter_timeline_stop(CLUTTER_TIMELINE(fade_controls));
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500895
896 /* have a timer check every 1 second if the controls should fade out */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500897 timer_fade = g_timeout_add(1000, (GSourceFunc)on_timer_fade_timeout, self);
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500898
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400899 /* connect the controllers (new model) */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500900 g_signal_connect_swapped(widgets->button_hangup, "clicked", G_CALLBACK(on_button_hangup_clicked), self);
Sébastien Blin784f2a32018-05-30 17:31:13 -0400901 g_signal_connect_swapped(widgets->togglebutton_transfer, "clicked", G_CALLBACK(on_button_transfer_clicked), self);
902 g_signal_connect_swapped(widgets->siptransfer_filter_entry, "activate", G_CALLBACK(on_siptransfer_filter_activated), self);
903 g_signal_connect(widgets->siptransfer_filter_entry, "search-changed", G_CALLBACK(on_siptransfer_text_changed), self);
904 g_signal_connect(widgets->list_conversations, "row-activated", G_CALLBACK(transfer_to_conversation), self);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500905 g_signal_connect_swapped(widgets->togglebutton_hold, "clicked", G_CALLBACK(on_togglebutton_hold_clicked), self);
906 g_signal_connect_swapped(widgets->togglebutton_muteaudio, "clicked", G_CALLBACK(on_togglebutton_muteaudio_clicked), self);
907 g_signal_connect_swapped(widgets->togglebutton_record, "clicked", G_CALLBACK(on_togglebutton_record_clicked), self);
908 g_signal_connect_swapped(widgets->togglebutton_mutevideo, "clicked", G_CALLBACK(on_togglebutton_mutevideo_clicked), self);
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400909
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500910 /* connect to the mouse motion event to reset the last moved time */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500911 g_signal_connect_swapped(widgets->video_widget, "motion-notify-event", G_CALLBACK(on_mouse_moved), self);
912 g_signal_connect_swapped(widgets->video_widget, "button-press-event", G_CALLBACK(on_mouse_moved), self);
913 g_signal_connect_swapped(widgets->video_widget, "button-release-event", G_CALLBACK(on_mouse_moved), self);
Stepan Salenikovich0c7aa2a2015-11-06 17:00:08 -0500914
Stepan Salenikovich5ed1b492015-11-13 14:03:31 -0500915 /* manually handle the focus of the video widget to be able to focus on the call controls */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500916 g_signal_connect(widgets->video_widget, "focus", G_CALLBACK(on_video_widget_focus), self);
Stepan Salenikovich5ed1b492015-11-13 14:03:31 -0500917
Sébastien Blin55bff9d2017-10-03 15:15:23 -0400918
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500919 /* toggle whether or not the chat is displayed */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500920 g_signal_connect(widgets->togglebutton_chat, "toggled", G_CALLBACK(on_togglebutton_chat_toggled), self);
Stepan Salenikovicha448f602015-05-29 13:33:06 -0400921
Stepan Salenikovichd2cad062016-01-08 13:43:49 -0500922 /* bind the chat orientation to the gsetting */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500923 widgets->settings = g_settings_new_full(get_ring_schema(), nullptr, nullptr);
924 g_settings_bind_with_mapping(widgets->settings, "chat-pane-horizontal",
925 widgets->paned_call, "orientation",
Stepan Salenikovicha5e8e362015-11-05 16:50:48 -0500926 G_SETTINGS_BIND_GET,
927 map_boolean_to_orientation,
928 nullptr, nullptr, nullptr);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500929
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500930 g_signal_connect(widgets->scalebutton_quality, "value-changed", G_CALLBACK(on_quality_changed), self);
931
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500932 /* customize the quality button scale */
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500933 if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(widgets->scalebutton_quality))) {
934 widgets->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality",
935 "Auto"));
936 gtk_widget_show(widgets->checkbutton_autoquality);
937 gtk_box_pack_start(GTK_BOX(scale_box), widgets->checkbutton_autoquality, FALSE, TRUE, 0);
938 g_signal_connect(widgets->checkbutton_autoquality, "toggled", G_CALLBACK(on_autoquality_toggled), self);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500939 }
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500940 if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(widgets->scalebutton_quality))) {
941 g_signal_connect(scale, "button-press-event", G_CALLBACK(on_quality_button_pressed), self);
942 g_signal_connect(scale, "button-release-event", G_CALLBACK(on_quality_button_released), self);
Stepan Salenikovich7e283552015-12-21 16:17:52 -0500943 }
Stepan Salenikovich88092932017-05-15 18:19:00 -0400944
Sébastien Blin78551352018-08-16 13:55:30 -0400945 g_signal_connect(widgets->video_widget, "drag-data-received",
946 G_CALLBACK(video_widget_on_drag_data_received), nullptr);
947
Sébastien Blinceb98632018-07-23 13:59:18 -0400948 auto videoCodecs = (*accountInfo)->codecModel->getVideoCodecs();
949 if (!videoCodecs.empty()) {
950 bool autoQualityEnabled = videoCodecs.front().auto_quality_enabled;
951 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->checkbutton_autoquality),
952 autoQualityEnabled);
953 } else {
954 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->checkbutton_autoquality),
955 false);
956 }
Sébastien Blin3667fa62017-11-23 09:11:53 -0500957
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400958 // Get if the user wants to show the smartInfo box
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500959 auto display_smartinfo = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),
960 "display-smartinfo");
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400961 if (g_variant_get_boolean(g_action_get_state(G_ACTION(display_smartinfo)))) {
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500962 gtk_widget_show(widgets->vbox_call_smartInfo);
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400963 } else {
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500964 gtk_widget_hide(widgets->vbox_call_smartInfo);
Sébastien Blin4514eeb2017-07-25 14:17:01 -0400965 }
Stepan Salenikovich88092932017-05-15 18:19:00 -0400966}
967
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500968void
969CppImpl::updateDetails()
970{
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400971 if (!conversation) {
972 g_warning("Could not update currentcallview details (null conversation)");
973 return;
974 }
975
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500976 auto callRendered = conversation->callId;
977
978 if (!conversation->confId.empty())
979 callRendered = conversation->confId;
980
981 gtk_label_set_text(GTK_LABEL(widgets->label_duration),
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400982 (*accountInfo)->callModel->getFormattedCallDuration(callRendered).c_str());
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500983
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -0400984 auto call = (*accountInfo)->callModel->getCall(callRendered);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500985 gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_muteaudio),
986 (call.type != lrc::api::call::Type::CONFERENCE));
987 gtk_widget_set_sensitive(GTK_WIDGET(widgets->togglebutton_mutevideo),
988 (call.type != lrc::api::call::Type::CONFERENCE));
989}
990
991void
992CppImpl::updateState()
993{
Hugo Lefeuvre8df7e772018-09-12 15:29:30 -0400994 if (!conversation) {
995 g_warning("Could not update currentcallview state (null conversation)");
996 return;
997 }
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -0500998
999 auto callId = conversation->callId;
1000
1001 try {
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001002 auto call = (*accountInfo)->callModel->getCall(callId);
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001003
1004 auto pauseBtn = GTK_TOGGLE_BUTTON(widgets->togglebutton_hold);
1005 auto image = gtk_image_new_from_resource ("/cx/ring/RingGnome/pause");
1006 if (call.status == lrc::api::call::Status::PAUSED)
1007 image = gtk_image_new_from_resource ("/cx/ring/RingGnome/play");
1008 gtk_button_set_image(GTK_BUTTON(pauseBtn), image);
1009
1010 auto audioButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio);
1011 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_muteaudio), call.audioMuted);
1012 auto imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_audio");
1013 if (call.audioMuted)
1014 imageMuteAudio = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_audio");
1015 gtk_button_set_image(GTK_BUTTON(audioButton), imageMuteAudio);
1016
1017 auto videoButton = GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo);
1018 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->togglebutton_mutevideo), call.videoMuted);
1019 auto imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/mute_video");
1020 if (call.videoMuted)
1021 imageMuteVideo = gtk_image_new_from_resource ("/cx/ring/RingGnome/unmute_video");
1022 gtk_button_set_image(GTK_BUTTON(videoButton), imageMuteVideo);
1023
1024 gchar *status = g_strdup_printf("%s", lrc::api::call::to_string(call.status).c_str());
1025 gtk_label_set_text(GTK_LABEL(widgets->label_status), status);
1026 g_free(status);
1027 } catch (std::out_of_range& e) {
1028 g_warning("Can't update state for callId=%s", callId.c_str());
1029 }
1030}
1031
1032void
1033CppImpl::updateNameAndPhoto()
1034{
1035 QVariant var_i = GlobalInstances::pixmapManipulator().conversationPhoto(
1036 *conversation,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001037 **(accountInfo),
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001038 QSize(60, 60),
1039 false
1040 );
1041 std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>();
1042 gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->image_peer), image.get());
1043
1044 try {
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001045 auto contactInfo = (*accountInfo)->contactModel->getContact(conversation->participants.front());
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001046 auto name = contactInfo.profileInfo.alias;
1047 gtk_label_set_text(GTK_LABEL(widgets->label_name), name.c_str());
1048
1049 auto bestId = contactInfo.registeredName;
1050 if (name != bestId) {
1051 gtk_label_set_text(GTK_LABEL(widgets->label_bestId), bestId.c_str());
1052 gtk_widget_show(widgets->label_bestId);
1053 }
1054 } catch (const std::out_of_range&) {
1055 // ContactModel::getContact() exception
1056 }
1057}
1058
1059void
1060CppImpl::updateSmartInfo()
1061{
1062 if (!SmartInfoHub::instance().isConference()) {
1063 gchar* general_information = g_strdup_printf(
1064 "Call ID: %s", SmartInfoHub::instance().callID().toStdString().c_str());
1065 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_general_information), general_information);
1066 g_free(general_information);
1067
1068 gchar* description = g_strdup_printf("You\n"
1069 "Framerate:\n"
1070 "Video codec:\n"
1071 "Audio codec:\n"
1072 "Resolution:\n\n"
1073 "Peer\n"
1074 "Framerate:\n"
1075 "Video codec:\n"
1076 "Audio codec:\n"
1077 "Resolution:");
1078 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_description),description);
1079 g_free(description);
1080
1081 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",
1082 (double)SmartInfoHub::instance().localFps(),
1083 SmartInfoHub::instance().localVideoCodec().toStdString().c_str(),
1084 SmartInfoHub::instance().localAudioCodec().toStdString().c_str(),
1085 SmartInfoHub::instance().localWidth(),
1086 SmartInfoHub::instance().localHeight(),
1087 (double)SmartInfoHub::instance().remoteFps(),
1088 SmartInfoHub::instance().remoteVideoCodec().toStdString().c_str(),
1089 SmartInfoHub::instance().remoteAudioCodec().toStdString().c_str(),
1090 SmartInfoHub::instance().remoteWidth(),
1091 SmartInfoHub::instance().remoteHeight());
1092 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_value),value);
1093 g_free(value);
1094 } else {
1095 gchar* general_information = g_strdup_printf(
1096 "Conference ID: %s", SmartInfoHub::instance().callID().toStdString().c_str());
1097 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_general_information), general_information);
1098 g_free(general_information);
1099
1100 gchar* description = g_strdup_printf("You\n"
1101 "Framerate:\n"
1102 "Video codec:\n"
1103 "Audio codec:\n"
1104 "Resolution:");
1105 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_description),description);
1106 g_free(description);
1107
1108 gchar* value = g_strdup_printf("\n%f\n%s\n%s\n%dx%d",
1109 (double)SmartInfoHub::instance().localFps(),
1110 SmartInfoHub::instance().localVideoCodec().toStdString().c_str(),
1111 SmartInfoHub::instance().localAudioCodec().toStdString().c_str(),
1112 SmartInfoHub::instance().localWidth(),
1113 SmartInfoHub::instance().localHeight());
1114 gtk_label_set_text(GTK_LABEL(widgets->label_smartinfo_value),value);
1115 g_free(value);
1116 }
1117}
1118
1119void
1120CppImpl::checkControlsFading()
1121{
1122 auto current_time = g_get_monotonic_time();
1123 if (current_time - time_last_mouse_motion >= CONTROLS_FADE_TIMEOUT) {
1124 // timeout has passed, hide the controls
1125 if (clutter_timeline_get_direction(CLUTTER_TIMELINE(fade_info)) == CLUTTER_TIMELINE_BACKWARD) {
1126 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_info), CLUTTER_TIMELINE_FORWARD);
1127 clutter_timeline_set_direction(CLUTTER_TIMELINE(fade_controls), CLUTTER_TIMELINE_FORWARD);
1128 if (!clutter_timeline_is_playing(CLUTTER_TIMELINE(fade_info))) {
1129 clutter_timeline_rewind(CLUTTER_TIMELINE(fade_info));
1130 clutter_timeline_rewind(CLUTTER_TIMELINE(fade_controls));
1131 clutter_timeline_start(CLUTTER_TIMELINE(fade_info));
1132 clutter_timeline_start(CLUTTER_TIMELINE(fade_controls));
1133 }
1134 }
1135 }
1136
1137 updateDetails();
1138}
1139
1140}} // namespace <anonymous>::details
1141
1142//==============================================================================
1143
1144lrc::api::conversation::Info
1145current_call_view_get_conversation(CurrentCallView *self)
1146{
1147 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), lrc::api::conversation::Info());
1148 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
1149 return *priv->cpp->conversation;
1150}
1151
1152GtkWidget *
1153current_call_view_get_chat_view(CurrentCallView *self)
1154{
1155 g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), nullptr);
1156 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
1157 return priv->chat_view;
1158}
1159
1160//==============================================================================
1161
Stepan Salenikovich88092932017-05-15 18:19:00 -04001162static void
1163current_call_view_init(CurrentCallView *view)
1164{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001165 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich88092932017-05-15 18:19:00 -04001166 gtk_widget_init_template(GTK_WIDGET(view));
1167
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001168 // CppImpl ctor
1169 priv->cpp = new details::CppImpl {*view};
1170 priv->cpp->init();
1171}
Stepan Salenikovich88092932017-05-15 18:19:00 -04001172
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001173static void
1174current_call_view_dispose(GObject *object)
1175{
1176 auto* view = CURRENT_CALL_VIEW(object);
1177 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(view);
Stepan Salenikovich88092932017-05-15 18:19:00 -04001178
Hugo Lefeuvreedad8832018-05-14 16:36:06 -04001179 // navbar was hidden during setCallInfo, we need to make it visible again before view destruction
1180 auto children = gtk_container_get_children(GTK_CONTAINER(priv->frame_chat));
1181 auto chat_view = children->data;
1182 chat_view_set_header_visible(CHAT_VIEW(chat_view), TRUE);
1183
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001184 delete priv->cpp;
1185 priv->cpp = nullptr;
Stepan Salenikovich88092932017-05-15 18:19:00 -04001186
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001187 G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001188}
1189
1190static void
1191current_call_view_class_init(CurrentCallViewClass *klass)
1192{
1193 G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose;
1194
1195 gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass),
1196 "/cx/ring/RingGnome/currentcallview.ui");
1197
Stepan Salenikoviche178e632015-11-06 13:31:19 -05001198 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_info);
1199 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, hbox_call_controls);
Olivier Gregoire66e4df72016-06-17 18:39:05 -04001200 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, vbox_call_smartInfo);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001201 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, image_peer);
Stepan Salenikovich07107e92016-05-06 10:35:17 -04001202 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_name);
Nicolas Jager2e467c32017-01-18 08:52:23 -05001203 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_bestId);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001204 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status);
1205 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration);
Olivier Gregoire66e4df72016-06-17 18:39:05 -04001206 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_description);
1207 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_value);
1208 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_smartinfo_general_information);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -05001209 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, paned_call);
Stepan Salenikovich36c025c2015-03-03 19:06:44 -05001210 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video);
Stepan Salenikovichd2cad062016-01-08 13:43:49 -05001211 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_chat);
Stepan Salenikovicha448f602015-05-29 13:33:06 -04001212 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat);
Sébastien Blin784f2a32018-05-30 17:31:13 -04001213 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_transfer);
AmarOke7c02972017-07-17 15:21:20 -04001214 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_hold);
1215 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_muteaudio);
Sébastien Blin55bff9d2017-10-03 15:15:23 -04001216 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_record);
AmarOke7c02972017-07-17 15:21:20 -04001217 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_mutevideo);
Stepan Salenikovich77baa522015-07-07 15:29:14 -04001218 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, button_hangup);
Stepan Salenikovich7e283552015-12-21 16:17:52 -05001219 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, scalebutton_quality);
Sébastien Blin784f2a32018-05-30 17:31:13 -04001220 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, siptransfer_popover);
1221 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, siptransfer_filter_entry);
1222 gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, list_conversations);
Stepan Salenikoviche1b54892015-12-13 22:18:44 -05001223
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001224 details::current_call_view_signals[VIDEO_DOUBLE_CLICKED] = g_signal_new (
Stepan Salenikoviche1b54892015-12-13 22:18:44 -05001225 "video-double-clicked",
1226 G_TYPE_FROM_CLASS(klass),
1227 (GSignalFlags) (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION),
1228 0,
1229 nullptr,
1230 nullptr,
1231 g_cclosure_marshal_VOID__VOID,
1232 G_TYPE_NONE, 0);
Stepan Salenikovichc64523b2015-02-27 16:31:00 -05001233}
1234
Stepan Salenikovich09e0b782016-09-07 16:28:50 -04001235GtkWidget *
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001236current_call_view_new(WebKitChatContainer* chat_widget,
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001237 AccountInfoPointer const & accountInfo,
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001238 lrc::api::conversation::Info* conversation)
Stepan Salenikovich09e0b782016-09-07 16:28:50 -04001239{
Guillaume Roguezaaf8b0f2018-01-24 14:38:43 -05001240 auto* self = g_object_new(CURRENT_CALL_VIEW_TYPE, NULL);
1241 auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
1242
Hugo Lefeuvre6f2ceb12018-04-18 15:08:01 -04001243 priv->cpp->setup(chat_widget, accountInfo, conversation);
Stepan Salenikovich09e0b782016-09-07 16:28:50 -04001244 return GTK_WIDGET(self);
1245}