2 * Copyright (C) 2011 Collabora Ltd.
4 * The code contained in this file is free software; you can redistribute
5 * it and/or modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either version
7 * 2.1 of the License, or (at your option) any later version.
9 * This file is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this code; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
23 #include <glib/gi18n.h>
27 #include <telepathy-glib/telepathy-glib.h>
29 #include <telepathy-yell/telepathy-yell.h>
31 #include "empathy-call-utils.h"
33 #include <libempathy/empathy-request-util.h>
35 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
36 #include <libempathy/empathy-debug.h>
39 show_call_error (GError *error)
43 dialog = gtk_message_dialog_new (NULL, 0,
44 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
45 _("There was an error starting the call"));
47 g_signal_connect_swapped (dialog, "response",
48 G_CALLBACK (gtk_widget_destroy),
51 gtk_widget_show (dialog);
55 empathy_call_create_call_request (const gchar *contact,
56 gboolean initial_audio,
57 gboolean initial_video)
60 TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
61 TPY_IFACE_CHANNEL_TYPE_CALL,
62 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
63 TP_HANDLE_TYPE_CONTACT,
64 TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING,
66 TPY_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO, G_TYPE_BOOLEAN,
68 TPY_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, G_TYPE_BOOLEAN,
74 empathy_call_create_streamed_media_request (const gchar *contact,
75 gboolean initial_audio,
76 gboolean initial_video)
79 TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
80 TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
81 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
82 TP_HANDLE_TYPE_CONTACT,
83 TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING,
85 TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN,
87 TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN,
93 create_call_channel_cb (GObject *source,
99 if (!tp_account_channel_request_create_channel_finish (
100 TP_ACCOUNT_CHANNEL_REQUEST (source),
104 DEBUG ("Failed to create Call channel: %s", error->message);
105 show_call_error (error);
106 g_error_free (error);
111 create_streamed_media_channel_cb (GObject *source,
112 GAsyncResult *result,
115 TpAccountChannelRequest *call_req = user_data;
116 GError *error = NULL;
118 if (tp_account_channel_request_create_channel_finish (
119 TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
121 g_object_unref (call_req);
125 DEBUG ("Failed to create StreamedMedia channel: %s", error->message);
127 if (error->code != TP_ERROR_NOT_IMPLEMENTED)
129 show_call_error (error);
133 DEBUG ("Let's try with a Call channel");
134 g_error_free (error);
135 tp_account_channel_request_create_channel_async (call_req,
136 EMPATHY_CALL_BUS_NAME, NULL,
137 create_call_channel_cb,
142 empathy_call_new_with_streams (const gchar *contact,
144 gboolean initial_audio,
145 gboolean initial_video,
148 GHashTable *call_request, *streamed_media_request;
149 TpAccountChannelRequest *call_req, *streamed_media_req;
151 call_request = empathy_call_create_call_request (contact,
155 streamed_media_request = empathy_call_create_streamed_media_request (
156 contact, initial_audio, initial_video);
158 call_req = tp_account_channel_request_new (account, call_request, timestamp);
159 streamed_media_req = tp_account_channel_request_new (account,
160 streamed_media_request,
163 tp_account_channel_request_create_channel_async (streamed_media_req,
164 EMPATHY_AV_BUS_NAME, NULL,
165 create_streamed_media_channel_cb,
168 g_hash_table_unref (call_request);
169 g_hash_table_unref (streamed_media_request);
170 g_object_unref (streamed_media_req);