From 43351bae1eb2f338922577ffa6dcc7321e35a37b Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Tue, 22 Feb 2011 18:14:07 +0000 Subject: Don't require EmpathyContacts to start a call --- libempathy-gtk/empathy-call-utils.c | 18 ++++++------- libempathy-gtk/empathy-call-utils.h | 11 +++----- libempathy-gtk/empathy-contact-menu.c | 8 ++++-- libempathy-gtk/empathy-individual-menu.c | 8 ++++-- libempathy-gtk/empathy-new-call-dialog.c | 43 ++------------------------------ 5 files changed, 26 insertions(+), 62 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-call-utils.c b/libempathy-gtk/empathy-call-utils.c index d94e62400..d9c35e2cf 100644 --- a/libempathy-gtk/empathy-call-utils.c +++ b/libempathy-gtk/empathy-call-utils.c @@ -33,7 +33,7 @@ #if HAVE_CALL GHashTable * -empathy_call_create_call_request (EmpathyContact *contact, +empathy_call_create_call_request (const gchar *contact, gboolean initial_audio, gboolean initial_video) { @@ -42,8 +42,8 @@ empathy_call_create_call_request (EmpathyContact *contact, TPY_IFACE_CHANNEL_TYPE_CALL, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, - empathy_contact_get_handle (contact), + TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, + contact, TPY_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO, G_TYPE_BOOLEAN, initial_audio, TPY_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, G_TYPE_BOOLEAN, @@ -53,7 +53,7 @@ empathy_call_create_call_request (EmpathyContact *contact, #endif GHashTable * -empathy_call_create_streamed_media_request (EmpathyContact *contact, +empathy_call_create_streamed_media_request (const gchar *contact, gboolean initial_audio, gboolean initial_video) { @@ -62,8 +62,8 @@ empathy_call_create_streamed_media_request (EmpathyContact *contact, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, - empathy_contact_get_handle (contact), + TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, + contact, TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, initial_audio, TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, @@ -118,14 +118,14 @@ create_call_channel_cb (GObject *source, #endif void -empathy_call_new_with_streams (EmpathyContact *contact, +empathy_call_new_with_streams (const gchar *contact, + TpAccount *account, gboolean initial_audio, gboolean initial_video, gint64 timestamp) { #if HAVE_CALL GHashTable *call_request, *streamed_media_request; - TpAccount *account; TpAccountChannelRequest *call_req, *streamed_media_req; call_request = empathy_call_create_call_request (contact, @@ -135,8 +135,6 @@ empathy_call_new_with_streams (EmpathyContact *contact, streamed_media_request = empathy_call_create_streamed_media_request ( contact, initial_audio, initial_video); - account = empathy_contact_get_account (contact); - call_req = tp_account_channel_request_new (account, call_request, timestamp); streamed_media_req = tp_account_channel_request_new (account, streamed_media_request, diff --git a/libempathy-gtk/empathy-call-utils.h b/libempathy-gtk/empathy-call-utils.h index 1bea52f6a..99a97f202 100644 --- a/libempathy-gtk/empathy-call-utils.h +++ b/libempathy-gtk/empathy-call-utils.h @@ -21,23 +21,20 @@ #ifndef __EMPATHY_CALL_UTILS_H__ #define __EMPATHY_CALL_UTILS_H__ -#include - G_BEGIN_DECLS /* Calls */ -void empathy_call_new_with_streams (EmpathyContact *contact, +void empathy_call_new_with_streams (const gchar *contact, + TpAccount *account, gboolean initial_audio, gboolean initial_video, gint64 timestamp); -GHashTable * empathy_call_create_call_request ( - EmpathyContact *contact, +GHashTable * empathy_call_create_call_request (const gchar *contact, gboolean initial_audio, gboolean initial_video); -GHashTable * empathy_call_create_streamed_media_request ( - EmpathyContact *contact, +GHashTable * empathy_call_create_streamed_media_request (const gchar *contact, gboolean initial_audio, gboolean initial_video); diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c index a9504e085..7bcec3810 100644 --- a/libempathy-gtk/empathy-contact-menu.c +++ b/libempathy-gtk/empathy-contact-menu.c @@ -339,7 +339,9 @@ empathy_contact_audio_call_menu_item_activated (GtkMenuItem *item, EmpathyContact *contact) { - empathy_call_new_with_streams (contact, TRUE, FALSE, + empathy_call_new_with_streams (empathy_contact_get_id (contact), + empathy_contact_get_account (contact), + TRUE, FALSE, gtk_get_current_event_time ()); } @@ -370,7 +372,9 @@ static void empathy_contact_video_call_menu_item_activated (GtkMenuItem *item, EmpathyContact *contact) { - empathy_call_new_with_streams (contact, TRUE, TRUE, + empathy_call_new_with_streams (empathy_contact_get_id (contact), + empathy_contact_get_account (contact), + TRUE, TRUE, gtk_get_current_event_time ()); } diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c index fad18b3f3..a86aed966 100644 --- a/libempathy-gtk/empathy-individual-menu.c +++ b/libempathy-gtk/empathy-individual-menu.c @@ -543,7 +543,9 @@ empathy_individual_audio_call_menu_item_activated (GtkMenuItem *item, { g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - empathy_call_new_with_streams (contact, TRUE, FALSE, + empathy_call_new_with_streams (empathy_contact_get_id (contact), + empathy_contact_get_account (contact), + TRUE, FALSE, gtk_get_current_event_time ()); } @@ -585,7 +587,9 @@ empathy_individual_video_call_menu_item_activated (GtkMenuItem *item, { g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - empathy_call_new_with_streams (contact, TRUE, TRUE, + empathy_call_new_with_streams (empathy_contact_get_id (contact), + empathy_contact_get_account (contact), + TRUE, TRUE, gtk_get_current_event_time ()); } diff --git a/libempathy-gtk/empathy-new-call-dialog.c b/libempathy-gtk/empathy-new-call-dialog.c index cbfbb9569..be266c715 100644 --- a/libempathy-gtk/empathy-new-call-dialog.c +++ b/libempathy-gtk/empathy-new-call-dialog.c @@ -58,11 +58,6 @@ typedef struct { gpointer user_data; } FilterCallbackData; -typedef struct { - gboolean video; - gint64 timestamp; -} ContactCallbackData; - struct _EmpathyNewCallDialogPriv { GtkWidget *check_video; }; @@ -81,41 +76,6 @@ struct _EmpathyNewCallDialogPriv { * to be started with any contact on any enabled account. */ -static void -got_contact_cb (TpConnection *connection, - EmpathyContact *contact, - const GError *error, - gpointer user_data, - GObject *weak_object) -{ - ContactCallbackData *data = user_data; - - if (error != NULL) - g_warning ("Could not get contact: %s", error->message); - else - empathy_call_new_with_streams (contact, - TRUE, data->video, data->timestamp); - - g_slice_free (ContactCallbackData, data); -} - -static void -call_contact (TpAccount *account, - const gchar *contact_id, - gboolean video, - gint64 timestamp) -{ - ContactCallbackData *data = g_slice_new0 (ContactCallbackData); - - data->video = video; - data->timestamp = timestamp; - - empathy_tp_contact_factory_get_from_id (tp_account_get_connection (account), - contact_id, - got_contact_cb, data, - NULL, NULL); -} - static void empathy_new_call_dialog_response (GtkDialog *dialog, int response_id) { @@ -135,7 +95,8 @@ empathy_new_call_dialog_response (GtkDialog *dialog, int response_id) * we return from this function. */ video = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_video)); - call_contact (account, contact_id, video, gtk_get_current_event_time ()); + empathy_call_new_with_streams (contact_id, + account, TRUE, video, gtk_get_current_event_time ()); out: gtk_widget_destroy (GTK_WIDGET (dialog)); -- cgit v1.2.3