12024
|
1 /**
|
|
2 * @file gtkmedia.h Voice and Video API
|
|
3 * @ingroup gtkui
|
|
4 *
|
|
5 * gaim
|
|
6 *
|
|
7 * Gaim is the legal property of its developers, whose names are too numerous
|
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
9 * source distribution.
|
|
10 *
|
|
11 * This program is free software; you can redistribute it and/or modify
|
|
12 * it under the terms of the GNU General Public License as published by
|
|
13 * the Free Software Foundation; either version 2 of the License, or
|
|
14 * (at your option) any later version.
|
|
15 *
|
|
16 * This program is distributed in the hope that it will be useful,
|
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 * GNU General Public License for more details.
|
|
20 *
|
|
21 * You should have received a copy of the GNU General Public License
|
|
22 * along with this program; if not, write to the Free Software
|
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
24 */
|
|
25
|
|
26 #ifdef HAVE_VV
|
|
27
|
|
28 #include "internal.h"
|
|
29 #include "gtkconv.h"
|
|
30 #include "gtkmedia.h"
|
|
31
|
|
32 typedef struct {
|
|
33 GtkWidget *call_pane;
|
|
34 GtkWidget *bbox;
|
|
35 } GaimGtkVoiceChat;
|
|
36
|
|
37
|
|
38 static void gaim_gtk_media_new_voice_chat(GaimVoiceChat *vc)
|
|
39 {
|
|
40 GaimGtkVoiceChat *gvc = g_new0(GaimGtkVoiceChat, 1);
|
|
41 gaim_voice_chat_set_ui_data(vc, gvc);
|
|
42
|
|
43 }
|
|
44
|
|
45 static void gaim_gtk_media_destroy(GaimVoiceChat *vc)
|
|
46 {
|
|
47 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gaim_connection_get_account(gaim_voice_chat_get_connection(vc)),
|
|
48 gaim_voice_chat_get_name(vc));
|
|
49 gaim_conversation_write(conv, NULL, _("Call ended."), GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
50 GaimGtkVoiceChat *gvc = (GaimGtkVoiceChat*)gaim_voice_chat_get_ui_data(vc);
|
|
51 gtk_widget_destroy(gvc->call_pane);
|
|
52 g_free(gvc);
|
|
53 }
|
|
54
|
|
55 static void gaim_gtk_media_state_change(GaimVoiceChat *vc, GaimMediaState state)
|
|
56 {
|
|
57 GaimGtkVoiceChat *gvc = (GaimGtkVoiceChat*)gaim_voice_chat_get_ui_data(vc);
|
|
58 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gaim_connection_get_account(gaim_voice_chat_get_connection(vc)),
|
|
59 gaim_voice_chat_get_name(vc));
|
|
60 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
|
|
61 GtkWidget *hbox, *bbox;
|
|
62 GtkWidget *button;
|
|
63 char *msg = NULL;
|
|
64
|
|
65 switch (state) {
|
|
66 case GAIM_MEDIA_STATE_CALLING:
|
|
67 msg = g_strdup_printf(_("Calling %s"), gaim_voice_chat_get_name(vc));
|
|
68 gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
69 g_free(msg);
|
|
70 hbox = gtk_hbox_new(FALSE, 6);
|
|
71 button = gtk_button_new_with_label(_("End Call"));
|
|
72 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_terminate), vc);
|
|
73 gvc->call_pane = hbox;
|
|
74 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, 0, 0);
|
|
75 gtk_box_pack_end(GTK_BOX(gtkconv->tab_cont), hbox, FALSE, 0, 0);
|
|
76 gtk_widget_show_all(hbox);
|
|
77 break;
|
|
78 case GAIM_MEDIA_STATE_RECEIVING:
|
|
79 msg = g_strdup_printf(_("Receiving call from %s"), gaim_voice_chat_get_name(vc));
|
|
80 gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
81 g_free(msg);
|
|
82 hbox = gtk_hbox_new(FALSE, 6);
|
|
83 bbox = gvc->bbox = gtk_hbutton_box_new();
|
|
84 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
|
85 gtk_box_set_spacing(GTK_BOX(bbox), 6);
|
|
86 gtk_container_add(GTK_CONTAINER(hbox), bbox);
|
|
87 button = gtk_button_new_with_label(_("Reject Call"));
|
|
88 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_reject), vc);
|
|
89 gvc->call_pane = hbox;
|
|
90 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, 0, 0);
|
|
91 gtk_box_pack_end(GTK_BOX(gtkconv->tab_cont), hbox, FALSE, 0, 0);
|
|
92
|
|
93 button = gtk_button_new_with_label(_("Accept call"));
|
|
94 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_accept), vc);
|
|
95 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, 0, 0);
|
|
96
|
|
97 gtk_widget_show_all(hbox);
|
|
98 break;
|
|
99 case GAIM_MEDIA_STATE_IN_PROGRESS:
|
|
100 msg = g_strdup_printf(_("Connected to %s"), gaim_voice_chat_get_name(vc));
|
|
101 gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
102 g_free(msg);
|
|
103 if (gvc->bbox) {
|
|
104 gtk_widget_destroy(gvc->bbox);
|
|
105 gvc->bbox = NULL;
|
|
106 button = gtk_button_new_with_label(_("End Call"));
|
|
107 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_terminate), vc);
|
|
108 gtk_box_pack_end(GTK_BOX(gvc->call_pane), button, FALSE, 0, 0);
|
|
109 gtk_widget_show(button);
|
|
110 }
|
|
111 button = gtk_check_button_new_with_mnemonic(_("_Mute"));
|
|
112 gtk_box_pack_start(GTK_BOX(gvc->call_pane), button, FALSE, 0, 0);
|
|
113 gtk_widget_show(button);
|
|
114 break;
|
|
115 default:
|
|
116 break;
|
|
117 }
|
|
118 }
|
|
119
|
|
120
|
|
121 static GaimMediaUiOps ui_ops =
|
|
122 {
|
|
123 gaim_gtk_media_new_voice_chat,
|
|
124 gaim_gtk_media_destroy,
|
|
125 gaim_gtk_media_state_change
|
|
126 };
|
|
127
|
|
128 void gaim_gtk_media_init(void)
|
|
129 {
|
|
130 gaim_debug_info("gtkmedia","Initialising\n");
|
|
131 gaim_media_set_ui_ops(&ui_ops);
|
|
132 }
|
|
133
|
|
134 #endif /* HAVE_VV */
|