2 linphone, gtk-glade interface.
3 Copyright (C) 2009 Simon MORLAT (simon.morlat@linphone.org)
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * C Implementation: incall_frame
25 * Author: Simon Morlat <simon.morlat@linphone.org>, (C) 2009
33 gboolean linphone_gtk_use_in_call_view(){
35 if (val==-1) val=linphone_gtk_get_ui_config_int("use_incall_view",1);
39 LinphoneCall *linphone_gtk_get_currently_displayed_call(gboolean *is_conf){
40 LinphoneCore *lc=linphone_gtk_get_core();
41 GtkWidget *main_window=linphone_gtk_get_main_window ();
42 GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
43 const MSList *calls=linphone_core_get_calls(lc);
44 if (is_conf) *is_conf=FALSE;
45 if (!linphone_gtk_use_in_call_view() || ms_list_size(calls)==1){
46 if (calls) return (LinphoneCall*)calls->data;
48 int idx=gtk_notebook_get_current_page (notebook);
49 GtkWidget *page=gtk_notebook_get_nth_page(notebook,idx);
51 LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(page),"call");
53 if (page==g_object_get_data(G_OBJECT(main_window),"conference_tab")){
65 static GtkWidget *make_tab_header(int number){
66 GtkWidget *w=gtk_hbox_new (FALSE,0);
67 GtkWidget *i=create_pixmap ("status-green.png");
69 gchar *text=g_strdup_printf(_("Call #%i"),number);
70 l=gtk_label_new (text);
71 gtk_box_pack_start (GTK_BOX(w),i,FALSE,FALSE,0);
72 gtk_box_pack_end(GTK_BOX(w),l,TRUE,TRUE,0);
73 gtk_widget_show_all(w);
77 static void linphone_gtk_in_call_set_animation_image(GtkWidget *callview, const char *image_name, gboolean is_stock){
78 GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation");
79 GList *elem=gtk_container_get_children(GTK_CONTAINER(container));
83 if (image_name==NULL){
84 gtk_widget_hide(container);
86 image=create_pixmap(image_name);
88 image=gtk_image_new_from_stock(image_name,GTK_ICON_SIZE_DIALOG);
90 gtk_widget_destroy((GtkWidget*)elem->data);
91 gtk_widget_show(image);
92 gtk_container_add(GTK_CONTAINER(container),image);
93 gtk_widget_show_all(container);
96 static void linphone_gtk_in_call_set_animation_spinner(GtkWidget *callview){
97 #if GTK_CHECK_VERSION(2,20,0)
98 GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation");
99 GList *elem=gtk_container_get_children(GTK_CONTAINER(container));
100 GtkWidget *spinner=gtk_spinner_new();
102 gtk_widget_destroy((GtkWidget*)elem->data);
103 gtk_widget_show(spinner);
104 gtk_container_add(GTK_CONTAINER(container),spinner);
105 gtk_widget_set_size_request(spinner, 20,20);
106 gtk_spinner_start(GTK_SPINNER(spinner));
110 static void linphone_gtk_transfer_call(LinphoneCall *dest_call){
111 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(NULL);
112 if (call) linphone_core_transfer_call_to_another(linphone_gtk_get_core(),call,dest_call);
115 static void transfer_button_clicked(GtkWidget *button, gpointer call_ref){
116 GtkWidget *menu_item;
117 GtkWidget *menu=gtk_menu_new();
118 LinphoneCall *call=(LinphoneCall*)call_ref;
119 LinphoneCore *lc=linphone_gtk_get_core();
120 const MSList *elem=linphone_core_get_calls(lc);
122 for(;elem!=NULL;elem=elem->next){
123 LinphoneCall *other_call=(LinphoneCall*)elem->data;
124 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(other_call);
125 if (other_call!=call){
126 int call_index=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(call_view),"call_index"));
127 char *remote_uri=linphone_call_get_remote_address_as_string (other_call);
128 char *text=g_strdup_printf(_("Transfer to call #%i with %s"),call_index,remote_uri);
129 menu_item=gtk_image_menu_item_new_with_label(text);
132 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),create_pixmap("status-green.png"));
133 gtk_widget_show(menu_item);
134 gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
135 g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_transfer_call,other_call);
138 gtk_menu_popup(GTK_MENU(menu),NULL,NULL,NULL,NULL,0,
139 gtk_get_current_event_time());
140 gtk_widget_show(menu);
143 void linphone_gtk_enable_transfer_button(LinphoneCore *lc, gboolean value){
144 const MSList *elem=linphone_core_get_calls(lc);
145 for(;elem!=NULL;elem=elem->next){
146 LinphoneCall *call=(LinphoneCall*)elem->data;
147 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
148 GtkWidget *box=linphone_gtk_get_widget (call_view,"mute_pause_buttons");
149 GtkWidget *button=(GtkWidget*)g_object_get_data(G_OBJECT(box),"transfer");
150 if (button && value==FALSE){
151 gtk_widget_destroy(button);
153 }else if (!button && value==TRUE){
154 button=gtk_button_new_with_label (_("Transfer"));
155 //gtk_button_set_image_position(GTK_BUTTON(button),GTK_POS_BOTTOM);
156 gtk_button_set_image(GTK_BUTTON(button),gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_BUTTON));
157 g_signal_connect(G_OBJECT(button),"clicked",(GCallback)transfer_button_clicked,call);
158 gtk_widget_show_all(button);
159 gtk_container_add(GTK_CONTAINER(box),button);
161 g_object_set_data(G_OBJECT(box),"transfer",button);
165 static void conference_button_clicked(GtkWidget *button, gpointer call_ref){
166 linphone_core_add_all_to_conference(linphone_gtk_get_core());
167 //linphone_core_add_to_conference(linphone_gtk_get_core(),(LinphoneCall*)call_ref);
168 gtk_widget_set_sensitive(button,FALSE);
171 void linphone_gtk_enable_conference_button(LinphoneCore *lc, gboolean value){
172 const MSList *elem=linphone_core_get_calls(lc);
173 for(;elem!=NULL;elem=elem->next){
174 LinphoneCall *call=(LinphoneCall*)elem->data;
175 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
176 GtkWidget *box=linphone_gtk_get_widget (call_view,"mute_pause_buttons");
177 GtkWidget *button=(GtkWidget*)g_object_get_data(G_OBJECT(box),"conference");
178 if (button && value==FALSE){
179 gtk_widget_destroy(button);
181 }else if (!button && value==TRUE){
182 button=gtk_button_new_with_label (_("Conference"));
183 //gtk_button_set_image_position(GTK_BUTTON(button),GTK_POS_BOTTOM);
184 gtk_button_set_image(GTK_BUTTON(button),gtk_image_new_from_stock (GTK_STOCK_ADD,GTK_ICON_SIZE_BUTTON));
185 g_signal_connect(G_OBJECT(button),"clicked",(GCallback)conference_button_clicked,call);
186 gtk_widget_show_all(button);
187 gtk_container_add(GTK_CONTAINER(box),button);
189 g_object_set_data(G_OBJECT(box),"conference",button);
193 void linphone_gtk_create_in_call_view(LinphoneCall *call){
194 GtkWidget *call_view=linphone_gtk_create_widget("main","in_call_frame");
195 GtkWidget *main_window=linphone_gtk_get_main_window ();
196 GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
197 static int call_index=1;
200 if (ms_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){
201 /*this is the only call at this time */
204 g_object_set_data(G_OBJECT(call_view),"call",call);
205 g_object_set_data(G_OBJECT(call_view),"call_index",GINT_TO_POINTER(call_index));
207 linphone_call_set_user_pointer (call,call_view);
208 linphone_call_ref(call);
209 gtk_notebook_append_page (notebook,call_view,make_tab_header(call_index));
210 gtk_widget_show(call_view);
211 idx = gtk_notebook_page_num(notebook, call_view);
212 gtk_notebook_set_current_page(notebook, idx);
214 linphone_gtk_enable_hold_button (call,FALSE,TRUE);
215 linphone_gtk_enable_mute_button(
216 GTK_BUTTON(linphone_gtk_get_widget(call_view,"incall_mute")),FALSE);
218 GtkWidget *button=linphone_gtk_get_widget(call_view,"terminate_call");
219 GtkWidget *image=create_pixmap("stopcall-red.png");
220 gtk_button_set_label(GTK_BUTTON(button),_("Stop"));
221 gtk_button_set_image(GTK_BUTTON(button),image);
222 gtk_widget_show(image);
226 static void video_button_clicked(GtkWidget *button, LinphoneCall *call){
227 gboolean adding=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"adding_video"));
228 LinphoneCore *lc=linphone_call_get_core(call);
229 LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call));
230 gtk_widget_set_sensitive(button,FALSE);
231 linphone_call_params_enable_video(params,adding);
232 linphone_core_update_call(lc,call,params);
233 linphone_call_params_destroy(params);
236 void linphone_gtk_update_video_button(LinphoneCall *call){
237 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
239 const LinphoneCallParams *params=linphone_call_get_current_params(call);
240 gboolean has_video=linphone_call_params_video_enabled(params);
241 if (call_view==NULL) return;
242 button=linphone_gtk_get_widget(call_view,"video_button");
244 gtk_button_set_image(GTK_BUTTON(button),
245 gtk_image_new_from_stock(has_video ? GTK_STOCK_REMOVE : GTK_STOCK_ADD,GTK_ICON_SIZE_BUTTON));
246 g_object_set_data(G_OBJECT(button),"adding_video",GINT_TO_POINTER(!has_video));
247 if (!linphone_core_video_supported(linphone_call_get_core(call))){
248 gtk_widget_set_sensitive(button,FALSE);
251 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"signal_connected"))==0){
252 g_signal_connect(G_OBJECT(button),"clicked",(GCallback)video_button_clicked,call);
253 g_object_set_data(G_OBJECT(button),"signal_connected",GINT_TO_POINTER(1));
255 gtk_widget_set_sensitive(button,linphone_call_get_state(call)==LinphoneCallStreamsRunning);
258 void linphone_gtk_remove_in_call_view(LinphoneCall *call){
259 GtkWidget *w=(GtkWidget*)linphone_call_get_user_pointer (call);
260 GtkWidget *main_window=linphone_gtk_get_main_window ();
261 GtkWidget *nb=linphone_gtk_get_widget(main_window,"viewswitch");
262 gboolean in_conf=linphone_call_params_local_conference_mode(linphone_call_get_current_params(call));
264 g_return_if_fail(w!=NULL);
265 idx=gtk_notebook_page_num(GTK_NOTEBOOK(nb),w);
266 gtk_notebook_remove_page (GTK_NOTEBOOK(nb),idx);
267 gtk_widget_destroy(w);
269 linphone_gtk_unset_from_conference(call);
271 linphone_call_set_user_pointer (call,NULL);
272 linphone_call_unref(call);
273 call=linphone_core_get_current_call(linphone_gtk_get_core());
275 if (linphone_core_is_in_conference(linphone_gtk_get_core())){
276 /*show the conference*/
277 gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),
278 g_object_get_data(G_OBJECT(main_window),"conference_tab")));
279 }else gtk_notebook_set_current_page(GTK_NOTEBOOK(nb), 0);
281 /*show the active call*/
282 gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),
283 linphone_call_get_user_pointer(call)));
287 static void display_peer_name_in_label(GtkWidget *label, const LinphoneAddress *from){
288 const char *displayname=NULL;
291 displayname=linphone_address_get_display_name(from);
292 id=linphone_address_as_string_uri_only(from);
294 if (displayname!=NULL){
295 uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>",
298 uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
299 gtk_label_set_markup(GTK_LABEL(label),uri_label);
303 void linphone_gtk_in_call_view_set_calling(LinphoneCall *call){
304 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
305 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
306 GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
307 GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
309 gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
310 display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
312 gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
313 linphone_gtk_in_call_set_animation_spinner(callview);
316 void linphone_gtk_in_call_view_set_incoming(LinphoneCall *call){
317 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
318 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
319 GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
320 GtkWidget *answer_button;
323 gtk_label_set_markup(GTK_LABEL(status),_("<b>Incoming call</b>"));
324 gtk_widget_show_all(linphone_gtk_get_widget(callview,"answer_decline_panel"));
325 gtk_widget_hide(linphone_gtk_get_widget(callview,"mute_pause_buttons"));
326 display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
328 answer_button=linphone_gtk_get_widget(callview,"accept_call");
329 image=create_pixmap (linphone_gtk_get_ui_config("start_call_icon","startcall-green.png"));
330 gtk_button_set_label(GTK_BUTTON(answer_button),_("Answer"));
331 gtk_button_set_image(GTK_BUTTON(answer_button),image);
332 gtk_widget_show(image);
334 image=create_pixmap (linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"));
335 gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(callview,"decline_call")),image);
336 gtk_widget_show(image);
338 linphone_gtk_in_call_set_animation_image(callview,GTK_STOCK_DIALOG_INFO,TRUE);
341 static void rating_to_color(float rating, GdkColor *color){
342 const char *colorname="grey";
345 else if (rating>=3.0)
347 else if (rating>=2.0)
349 else if (rating>=1.0)
353 if (!gdk_color_parse(colorname,color)){
354 g_warning("Fail to parse color %s",colorname);
358 static const char *rating_to_text(float rating){
366 return _("very poor");
369 return _("unavailable");
372 static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){
373 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
374 GtkWidget *qi=linphone_gtk_get_widget(callview,"quality_indicator");
375 float rating=linphone_call_get_current_quality(call);
378 linphone_gtk_in_call_view_update_duration(call);
380 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(qi),rating/5.0);
381 snprintf(tmp,sizeof(tmp),"%.1f (%s)",rating,rating_to_text(rating));
382 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(qi),tmp);
384 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(qi),0);
385 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(qi),_("unavailable"));
387 rating_to_color(rating,&color);
388 gtk_widget_modify_bg(qi,GTK_STATE_NORMAL,&color);
394 typedef struct _volume_ctx{
396 get_volume_t get_volume;
401 #define UNSIGNIFICANT_VOLUME (-26)
404 static gboolean update_audio_meter(volume_ctx_t *ctx){
405 float volume_db=ctx->get_volume(ctx->data);
406 float frac=(volume_db-UNSIGNIFICANT_VOLUME)/(float)(-UNSIGNIFICANT_VOLUME+3.0);
408 if (frac>1.0) frac=1.0;
409 if (frac<ctx->last_value){
410 frac=(frac*SMOOTH)+(ctx->last_value*(1-SMOOTH));
412 ctx->last_value=frac;
413 //g_message("volume_db=%f, frac=%f",volume_db,frac);
414 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ctx->widget),frac);
418 static void on_audio_meter_destroy(guint task_id){
419 g_source_remove(task_id);
422 void linphone_gtk_init_audio_meter(GtkWidget *w, get_volume_t get_volume, void *data){
423 guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id"));
425 volume_ctx_t *ctx=g_new(volume_ctx_t,1);
427 ctx->get_volume=get_volume;
430 g_object_set_data_full(G_OBJECT(w),"ctx",ctx,g_free);
431 task_id=g_timeout_add(50,(GSourceFunc)update_audio_meter,ctx);
432 g_object_set_data_full(G_OBJECT(w),"task_id",GINT_TO_POINTER(task_id),(GDestroyNotify)on_audio_meter_destroy);
436 void linphone_gtk_uninit_audio_meter(GtkWidget *w){
437 guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id"));
439 g_object_set_data(G_OBJECT(w),"ctx",NULL);
440 g_object_set_data(G_OBJECT(w),"task_id",NULL);
444 void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call, gboolean val){
445 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
446 GtkWidget *audio_view=linphone_gtk_get_widget(callview,"incall_audioview");
447 //GtkWidget *mic=linphone_gtk_get_widget(callview,"incall_mic_icon");
448 GtkWidget *spk=linphone_gtk_get_widget(callview,"incall_spk_icon");
449 GtkWidget *mic_level=linphone_gtk_get_widget(callview,"mic_audiolevel");
450 GtkWidget *spk_level=linphone_gtk_get_widget(callview,"spk_audiolevel");
452 //gtk_image_set_from_pixbuf(GTK_IMAGE(mic),(pbuf=create_pixbuf("mic_active.png")));
453 //g_object_unref(pbuf);
455 gtk_image_set_from_pixbuf(GTK_IMAGE(spk),(pbuf=create_pixbuf("speaker.png")));
456 g_object_unref(pbuf);
457 linphone_gtk_init_audio_meter(mic_level,(get_volume_t)linphone_call_get_record_volume,call);
458 linphone_gtk_init_audio_meter(spk_level,(get_volume_t)linphone_call_get_play_volume,call);
459 gtk_widget_show_all(audio_view);
461 linphone_gtk_uninit_audio_meter(mic_level);
462 linphone_gtk_uninit_audio_meter(spk_level);
463 gtk_widget_hide(audio_view);
467 void linphone_gtk_auth_token_verified_clicked(GtkButton *button){
468 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(NULL);
470 linphone_call_set_authentication_token_verified(call,!linphone_call_get_authentication_token_verified(call));
474 void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call){
475 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
476 GtkWidget *encryption_box=linphone_gtk_get_widget(callview,"encryption_box");
477 GtkWidget *label=linphone_gtk_get_widget(callview,"encryption_label");
478 GtkWidget *status_icon=linphone_gtk_get_widget(callview,"encryption_status_icon");
479 GtkWidget *verify_button=linphone_gtk_get_widget(callview,"encryption_verify_button");
480 LinphoneMediaEncryption me=linphone_call_params_get_media_encryption(linphone_call_get_current_params(call));
481 bool_t verified=linphone_call_get_authentication_token_verified(call);
483 case LinphoneMediaEncryptionSRTP:
484 gtk_widget_show_all(encryption_box);
485 gtk_label_set_markup(GTK_LABEL(label),_("Secured by SRTP"));
486 gtk_widget_hide(status_icon);
487 gtk_widget_hide(verify_button);
489 case LinphoneMediaEncryptionZRTP:
491 gchar *text=g_strdup_printf(_("Secured by ZRTP - [auth token: %s]"),linphone_call_get_authentication_token(call));
492 gtk_label_set_markup(GTK_LABEL(label),text);
494 gtk_image_set_from_stock(GTK_IMAGE(status_icon),
495 verified ? GTK_STOCK_APPLY : GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_MENU);
496 gtk_button_set_label(GTK_BUTTON(verify_button),
497 verified ? _("Set unverified") : _("Set verified"));
498 gtk_widget_show_all(encryption_box);
502 gtk_widget_hide_all(encryption_box);
506 void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){
507 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
508 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
509 GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
510 GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
511 guint taskid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(callview),"taskid"));
512 gboolean in_conf=linphone_call_params_local_conference_mode(linphone_call_get_current_params(call));
514 display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
516 gtk_widget_set_visible(linphone_gtk_get_widget(callview,"mute_pause_buttons"),!in_conf);
517 gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
518 gtk_label_set_markup(GTK_LABEL(status),in_conf ? _("In conference") : _("<b>In call</b>"));
520 gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
521 linphone_gtk_in_call_set_animation_image(callview,GTK_STOCK_MEDIA_PLAY,TRUE);
522 linphone_gtk_enable_mute_button(
523 GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),!in_conf);
525 taskid=g_timeout_add(250,(GSourceFunc)linphone_gtk_in_call_view_refresh,call);
526 g_object_set_data(G_OBJECT(callview),"taskid",GINT_TO_POINTER(taskid));
528 linphone_gtk_in_call_view_enable_audio_view(call, !in_conf);
529 linphone_gtk_in_call_view_show_encryption(call);
530 if (in_conf) linphone_gtk_set_in_conference(call);
533 void linphone_gtk_in_call_view_set_paused(LinphoneCall *call){
534 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
535 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
536 gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
537 gtk_label_set_markup(GTK_LABEL(status),_("<b>Paused call</b>"));
538 linphone_gtk_in_call_set_animation_image(callview,GTK_STOCK_MEDIA_PAUSE,TRUE);
541 void linphone_gtk_in_call_view_update_duration(LinphoneCall *call){
542 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
543 GtkWidget *duration_label=linphone_gtk_get_widget(callview,"in_call_duration");
544 int duration=linphone_call_get_duration(call);
546 int seconds=duration%60;
547 int minutes=(duration/60)%60;
548 int hours=duration/3600;
549 snprintf(tmp,sizeof(tmp)-1,_("%02i::%02i::%02i"),hours,minutes,seconds);
550 gtk_label_set_text(GTK_LABEL(duration_label),tmp);
553 static gboolean in_call_view_terminated(LinphoneCall *call){
554 linphone_gtk_remove_in_call_view(call);
558 void linphone_gtk_in_call_view_terminate(LinphoneCall *call, const char *error_msg){
559 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
560 GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
561 guint taskid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(callview),"taskid"));
562 gboolean in_conf=linphone_call_params_local_conference_mode(linphone_call_get_current_params(call));
564 if ((callview==NULL) || (status==NULL)) return;
566 gtk_label_set_markup(GTK_LABEL(status),_("<b>Call ended.</b>"));
568 char *msg=g_markup_printf_escaped("<span color=\"red\"><b>%s</b></span>",error_msg);
569 gtk_label_set_markup(GTK_LABEL(status),msg);
572 linphone_gtk_in_call_set_animation_image(callview,
573 linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"),FALSE);
575 gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
576 gtk_widget_hide(linphone_gtk_get_widget(callview,"incall_audioview"));
577 gtk_widget_hide(linphone_gtk_get_widget(callview,"terminate_call"));
578 gtk_widget_hide(linphone_gtk_get_widget(callview,"video_button"));
579 linphone_gtk_enable_mute_button(
580 GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),FALSE);
581 linphone_gtk_enable_hold_button(call,FALSE,TRUE);
583 if (taskid!=0) g_source_remove(taskid);
584 g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,call);
586 linphone_gtk_terminate_conference_participant(call);
589 void linphone_gtk_in_call_view_set_transfer_status(LinphoneCall *call,LinphoneCallState cstate){
590 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
592 GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
593 const char *transfer_status="unknown";
595 case LinphoneCallOutgoingProgress:
596 transfer_status=_("Transfer in progress");
598 case LinphoneCallConnected:
599 transfer_status=_("Transfer done.");
601 case LinphoneCallError:
602 transfer_status=_("Transfer failed.");
607 gtk_label_set_text(GTK_LABEL(duration),transfer_status);
611 void linphone_gtk_draw_mute_button(GtkButton *button, gboolean active){
612 g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
614 GtkWidget *image=create_pixmap("mic_muted.png");
615 /*gtk_button_set_label(GTK_BUTTON(button),_("Unmute"));*/
617 gtk_button_set_image(GTK_BUTTON(button),image);
618 gtk_widget_show(image);
621 GtkWidget *image=create_pixmap("mic_active.png");
622 /*gtk_button_set_label(GTK_BUTTON(button),_("Mute"));*/
624 gtk_button_set_image(GTK_BUTTON(button),image);
625 gtk_widget_show(image);
630 void linphone_gtk_mute_clicked(GtkButton *button){
631 int active=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"active"));
632 linphone_core_mute_mic(linphone_gtk_get_core(),!active);
633 linphone_gtk_draw_mute_button(button,!active);
636 void linphone_gtk_enable_mute_button(GtkButton *button, gboolean sensitive)
638 /*gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);*/
639 gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
640 linphone_gtk_draw_mute_button(button,FALSE);
643 void linphone_gtk_draw_hold_button(GtkButton *button, gboolean active){
644 g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
646 GtkWidget *image=create_pixmap("hold_off.png");
647 gtk_button_set_label(GTK_BUTTON(button),_("Resume"));
649 gtk_button_set_image(GTK_BUTTON(button),image);
650 gtk_widget_show(image);
653 GtkWidget *image=create_pixmap("hold_on.png");
654 gtk_button_set_label(GTK_BUTTON(button),_("Pause"));
656 gtk_button_set_image(GTK_BUTTON(button),image);
657 gtk_widget_show(image);
662 void linphone_gtk_hold_clicked(GtkButton *button){
663 int active=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"active"));
664 LinphoneCall *call=linphone_gtk_get_currently_displayed_call(NULL);
668 linphone_core_pause_call(linphone_gtk_get_core(),call);
672 linphone_core_resume_call(linphone_gtk_get_core(),call);
676 void linphone_gtk_enable_hold_button(LinphoneCall *call, gboolean sensitive, gboolean holdon){
677 GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer (call);
679 g_return_if_fail(callview!=NULL);
680 button=linphone_gtk_get_widget(callview,"hold_call");
681 gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
682 gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
683 linphone_gtk_draw_hold_button(GTK_BUTTON(button),!holdon);