1 /*
2 linphone, gtk-glade interface.
3 Copyright (C) 2009 Simon MORLAT (simon.morlat@linphone.org)
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (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.
18 */
19 /*
20 * C Implementation: incall_frame
21 *
22 * Description:
23 *
24 *
25 * Author: Simon Morlat <simon.morlat@linphone.org>, (C) 2009
26 *
27 *
28 */
29
30 #include "linphone.h"
31
linphone_gtk_use_in_call_view(void)32 gboolean linphone_gtk_use_in_call_view(void){
33 static int val=-1;
34 if (val==-1) val=linphone_gtk_get_ui_config_int("use_incall_view",1);
35 return val;
36 }
37
linphone_gtk_get_currently_displayed_call(gboolean * is_conf)38 LinphoneCall *linphone_gtk_get_currently_displayed_call(gboolean *is_conf){
39 LinphoneCore *lc=linphone_gtk_get_core();
40 GtkWidget *main_window=linphone_gtk_get_main_window ();
41 GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
42 const bctbx_list_t *calls=linphone_core_get_calls(lc);
43 if (is_conf) *is_conf=FALSE;
44 if (!linphone_gtk_use_in_call_view() || bctbx_list_size(calls)==1){
45 if (calls) return (LinphoneCall*)calls->data;
46 }else{
47 int idx=gtk_notebook_get_current_page (notebook);
48 GtkWidget *page=gtk_notebook_get_nth_page(notebook,idx);
49 if (page!=NULL){
50 LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(page),"call");
51 if (call==NULL){
52 GtkWidget *conf_frame=(GtkWidget *)g_object_get_data(G_OBJECT(main_window),"conf_frame");
53 if (conf_frame==page){
54 if (is_conf)
55 *is_conf=TRUE;
56 return NULL;
57 }
58 }
59 return call;
60 }
61 }
62 return NULL;
63 }
64
make_tab_header(int number)65 static GtkWidget *make_tab_header(int number){
66 gchar text[20];
67 g_snprintf(text, sizeof(text), _("Call #%i"), number);
68 return linphone_gtk_make_tab_header(text, "linphone-start-call", FALSE, NULL, NULL);
69 }
70
linphone_gtk_call_update_tab_header(LinphoneCall * call,gboolean pause)71 void linphone_gtk_call_update_tab_header(LinphoneCall *call,gboolean pause){
72 GtkWidget *w=(GtkWidget*)linphone_call_get_user_pointer(call);
73 GtkWidget *main_window=linphone_gtk_get_main_window();
74 GtkNotebook *notebook=GTK_NOTEBOOK(linphone_gtk_get_widget(main_window,"viewswitch"));
75 gint call_index=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"call_index"));
76 GtkWidget *new_label=gtk_hbox_new (FALSE,0);
77 GtkWidget *i=NULL;
78 GtkWidget *l;
79 gchar *text;
80
81 if(pause){
82 i=gtk_image_new_from_icon_name("linphone-hold-off",GTK_ICON_SIZE_BUTTON);
83 } else {
84 i=gtk_image_new_from_icon_name("linphone-start-call", GTK_ICON_SIZE_BUTTON);
85 }
86
87 text=g_strdup_printf(_("Call #%i"),call_index);
88 l=gtk_label_new (text);
89 gtk_box_pack_start (GTK_BOX(new_label),i,FALSE,FALSE,0);
90 gtk_box_pack_end(GTK_BOX(new_label),l,TRUE,TRUE,0);
91
92 gtk_notebook_set_tab_label(notebook,w,new_label);
93 gtk_widget_show_all(new_label);
94 g_free(text);
95 }
96
linphone_gtk_in_call_set_animation_image(GtkWidget * callview,const char * image_name)97 static void linphone_gtk_in_call_set_animation_image(GtkWidget *callview, const char *image_name){
98 GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation");
99 GList *elem=gtk_container_get_children(GTK_CONTAINER(container));
100 GtkWidget *image;
101
102 if (image_name==NULL){
103 gtk_widget_hide(container);
104 }
105 image=gtk_image_new_from_icon_name(image_name,GTK_ICON_SIZE_DIALOG);
106 if (elem)
107 gtk_widget_destroy((GtkWidget*)elem->data);
108 gtk_widget_show(image);
109 gtk_container_add(GTK_CONTAINER(container),image);
110 gtk_widget_show_all(container);
111 }
112
linphone_gtk_in_call_set_animation_spinner(GtkWidget * callview)113 static void linphone_gtk_in_call_set_animation_spinner(GtkWidget *callview){
114 #if GTK_CHECK_VERSION(2,20,0)
115 GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation");
116 GList *elem=gtk_container_get_children(GTK_CONTAINER(container));
117 GtkWidget *spinner=gtk_spinner_new();
118 if (elem)
119 gtk_widget_destroy((GtkWidget*)elem->data);
120 gtk_widget_show(spinner);
121 gtk_container_add(GTK_CONTAINER(container),spinner);
122 gtk_widget_set_size_request(spinner, 20,20);
123 gtk_spinner_start(GTK_SPINNER(spinner));
124 #endif
125 }
126
linphone_gtk_transfer_call(LinphoneCall * dest_call)127 static void linphone_gtk_transfer_call(LinphoneCall *dest_call){
128 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(NULL);
129 if (call) linphone_call_transfer_to_another(call,dest_call);
130 }
131
transfer_button_clicked(GtkWidget * button,gpointer call_ref)132 void transfer_button_clicked(GtkWidget *button, gpointer call_ref){
133 GtkWidget *menu_item;
134 GtkWidget *menu=gtk_menu_new();
135 LinphoneCall *call=(LinphoneCall*)call_ref;
136 LinphoneCore *lc=linphone_gtk_get_core();
137 const bctbx_list_t *elem=linphone_core_get_calls(lc);
138
139 for(;elem!=NULL;elem=elem->next){
140 LinphoneCall *other_call=(LinphoneCall*)elem->data;
141 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(other_call);
142 if (other_call!=call){
143 int call_index=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(call_view),"call_index"));
144 char *remote_uri=linphone_call_get_remote_address_as_string (other_call);
145 char *text=g_strdup_printf(_("Transfer to call #%i with %s"),call_index,remote_uri);
146 GtkWidget *image = gtk_image_new_from_icon_name("linphone-start-call", GTK_ICON_SIZE_MENU);
147 menu_item=gtk_image_menu_item_new_with_label(text);
148 ms_free(remote_uri);
149 g_free(text);
150 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image);
151 gtk_widget_show(menu_item);
152 gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
153 g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_transfer_call,other_call);
154 }
155 }
156 gtk_menu_popup(GTK_MENU(menu),NULL,NULL,NULL,NULL,0,gtk_get_current_event_time());
157 gtk_widget_show(menu);
158 }
159
linphone_gtk_enable_transfer_button(LinphoneCore * lc,gboolean value)160 void linphone_gtk_enable_transfer_button(LinphoneCore *lc, gboolean value){
161 const bctbx_list_t *elem=linphone_core_get_calls(lc);
162 for(;elem!=NULL;elem=elem->next){
163 LinphoneCall *call=(LinphoneCall*)elem->data;
164 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
165 GtkWidget *button=linphone_gtk_get_widget (call_view,"transfer_button");
166 if(button != NULL){
167 gtk_widget_set_sensitive(button,value);
168 }
169 }
170 }
171
conference_button_clicked(GtkWidget * button,gpointer call_ref)172 static void conference_button_clicked(GtkWidget *button, gpointer call_ref){
173 gtk_widget_set_sensitive(button,FALSE);
174 linphone_core_add_all_to_conference(linphone_gtk_get_core());
175
176 }
177
linphone_gtk_enable_conference_button(LinphoneCore * lc,gboolean value)178 void linphone_gtk_enable_conference_button(LinphoneCore *lc, gboolean value){
179 const bctbx_list_t *elem=linphone_core_get_calls(lc);
180 for(;elem!=NULL;elem=elem->next){
181 LinphoneCall *call=(LinphoneCall*)elem->data;
182 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
183 GtkWidget *button=linphone_gtk_get_widget (call_view,"conference_button");
184 if (button != NULL){
185 gtk_widget_set_sensitive(button,value);
186 }
187 }
188 }
189
show_used_codecs(GtkWidget * callstats,LinphoneCall * call)190 static void show_used_codecs(GtkWidget *callstats, LinphoneCall *call){
191 const LinphoneCallParams *params=linphone_call_get_current_params(call);
192 if (params){
193 const PayloadType *acodec=linphone_call_params_get_used_audio_codec(params);
194 const PayloadType *vcodec=linphone_call_params_get_used_video_codec(params);
195 GtkWidget *acodec_ui=linphone_gtk_get_widget(callstats,"audio_codec");
196 GtkWidget *vcodec_ui=linphone_gtk_get_widget(callstats,"video_codec");
197 if (acodec){
198 char tmp[64]={0};
199 snprintf(tmp,sizeof(tmp)-1,"%s/%i/%i",acodec->mime_type,acodec->clock_rate,acodec->channels);
200 gtk_label_set_label(GTK_LABEL(acodec_ui),tmp);
201 }else gtk_label_set_label(GTK_LABEL(acodec_ui),_("Not used"));
202 if (vcodec){
203 gtk_label_set_label(GTK_LABEL(vcodec_ui),vcodec->mime_type);
204 }else gtk_label_set_label(GTK_LABEL(vcodec_ui),_("Not used"));
205 }
206 }
207
ice_state_to_string(LinphoneIceState ice_state)208 static const char *ice_state_to_string(LinphoneIceState ice_state){
209 switch(ice_state){
210 case LinphoneIceStateNotActivated:
211 return _("ICE not activated");
212 case LinphoneIceStateFailed:
213 return _("ICE failed");
214 case LinphoneIceStateInProgress:
215 return _("ICE in progress");
216 case LinphoneIceStateReflexiveConnection:
217 return _("Going through one or more NATs");
218 case LinphoneIceStateHostConnection:
219 return _("Direct");
220 case LinphoneIceStateRelayConnection:
221 return _("Through a relay server");
222 }
223 return "invalid";
224 }
225
upnp_state_to_string(LinphoneUpnpState ice_state)226 static const char *upnp_state_to_string(LinphoneUpnpState ice_state){
227 switch(ice_state){
228 case LinphoneUpnpStateIdle:
229 return _("uPnP not activated");
230 case LinphoneUpnpStatePending:
231 return _("uPnP in progress");
232 case LinphoneUpnpStateNotAvailable:
233 return _("uPnp not available");
234 case LinphoneUpnpStateOk:
235 return _("uPnP is running");
236 case LinphoneUpnpStateKo:
237 return _("uPnP failed");
238 default:
239 break;
240 }
241 return "invalid";
242 }
243
_refresh_call_stats(GtkWidget * callstats,LinphoneCall * call)244 static void _refresh_call_stats(GtkWidget *callstats, LinphoneCall *call){
245 LinphoneUpnpState upnp_state;
246 LinphoneIceState ice_state;
247 LinphoneCallStats *as=linphone_call_get_audio_stats(call);
248 LinphoneCallStats *vs=linphone_call_get_video_stats(call);
249 const char *audio_media_connectivity = _("Direct or through server");
250 const char *video_media_connectivity = _("Direct or through server");
251 const LinphoneCallParams *curparams=linphone_call_get_current_params(call);
252 gboolean has_video=linphone_call_params_video_enabled(curparams);
253 MSVideoSize size_received = linphone_call_params_get_received_video_size(curparams);
254 MSVideoSize size_sent = linphone_call_params_get_sent_video_size(curparams);
255 const char *rtp_profile = linphone_call_params_get_rtp_profile(curparams);
256 gchar *tmp = g_strdup_printf("%s", rtp_profile);
257 gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"rtp_profile")),tmp);
258 g_free(tmp);
259 tmp=g_strdup_printf(_("download: %f\nupload: %f (kbit/s)"),
260 linphone_call_stats_get_download_bandwidth(as),linphone_call_stats_get_upload_bandwidth(as));
261 gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"audio_bandwidth_usage")),tmp);
262 g_free(tmp);
263 if (has_video){
264 gchar *size_r=g_strdup_printf(_("%ix%i @ %f fps"),size_received.width,size_received.height,
265 linphone_call_params_get_received_framerate(curparams));
266 gchar *size_s=g_strdup_printf(_("%ix%i @ %f fps"),size_sent.width,size_sent.height,
267 linphone_call_params_get_sent_framerate(curparams));
268 gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_size_recv")),size_r);
269 gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_size_sent")),size_s);
270
271 tmp=g_strdup_printf(_("download: %f\nupload: %f (kbit/s)"),linphone_call_stats_get_download_bandwidth(vs),linphone_call_stats_get_upload_bandwidth(vs));
272 g_free(size_r);
273 g_free(size_s);
274 } else {
275 tmp=NULL;
276 }
277 gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_bandwidth_usage")),tmp);
278 if (tmp) g_free(tmp);
279 upnp_state = linphone_call_stats_get_upnp_state(as);
280 ice_state = linphone_call_stats_get_ice_state(as);
281 if(upnp_state != LinphoneUpnpStateNotAvailable && upnp_state != LinphoneUpnpStateIdle) {
282 audio_media_connectivity = upnp_state_to_string(upnp_state);
283 } else if(ice_state != LinphoneIceStateNotActivated) {
284 audio_media_connectivity = ice_state_to_string(ice_state);
285 }
286 gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"audio_media_connectivity")),audio_media_connectivity);
287
288 if (has_video){
289 upnp_state = linphone_call_stats_get_upnp_state(vs);
290 ice_state = linphone_call_stats_get_ice_state(vs);
291 if(upnp_state != LinphoneUpnpStateNotAvailable && upnp_state != LinphoneUpnpStateIdle) {
292 video_media_connectivity = upnp_state_to_string(upnp_state);
293 } else if(ice_state != LinphoneIceStateNotActivated) {
294 video_media_connectivity = ice_state_to_string(ice_state);
295 }
296 }else video_media_connectivity=NULL;
297 gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_media_connectivity")),video_media_connectivity);
298
299 if (linphone_call_stats_get_round_trip_delay(as)>0){
300 tmp=g_strdup_printf(_("%.3f seconds"),linphone_call_stats_get_round_trip_delay(as));
301 gtk_label_set_text(GTK_LABEL(linphone_gtk_get_widget(callstats,"round_trip_time")),tmp);
302 g_free(tmp);
303 }
304 linphone_call_stats_unref(as);
305 linphone_call_stats_unref(vs);
306 }
307
refresh_call_stats(GtkWidget * callstats)308 static gboolean refresh_call_stats(GtkWidget *callstats){
309 LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(callstats),"call");
310 switch (linphone_call_get_state(call)){
311 case LinphoneCallError:
312 case LinphoneCallEnd:
313 case LinphoneCallReleased:
314 gtk_widget_destroy(callstats);
315 return FALSE;
316 break;
317 case LinphoneCallStreamsRunning:
318 _refresh_call_stats(callstats,call);
319 break;
320 default:
321 break;
322 }
323 return TRUE;
324 }
325
on_call_stats_destroyed(GtkWidget * call_view)326 static void on_call_stats_destroyed(GtkWidget *call_view){
327 GtkWidget *call_stats=(GtkWidget*)g_object_get_data(G_OBJECT(call_view),"call_stats");
328 LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(call_stats),"call");
329 g_source_remove(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(call_stats),"tid")));
330 g_object_set_data(G_OBJECT(call_view),"call_stats",NULL);
331 linphone_call_unref(call);
332 }
333
linphone_gtk_show_call_stats(LinphoneCall * call)334 static void linphone_gtk_show_call_stats(LinphoneCall *call){
335 GtkWidget *w=(GtkWidget*)linphone_call_get_user_pointer(call);
336 GtkWidget *call_stats=(GtkWidget*)g_object_get_data(G_OBJECT(w),"call_stats");
337 if (call_stats==NULL){
338 guint tid;
339 call_stats=linphone_gtk_create_window("call_statistics", NULL);
340 g_object_set_data(G_OBJECT(w),"call_stats",call_stats);
341 g_object_set_data(G_OBJECT(call_stats),"call",linphone_call_ref(call));
342 tid=g_timeout_add(1000,(GSourceFunc)refresh_call_stats,call_stats);
343 g_object_set_data(G_OBJECT(call_stats),"tid",GINT_TO_POINTER(tid));
344 g_signal_connect_swapped(G_OBJECT(call_stats),"destroy",(GCallback)on_call_stats_destroyed,(gpointer)w);
345 show_used_codecs(call_stats,call);
346 refresh_call_stats(call_stats);
347 gtk_widget_show(call_stats);
348 }
349
350 }
351
linphone_gtk_enable_video_button(LinphoneCall * call,gboolean sensitive,gboolean holdon)352 void linphone_gtk_enable_video_button(LinphoneCall *call, gboolean sensitive, gboolean holdon){
353 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer (call);
354 GtkWidget *button;
355 g_return_if_fail(callview!=NULL);
356 button=linphone_gtk_get_widget(callview,"video_button");
357 gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
358 gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
359 }
360
361
362 typedef enum { VOLUME_CTRL_PLAYBACK, VOLUME_CTRL_RECORD } VolumeControlType;
363
volume_control_value_changed(GtkScaleButton * button,gdouble value,gpointer user_data)364 static void volume_control_value_changed(GtkScaleButton *button, gdouble value, gpointer user_data) {
365 LinphoneCall *call = (LinphoneCall *)g_object_get_data(G_OBJECT(button), "call");
366 VolumeControlType type = (VolumeControlType)GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "type"));
367
368 if(type == VOLUME_CTRL_PLAYBACK) {
369 linphone_call_set_speaker_volume_gain(call, (float)value);
370 } else if(type == VOLUME_CTRL_RECORD) {
371 linphone_call_set_microphone_volume_gain(call, (float)value);
372 }
373 }
374
volume_control_button_update_value(GtkWidget * widget)375 static gboolean volume_control_button_update_value(GtkWidget *widget) {
376 LinphoneCall *call = (LinphoneCall *)g_object_get_data(G_OBJECT(widget), "call");
377 VolumeControlType type = (VolumeControlType)GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "type"));
378 float gain = -1;
379
380 if(type == VOLUME_CTRL_PLAYBACK) {
381 gain = linphone_call_get_speaker_volume_gain(call);
382 } else if(type == VOLUME_CTRL_RECORD) {
383 gain = linphone_call_get_microphone_volume_gain(call);
384 }
385 if(gain >= 0.0f) {
386 gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), gain);
387 return TRUE;
388 } else {
389 return FALSE;
390 }
391 }
392
volume_control_button_enter_event_handler(GtkWidget * widget)393 static gboolean volume_control_button_enter_event_handler(GtkWidget *widget) {
394 volume_control_button_update_value(widget);
395 return FALSE;
396 }
397
volume_control_init(GtkWidget * vol_ctrl,VolumeControlType type,LinphoneCall * call)398 static void volume_control_init(GtkWidget *vol_ctrl, VolumeControlType type, LinphoneCall *call) {
399 g_object_set_data(G_OBJECT(vol_ctrl), "call", call);
400 g_object_set_data(G_OBJECT(vol_ctrl), "type", GINT_TO_POINTER(type));
401 if(!volume_control_button_update_value(vol_ctrl)) {
402 gtk_widget_set_sensitive(vol_ctrl, FALSE);
403 } else {
404 gtk_widget_set_sensitive(vol_ctrl, TRUE);
405 g_signal_connect(G_OBJECT(vol_ctrl), "enter-notify-event", G_CALLBACK(volume_control_button_enter_event_handler), NULL);
406 g_signal_connect(G_OBJECT(vol_ctrl), "value-changed", G_CALLBACK(volume_control_value_changed), NULL);
407 }
408 }
409
linphone_gtk_create_in_call_view(LinphoneCall * call)410 void linphone_gtk_create_in_call_view(LinphoneCall *call){
411 GtkWidget *call_view=linphone_gtk_create_widget("in_call_frame");
412 GtkWidget *main_window=linphone_gtk_get_main_window ();
413 GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
414 GtkWidget *audio_bar = linphone_gtk_get_widget(call_view, "incall_audioview");
415 static int call_index=1;
416 int idx;
417 GtkWidget *record;
418 GtkWidget *transfer;
419 GtkWidget *conf;
420 GtkWidget *button;
421 GtkWidget *image;
422
423 if (bctbx_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){
424 /*this is the only call at this time */
425 call_index=1;
426 }
427 g_object_set_data(G_OBJECT(call_view),"call",call);
428 g_object_set_data(G_OBJECT(call_view),"call_index",GINT_TO_POINTER(call_index));
429
430 linphone_call_set_user_pointer (call,call_view);
431 linphone_call_ref(call);
432 gtk_notebook_append_page (notebook,call_view,make_tab_header(call_index));
433 gtk_widget_show(call_view);
434 idx = gtk_notebook_page_num(notebook, call_view);
435 gtk_notebook_set_current_page(notebook, idx);
436 call_index++;
437 linphone_gtk_enable_hold_button (call,FALSE,TRUE);
438 linphone_gtk_enable_video_button (call,FALSE,TRUE);
439 linphone_gtk_enable_mute_button(
440 GTK_BUTTON(linphone_gtk_get_widget(call_view,"incall_mute")),FALSE);
441
442 record = linphone_gtk_get_widget(call_view, "record_button");
443 gtk_button_set_image(GTK_BUTTON(record), gtk_image_new_from_icon_name("linphone-record", GTK_ICON_SIZE_BUTTON));
444 gtk_widget_hide(record);
445 transfer = linphone_gtk_get_widget(call_view,"transfer_button");
446 gtk_button_set_image(GTK_BUTTON(transfer),gtk_image_new_from_icon_name("linphone-call-transfer",GTK_ICON_SIZE_BUTTON));
447 g_signal_connect(G_OBJECT(transfer),"clicked",(GCallback)transfer_button_clicked,call);
448 gtk_widget_hide(transfer);
449
450 conf = linphone_gtk_get_widget(call_view,"conference_button");
451 gtk_button_set_image(GTK_BUTTON(conf),gtk_image_new_from_icon_name("linphone-conference-start",GTK_ICON_SIZE_BUTTON));
452 g_signal_connect(G_OBJECT(conf),"clicked",(GCallback)conference_button_clicked,call);
453 gtk_widget_hide(conf);
454
455 button=linphone_gtk_get_widget(call_view,"terminate_call");
456 image=gtk_image_new_from_icon_name(
457 linphone_gtk_get_ui_config("stop_call_icon_name","linphone-stop-call"),
458 GTK_ICON_SIZE_BUTTON
459 );
460 gtk_button_set_label(GTK_BUTTON(button),_("Hang up"));
461 gtk_button_set_image(GTK_BUTTON(button),image);
462 gtk_widget_show(image);
463 g_signal_connect_swapped(G_OBJECT(linphone_gtk_get_widget(call_view,"quality_indicator")),"button-press-event",(GCallback)linphone_gtk_show_call_stats,call);
464
465 gtk_widget_hide(audio_bar);
466 }
467
video_button_clicked(GtkWidget * button,LinphoneCall * call)468 static void video_button_clicked(GtkWidget *button, LinphoneCall *call){
469 gboolean adding=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"adding_video"));
470 LinphoneCore *lc=linphone_call_get_core(call);
471 LinphoneCallParams *params = linphone_core_create_call_params(lc, call);
472 gtk_widget_set_sensitive(button,FALSE);
473 linphone_call_params_enable_video(params, adding);
474 linphone_call_update(call,params);
475 linphone_call_params_unref(params);
476 }
477
linphone_gtk_update_video_button(LinphoneCall * call)478 void linphone_gtk_update_video_button(LinphoneCall *call){
479 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
480 GtkWidget *button;
481 GtkWidget *conf_frame;
482 const LinphoneCallParams *params=linphone_call_get_current_params(call);
483 gboolean has_video=linphone_call_params_video_enabled(params);
484 gboolean button_sensitive=FALSE;
485 if (call_view==NULL) return;
486
487 button=linphone_gtk_get_widget(call_view,"video_button");
488
489 gtk_button_set_image(GTK_BUTTON(button),
490 gtk_image_new_from_icon_name(has_video ? "linphone-camera-disabled" : "linphone-camera-enabled",GTK_ICON_SIZE_BUTTON));
491 g_object_set_data(G_OBJECT(button),"adding_video",GINT_TO_POINTER(!has_video));
492 if (!linphone_core_video_supported(linphone_call_get_core(call))){
493 gtk_widget_set_sensitive(button,FALSE);
494 return;
495 }
496 switch(linphone_call_get_state(call)){
497 case LinphoneCallStreamsRunning:
498 button_sensitive=!linphone_call_media_in_progress(call);
499 break;
500 default:
501 button_sensitive=FALSE;
502 break;
503 }
504 gtk_widget_set_sensitive(button,button_sensitive);
505 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"signal_connected"))==0){
506 g_signal_connect(G_OBJECT(button),"clicked",(GCallback)video_button_clicked,call);
507 g_object_set_data(G_OBJECT(button),"signal_connected",GINT_TO_POINTER(1));
508 }
509 conf_frame=(GtkWidget *)g_object_get_data(G_OBJECT(linphone_gtk_get_main_window()),"conf_frame");
510 if(conf_frame!=NULL){
511 gtk_widget_set_sensitive(button,FALSE);
512 }
513 }
514
linphone_gtk_remove_in_call_view(LinphoneCall * call)515 void linphone_gtk_remove_in_call_view(LinphoneCall *call){
516 GtkWidget *w=(GtkWidget*)linphone_call_get_user_pointer (call);
517 GtkWidget *main_window=linphone_gtk_get_main_window ();
518 GtkWidget *nb=linphone_gtk_get_widget(main_window,"viewswitch");
519 int idx,id_current_page;
520 g_return_if_fail(w!=NULL);
521 idx=gtk_notebook_page_num(GTK_NOTEBOOK(nb),w);
522 if (linphone_gtk_call_is_in_conference_view(call)){
523 linphone_gtk_unset_from_conference(call);
524 }
525 linphone_call_set_user_pointer (call,NULL);
526 linphone_call_unref(call);
527 call=linphone_core_get_current_call(linphone_gtk_get_core());
528 id_current_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(nb));
529 if (id_current_page == idx) {
530 if (call==NULL){
531 if (linphone_core_is_in_conference(linphone_gtk_get_core())){
532 /*show the conference*/
533 gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),
534 g_object_get_data(G_OBJECT(main_window),"conf_frame")));
535 } else {
536 gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),0);
537 }
538 }else{
539 /*show the active call*/
540 gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),
541 linphone_call_get_user_pointer(call)));
542 }
543 }
544 gtk_notebook_remove_page (GTK_NOTEBOOK(nb),idx);
545 gtk_widget_destroy(w);
546 }
547
display_peer_name_in_label(GtkWidget * label,const LinphoneAddress * from)548 static void display_peer_name_in_label(GtkWidget *label, const LinphoneAddress *from){
549 const char *displayname=NULL;
550 char *id;
551 char *uri_label;
552 displayname=linphone_address_get_display_name(from);
553 id=linphone_address_as_string_uri_only(from);
554
555 if (displayname!=NULL){
556 uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>",
557 displayname,id);
558 }else
559 uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
560 gtk_label_set_markup(GTK_LABEL(label),uri_label);
561 g_free(uri_label);
562 ms_free(id);
563 }
564
linphone_gtk_in_call_view_set_calling(LinphoneCall * call)565 void linphone_gtk_in_call_view_set_calling(LinphoneCall *call){
566 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
567 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
568 GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
569 GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
570
571 gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
572 display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
573
574 gtk_label_set_text(GTK_LABEL(duration),_("00:00:00"));
575 linphone_gtk_in_call_set_animation_spinner(callview);
576 }
577
linphone_gtk_in_call_view_set_incoming(LinphoneCall * call)578 void linphone_gtk_in_call_view_set_incoming(LinphoneCall *call){
579 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
580 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
581 GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
582 GtkWidget *answer_button;
583 GtkWidget *image;
584
585 gtk_label_set_markup(GTK_LABEL(status),_("<b>Incoming call</b>"));
586 gtk_widget_show_all(linphone_gtk_get_widget(callview,"answer_decline_panel"));
587 gtk_widget_hide(linphone_gtk_get_widget(callview,"buttons_panel"));
588 display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
589
590 answer_button=linphone_gtk_get_widget(callview,"accept_call");
591 image=gtk_image_new_from_icon_name("linphone-start-call", GTK_ICON_SIZE_BUTTON);
592 gtk_button_set_label(GTK_BUTTON(answer_button),_("Answer"));
593 gtk_button_set_image(GTK_BUTTON(answer_button),image);
594 gtk_widget_show(image);
595
596 image=gtk_image_new_from_icon_name("linphone-stop-call", GTK_ICON_SIZE_BUTTON);
597 gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(callview,"decline_call")),image);
598 gtk_widget_show(image);
599
600 linphone_gtk_in_call_set_animation_image(callview,"linphone-call-status-incoming");
601 }
602
rating_to_color(float rating,GdkColor * color)603 static void rating_to_color(float rating, GdkColor *color){
604 const char *colorname="grey";
605 if (rating>=4.0)
606 colorname="green";
607 else if (rating>=3.0)
608 colorname="white";
609 else if (rating>=2.0)
610 colorname="yellow";
611 else if (rating>=1.0)
612 colorname="orange";
613 else if (rating>=0)
614 colorname="red";
615 if (!gdk_color_parse(colorname,color)){
616 g_warning("Fail to parse color %s",colorname);
617 }
618 }
619
rating_to_text(float rating)620 static const char *rating_to_text(float rating){
621 if (rating>=4.0)
622 return _("good");
623 if (rating>=3.0)
624 return _("average");
625 if (rating>=2.0)
626 return _("poor");
627 if (rating>=1.0)
628 return _("very poor");
629 if (rating>=0)
630 return _("too bad");
631 return _("unavailable");
632 }
633
linphone_gtk_in_call_view_refresh(LinphoneCall * call)634 static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){
635 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
636 GtkWidget *qi=linphone_gtk_get_widget(callview,"quality_indicator");
637 float rating=linphone_call_get_current_quality(call);
638 GdkColor color;
639 gchar tmp[50];
640 linphone_gtk_in_call_view_update_duration(call);
641 if (rating>=0){
642 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(qi),rating/5.0);
643 snprintf(tmp,sizeof(tmp),"%.1f (%s)",rating,rating_to_text(rating));
644 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(qi),tmp);
645 }else{
646 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(qi),0);
647 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(qi),_("unavailable"));
648 }
649 rating_to_color(rating,&color);
650 gtk_widget_modify_bg(qi,GTK_STATE_NORMAL,&color);
651
652 linphone_gtk_update_video_button(call); /*in case of no ice re-invite, video button status shall be checked by polling*/
653 return TRUE;
654 }
655
656 #define UNSIGNIFICANT_VOLUME (-23)
657 #define SMOOTH 0.15f
658
update_audio_meter(volume_ctx_t * ctx)659 static gboolean update_audio_meter(volume_ctx_t *ctx){
660 float volume_db=ctx->get_volume(ctx->data);
661 float frac=(volume_db-UNSIGNIFICANT_VOLUME)/(float)(-UNSIGNIFICANT_VOLUME-3.0);
662 if (frac<0) frac=0;
663 if (frac>1.0) frac=1.0;
664 if (frac<ctx->last_value){
665 frac=(frac*SMOOTH)+(ctx->last_value*(1-SMOOTH));
666 }
667 ctx->last_value=frac;
668 //g_message("volume_db=%f, frac=%f",volume_db,frac);
669 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ctx->widget),frac);
670 return TRUE;
671 }
672
on_audio_meter_destroy(GtkWidget * w,gpointer data)673 static void on_audio_meter_destroy(GtkWidget *w, gpointer data){
674 guint task_id = GPOINTER_TO_INT(data);
675 g_source_remove(task_id);
676 }
677
678
linphone_gtk_init_audio_meter(GtkWidget * w,get_volume_t get_volume,void * data)679 void linphone_gtk_init_audio_meter(GtkWidget *w, get_volume_t get_volume, void *data){
680 guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id"));
681 if (task_id==0){
682 volume_ctx_t *ctx=g_new(volume_ctx_t,1);
683 ctx->widget=w;
684 ctx->get_volume=get_volume;
685 ctx->data=data;
686 ctx->last_value=0;
687 g_object_set_data_full(G_OBJECT(w),"ctx",ctx,g_free);
688 task_id=g_timeout_add(50,(GSourceFunc)update_audio_meter,ctx);
689 g_object_set_data(G_OBJECT(w), "task_id", GINT_TO_POINTER(task_id));
690 g_signal_connect(G_OBJECT(w), "destroy", (GCallback)on_audio_meter_destroy, GINT_TO_POINTER(task_id));
691 }
692 }
693
linphone_gtk_uninit_audio_meter(GtkWidget * w)694 void linphone_gtk_uninit_audio_meter(GtkWidget *w){
695 guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id"));
696 if (task_id!=0){
697 g_object_set_data(G_OBJECT(w),"ctx",NULL);
698 g_object_set_data(G_OBJECT(w),"task_id",NULL);
699 g_source_remove(task_id);
700 }
701 }
702
linphone_gtk_in_call_view_enable_audio_view(LinphoneCall * call,gboolean val)703 void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call, gboolean val){
704 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
705 GtkWidget *audio_view=linphone_gtk_get_widget(callview,"incall_audioview");
706 GtkWidget *mic_level=linphone_gtk_get_widget(callview,"mic_audiolevel");
707 GtkWidget *spk_level=linphone_gtk_get_widget(callview,"spk_audiolevel");
708 GtkWidget *mic_ctrl = linphone_gtk_get_widget(callview, "incall_mic_vol_ctrl_button");
709 GtkWidget *spk_ctrl = linphone_gtk_get_widget(callview, "incall_spk_vol_ctrl_button");
710
711 if (val){
712 linphone_gtk_init_audio_meter(mic_level,(get_volume_t)linphone_call_get_record_volume,call);
713 linphone_gtk_init_audio_meter(spk_level,(get_volume_t)linphone_call_get_play_volume,call);
714 volume_control_init(mic_ctrl, VOLUME_CTRL_RECORD, call);
715 volume_control_init(spk_ctrl, VOLUME_CTRL_PLAYBACK, call);
716 gtk_widget_show_all(audio_view);
717 }else{
718 linphone_gtk_uninit_audio_meter(mic_level);
719 linphone_gtk_uninit_audio_meter(spk_level);
720 gtk_widget_hide(audio_view);
721 }
722 }
723
linphone_gtk_auth_token_verified_clicked(GtkButton * button)724 void linphone_gtk_auth_token_verified_clicked(GtkButton *button){
725 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(NULL);
726 if (call){
727 linphone_call_set_authentication_token_verified(call,!linphone_call_get_authentication_token_verified(call));
728 }
729 }
730
linphone_gtk_in_call_view_show_encryption(LinphoneCall * call)731 void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call){
732 GtkWidget *callview = (GtkWidget*)linphone_call_get_user_pointer(call);
733 GtkWidget *encryption_status_box = linphone_gtk_get_widget(callview, "encryption_status_box");
734 GtkWidget *encryption_status_label = linphone_gtk_get_widget(callview, "encryption_status_label");
735 GtkWidget *encryption_status_icon = linphone_gtk_get_widget(callview, "encryption_status_icon");
736 GtkWidget *zrtp_box = linphone_gtk_get_widget(callview, "zrtp_box");
737 GtkWidget *zrtp_button = linphone_gtk_get_widget(callview, "zrtp_button");
738 GtkWidget *zrtp_status_icon = gtk_button_get_image(GTK_BUTTON(zrtp_button));
739 LinphoneMediaEncryption me = linphone_call_params_get_media_encryption(linphone_call_get_current_params(call));
740
741 switch (me) {
742 case LinphoneMediaEncryptionSRTP:
743 gtk_widget_hide_all(zrtp_box);
744 gtk_widget_show_all(encryption_status_box);
745 gtk_label_set_markup(GTK_LABEL(encryption_status_label), _("Secured by SRTP"));
746 gtk_image_set_from_icon_name(GTK_IMAGE(encryption_status_icon), "linphone-security-ok", GTK_ICON_SIZE_MENU);
747 break;
748 case LinphoneMediaEncryptionDTLS:
749 gtk_widget_hide_all(zrtp_box);
750 gtk_widget_show_all(encryption_status_box);
751 gtk_label_set_markup(GTK_LABEL(encryption_status_label), _("Secured by DTLS"));
752 gtk_image_set_from_icon_name(GTK_IMAGE(encryption_status_icon), "linphone-security-ok", GTK_ICON_SIZE_MENU);
753 break;
754 case LinphoneMediaEncryptionZRTP:
755 {
756 bool_t verified = linphone_call_get_authentication_token_verified(call);
757 gchar *text = g_strdup_printf(_("Secured by ZRTP - [auth token: %s]"), linphone_call_get_authentication_token(call));
758 gtk_button_set_label(GTK_BUTTON(zrtp_button), text);
759 g_free(text);
760 gtk_image_set_from_icon_name(GTK_IMAGE(zrtp_status_icon), verified ? "linphone-security-ok" : "linphone-security-pending", GTK_ICON_SIZE_MENU);
761 gtk_widget_set_tooltip_text(zrtp_button, verified ? _("Set unverified") : _("Set verified"));
762 gtk_widget_hide_all(encryption_status_box);
763 gtk_widget_show_all(zrtp_box);
764 }
765 break;
766 default:
767 gtk_widget_hide_all(encryption_status_box);
768 gtk_widget_hide_all(zrtp_box);
769 break;
770 }
771 }
772
linphone_gtk_in_call_view_hide_encryption(LinphoneCall * call)773 void linphone_gtk_in_call_view_hide_encryption(LinphoneCall *call) {
774 GtkWidget *callview = (GtkWidget*)linphone_call_get_user_pointer(call);
775 GtkWidget *encryption_status_box = linphone_gtk_get_widget(callview, "encryption_status_box");
776 GtkWidget *zrtp_box = linphone_gtk_get_widget(callview, "zrtp_box");
777 gtk_widget_hide_all(encryption_status_box);
778 gtk_widget_hide_all(zrtp_box);
779 }
780
linphone_gtk_address(const LinphoneAddress * addr)781 char *linphone_gtk_address(const LinphoneAddress *addr){
782 const char *displayname=linphone_address_get_display_name(addr);
783 if (!displayname) return linphone_address_as_string_uri_only(addr);
784 return ms_strdup(displayname);
785 }
786
linphone_gtk_in_call_view_set_in_call(LinphoneCall * call)787 void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){
788 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
789 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
790 GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
791 GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
792 guint taskid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(callview),"taskid"));
793 gboolean in_conf=(linphone_call_get_conference(call) != NULL);
794 GtkWidget *call_stats=(GtkWidget*)g_object_get_data(G_OBJECT(callview),"call_stats");
795
796 linphone_gtk_in_call_show_video(call);
797
798 display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
799
800 gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
801 gtk_label_set_markup(GTK_LABEL(status),in_conf ? _("In conference") : _("<b>In call</b>"));
802
803 gtk_widget_set_sensitive(linphone_gtk_get_widget(callview,"conference_button"),!in_conf);
804 gtk_widget_set_sensitive(linphone_gtk_get_widget(callview,"transfer_button"),!in_conf);
805
806 gtk_label_set_text(GTK_LABEL(duration),_("00:00:00"));
807 linphone_gtk_in_call_set_animation_image(callview,"linphone-media-play");
808 linphone_gtk_call_update_tab_header(call,FALSE);
809 linphone_gtk_enable_mute_button(
810 GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),TRUE);
811
812 if (taskid==0){
813 taskid=g_timeout_add(250,(GSourceFunc)linphone_gtk_in_call_view_refresh,call);
814 g_object_set_data(G_OBJECT(callview),"taskid",GINT_TO_POINTER(taskid));
815 }
816 linphone_gtk_in_call_view_enable_audio_view(call, !in_conf);
817 linphone_gtk_in_call_view_show_encryption(call);
818 if (in_conf){
819 linphone_gtk_set_in_conference(call);
820 gtk_widget_set_sensitive(linphone_gtk_get_widget(callview,"incall_mute"),FALSE);
821 gtk_widget_set_sensitive(linphone_gtk_get_widget(callview,"hold_call"),FALSE);
822 }else{
823 linphone_gtk_unset_from_conference(call); /*in case it was previously*/
824 gtk_widget_set_sensitive(linphone_gtk_get_widget(callview,"incall_mute"),TRUE);
825 gtk_widget_set_sensitive(linphone_gtk_get_widget(callview,"hold_call"),TRUE);
826 }
827 gtk_widget_show_all(linphone_gtk_get_widget(callview,"buttons_panel"));
828 if (!in_conf) gtk_widget_show_all(linphone_gtk_get_widget(callview,"record_hbox"));
829 else gtk_widget_hide(linphone_gtk_get_widget(callview,"record_hbox"));
830 if (call_stats) show_used_codecs(call_stats,call);
831 }
832
linphone_gtk_in_call_view_set_paused(LinphoneCall * call)833 void linphone_gtk_in_call_view_set_paused(LinphoneCall *call){
834 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
835 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
836 GtkWidget *record_bar = linphone_gtk_get_widget(callview, "record_hbox");
837 gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
838 gtk_label_set_markup(GTK_LABEL(status),_("<b>Paused call</b>"));
839 linphone_gtk_in_call_show_video(call);
840 linphone_gtk_in_call_set_animation_image(callview,"linphone-media-pause");
841 gtk_widget_show_all(record_bar);
842 }
843
linphone_gtk_in_call_view_update_duration(LinphoneCall * call)844 void linphone_gtk_in_call_view_update_duration(LinphoneCall *call){
845 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
846 GtkWidget *duration_label=linphone_gtk_get_widget(callview,"in_call_duration");
847 int duration=linphone_call_get_duration(call);
848 char tmp[256]={0};
849 int seconds=duration%60;
850 int minutes=(duration/60)%60;
851 int hours=duration/3600;
852 snprintf(tmp,sizeof(tmp)-1,"%02i:%02i:%02i",hours,minutes,seconds);
853 gtk_label_set_text(GTK_LABEL(duration_label),tmp);
854 }
855
in_call_view_terminated(LinphoneCall * call)856 static gboolean in_call_view_terminated(LinphoneCall *call){
857 linphone_gtk_remove_in_call_view(call);
858 return FALSE;
859 }
860
linphone_gtk_in_call_view_terminate(LinphoneCall * call,const char * error_msg)861 void linphone_gtk_in_call_view_terminate(LinphoneCall *call, const char *error_msg){
862 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
863 GtkWidget *status;
864 GtkWidget *video_window;
865 gboolean in_conf;
866 guint taskid;
867 if(callview==NULL) return;
868 video_window=(GtkWidget*)g_object_get_data(G_OBJECT(callview),"video_window");
869 status=linphone_gtk_get_widget(callview,"in_call_status");
870 taskid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(callview),"taskid"));
871 in_conf=(linphone_call_get_conference(call) != NULL);
872 if (video_window) gtk_widget_destroy(video_window);
873 if (status==NULL) return;
874 if (error_msg==NULL)
875 gtk_label_set_markup(GTK_LABEL(status),_("<b>Call ended.</b>"));
876 else{
877 char *msg=g_markup_printf_escaped("<span color=\"red\"><b>%s</b></span>",error_msg);
878 gtk_label_set_markup(GTK_LABEL(status),msg);
879 g_free(msg);
880 }
881
882 linphone_gtk_in_call_set_animation_image(callview, linphone_gtk_get_ui_config("stop_call_icon_name","linphone-stop-call"));
883 linphone_gtk_in_call_view_hide_encryption(call);
884
885 gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
886 gtk_widget_hide(linphone_gtk_get_widget(callview,"record_hbox"));
887 gtk_widget_hide(linphone_gtk_get_widget(callview,"buttons_panel"));
888 gtk_widget_hide(linphone_gtk_get_widget(callview,"incall_audioview"));
889 gtk_widget_hide(linphone_gtk_get_widget(callview,"quality_indicator"));
890 linphone_gtk_enable_mute_button(
891 GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),FALSE);
892 linphone_gtk_enable_hold_button(call,FALSE,TRUE);
893
894 if (taskid!=0) g_source_remove(taskid);
895 g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,call);
896 if (in_conf)
897 linphone_gtk_terminate_conference_participant(call);
898 }
899
linphone_gtk_in_call_view_set_transfer_status(LinphoneCall * call,LinphoneCallState cstate)900 void linphone_gtk_in_call_view_set_transfer_status(LinphoneCall *call,LinphoneCallState cstate){
901 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
902 if (callview){
903 GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
904 const char *transfer_status="unknown";
905 switch(cstate){
906 case LinphoneCallOutgoingProgress:
907 transfer_status=_("Transfer in progress");
908 break;
909 case LinphoneCallConnected:
910 transfer_status=_("Transfer done.");
911 break;
912 case LinphoneCallError:
913 transfer_status=_("Transfer failed.");
914 break;
915 default:
916 break;
917 }
918 gtk_label_set_text(GTK_LABEL(duration),transfer_status);
919 }
920 }
921
linphone_gtk_draw_mute_button(GtkButton * button,gboolean active)922 void linphone_gtk_draw_mute_button(GtkButton *button, gboolean active){
923 const char *icon_name = active ? "linphone-micro-muted" : "linphone-micro-enabled";
924 GtkWidget *image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_BUTTON);
925 gtk_button_set_image(button, image);
926 gtk_widget_show(image);
927 g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
928 }
929
linphone_gtk_mute_clicked(GtkButton * button)930 void linphone_gtk_mute_clicked(GtkButton *button){
931 int active=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"active"));
932 linphone_core_enable_mic(linphone_gtk_get_core(),active);
933 linphone_gtk_draw_mute_button(button,!active);
934 }
935
linphone_gtk_enable_mute_button(GtkButton * button,gboolean sensitive)936 void linphone_gtk_enable_mute_button(GtkButton *button, gboolean sensitive){
937 /*gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);*/
938 gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
939 linphone_gtk_draw_mute_button(button,FALSE);
940 }
941
linphone_gtk_draw_hold_button(GtkButton * button,gboolean active)942 void linphone_gtk_draw_hold_button(GtkButton *button, gboolean active){
943 const gchar *icon_name = active ? "linphone-hold-on" : "linphone-hold-off";
944 const gchar *label = active ? _("Resume") : _("Pause");
945 GtkWidget *image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_BUTTON);
946 g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
947 gtk_button_set_label(GTK_BUTTON(button),label);
948 gtk_button_set_image(GTK_BUTTON(button),image);
949 gtk_widget_show(image);
950 }
951
linphone_gtk_hold_clicked(GtkButton * button)952 void linphone_gtk_hold_clicked(GtkButton *button){
953 int active=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"active"));
954 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(NULL);
955 linphone_gtk_call_update_tab_header(call,active);
956 if (!call) return;
957 if(!active)
958 {
959 linphone_call_pause(call);
960 }
961 else
962 {
963 linphone_call_resume(call);
964 }
965 }
966
linphone_gtk_enable_hold_button(LinphoneCall * call,gboolean sensitive,gboolean holdon)967 void linphone_gtk_enable_hold_button(LinphoneCall *call, gboolean sensitive, gboolean holdon){
968 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer (call);
969 GtkWidget *button;
970 g_return_if_fail(callview!=NULL);
971 linphone_gtk_call_update_tab_header(call,!holdon);
972 button=linphone_gtk_get_widget(callview,"hold_call");
973 gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
974 gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
975 linphone_gtk_draw_hold_button(GTK_BUTTON(button),!holdon);
976 }
977
linphone_gtk_call_statistics_closed(GtkWidget * call_stats)978 void linphone_gtk_call_statistics_closed(GtkWidget *call_stats){
979 gtk_widget_destroy(call_stats);
980 }
981
linphone_gtk_record_call_toggled(GtkWidget * button)982 void linphone_gtk_record_call_toggled(GtkWidget *button){
983 gboolean active=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
984 gboolean is_conf=FALSE;
985 const char *filepath;
986 gchar *message;
987 LinphoneCore *lc=linphone_gtk_get_core();
988 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(&is_conf);
989 GtkWidget *callview;
990 GtkWidget *label;
991 if (call){
992 const LinphoneCallParams *params;
993 callview=(GtkWidget*)linphone_call_get_user_pointer (call);
994 params=linphone_call_get_current_params(call);
995 filepath=linphone_call_params_get_record_file(params);
996 label=linphone_gtk_get_widget(callview,"record_status");
997 }else if (is_conf){
998 GtkWidget *mw=linphone_gtk_get_main_window();
999 callview=(GtkWidget *)g_object_get_data(G_OBJECT(linphone_gtk_get_main_window()),"conf_frame");
1000 label=linphone_gtk_get_widget(callview,"conf_record_status");
1001 filepath=(const char*)g_object_get_data(G_OBJECT(mw),"conf_record_path");
1002 if (filepath==NULL){
1003 filepath=linphone_gtk_get_record_path(NULL,TRUE);
1004 g_object_set_data_full(G_OBJECT(mw),"conf_record_path",(char*)filepath,g_free);
1005 }
1006 }else{
1007 g_warning("linphone_gtk_record_call_toggled(): bug.");
1008 return;
1009 }
1010 message=g_strdup_printf(_("<small><i>Recording into\n%s %s</i></small>"),filepath,active ? "" : _("(Paused)"));
1011
1012 if (active){
1013 if (call)
1014 linphone_call_start_recording(call);
1015 else
1016 linphone_core_start_conference_recording(lc,filepath);
1017 }else {
1018 if (call)
1019 linphone_call_stop_recording(call);
1020 else
1021 linphone_core_stop_conference_recording(lc);
1022
1023 }
1024 gtk_label_set_markup(GTK_LABEL(label),g_locale_to_utf8(message, -1, NULL, NULL, NULL));
1025 g_free(message);
1026 }
1027
1028