diff options
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-menu.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-new-message-dialog.c | 83 | ||||
-rw-r--r-- | libempathy/empathy-auth-factory.c | 4 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.c | 24 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.h | 13 | ||||
-rw-r--r-- | src/empathy-call-window.c | 55 | ||||
-rw-r--r-- | src/empathy-chat-manager.c | 9 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 9 | ||||
-rw-r--r-- | src/empathy-main-window.c | 86 | ||||
m--------- | telepathy-yell | 0 |
11 files changed, 220 insertions, 72 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 1063ad196..43ece8fac 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -258,11 +258,13 @@ account_reconnected (EmpathyChat *chat, if (priv->sms_channel) empathy_dispatcher_sms_contact_id ( account, priv->id, - TP_USER_ACTION_TIME_NOT_USER_ACTION); + TP_USER_ACTION_TIME_NOT_USER_ACTION, + NULL, NULL); else empathy_dispatcher_chat_with_contact_id ( account, priv->id, - TP_USER_ACTION_TIME_NOT_USER_ACTION); + TP_USER_ACTION_TIME_NOT_USER_ACTION, + NULL, NULL); break; case TP_HANDLE_TYPE_ROOM: empathy_dispatcher_join_muc (account, priv->id, diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c index 8b1ed66a7..d65f24ee2 100644 --- a/libempathy-gtk/empathy-individual-menu.c +++ b/libempathy-gtk/empathy-individual-menu.c @@ -566,7 +566,8 @@ empathy_individual_sms_menu_item_activated (GtkMenuItem *item, empathy_dispatcher_sms_contact_id ( empathy_contact_get_account (contact), empathy_contact_get_id (contact), - gtk_get_current_event_time ()); + gtk_get_current_event_time (), + NULL, NULL); } GtkWidget * diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index 1fe935d4e..d3c04c327 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -68,6 +68,81 @@ enum EMP_NEW_MESSAGE_SMS, }; +static const gchar * +get_error_display_message (GError *error) +{ + if (error->domain != TP_ERROR) + goto out; + + switch (error->code) + { + case TP_ERROR_NETWORK_ERROR: + return _("Network error"); + case TP_ERROR_OFFLINE: + return _("The contact is offline"); + case TP_ERROR_INVALID_HANDLE: + return _("The specified contact is either invalid or unknown"); + case TP_ERROR_NOT_CAPABLE: + return _("The contact does not support this kind of conversation"); + case TP_ERROR_NOT_IMPLEMENTED: + return _("The requested functionality is not implemented " + "for this protocol"); + case TP_ERROR_INVALID_ARGUMENT: + /* Not very user friendly to say 'invalid arguments' */ + break; + case TP_ERROR_NOT_AVAILABLE: + return _("Could not start a conversation with the given contact"); + case TP_ERROR_CHANNEL_BANNED: + return _("You are banned from this channel"); + case TP_ERROR_CHANNEL_FULL: + return _("This channel is full"); + case TP_ERROR_CHANNEL_INVITE_ONLY: + return _("You must be invited to join this channel"); + case TP_ERROR_DISCONNECTED: + return _("Can't proceed while disconnected"); + case TP_ERROR_PERMISSION_DENIED: + return _("Permission denied"); + default: + DEBUG ("Unhandled error code: %d", error->code); + } + +out: + return _("There was an error starting the conversation"); +} + +static void +show_chat_error (GError *error, GtkWindow *parent) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "%s", + get_error_display_message (error)); + + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + dialog); + + gtk_widget_show (dialog); +} + +static void +ensure_text_channel_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + GError *error = NULL; + + if (!tp_account_channel_request_ensure_channel_finish ( + TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error)) + { + DEBUG ("Failed to ensure text channel: %s", error->message); + show_chat_error (error, user_data); + g_error_free (error); + } +} + static void empathy_new_message_dialog_response (GtkDialog *dialog, int response_id) { @@ -85,12 +160,16 @@ empathy_new_message_dialog_response (GtkDialog *dialog, int response_id) { case EMP_NEW_MESSAGE_TEXT: empathy_dispatcher_chat_with_contact_id (account, contact_id, - gtk_get_current_event_time ()); + gtk_get_current_event_time (), + ensure_text_channel_cb, + gtk_widget_get_parent_window (GTK_WIDGET (dialog))); break; case EMP_NEW_MESSAGE_SMS: empathy_dispatcher_sms_contact_id (account, contact_id, - gtk_get_current_event_time ()); + gtk_get_current_event_time (), + ensure_text_channel_cb, + gtk_widget_get_parent_window (GTK_WIDGET (dialog))); break; default: diff --git a/libempathy/empathy-auth-factory.c b/libempathy/empathy-auth-factory.c index 860222605..b98669559 100644 --- a/libempathy/empathy-auth-factory.c +++ b/libempathy/empathy-auth-factory.c @@ -20,9 +20,7 @@ #include "empathy-auth-factory.h" -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/simple-handler.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> #define DEBUG_FLAG EMPATHY_DEBUG_TLS #include "empathy-debug.h" diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index b1cc1d267..353e94612 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -491,7 +491,7 @@ empathy_dispatcher_chat_with_contact (EmpathyContact *contact, { empathy_dispatcher_chat_with_contact_id ( empathy_contact_get_account (contact), empathy_contact_get_id (contact), - timestamp); + timestamp, NULL, NULL); } static void @@ -514,7 +514,9 @@ empathy_dispatcher_create_text_channel (TpAccount *account, TpHandleType target_handle_type, const gchar *target_id, gboolean sms_channel, - gint64 timestamp) + gint64 timestamp, + GAsyncReadyCallback callback, + gpointer user_data) { GHashTable *request; TpAccountChannelRequest *req; @@ -533,19 +535,23 @@ empathy_dispatcher_create_text_channel (TpAccount *account, req = tp_account_channel_request_new (account, request, timestamp); tp_account_channel_request_ensure_channel_async (req, NULL, NULL, - ensure_text_channel_cb, NULL); + callback ? callback : ensure_text_channel_cb, user_data); g_hash_table_unref (request); g_object_unref (req); } +/* @callback is optional, but if it's provided, it should call the right + * _finish() func that we call in ensure_text_channel_cb() */ void empathy_dispatcher_chat_with_contact_id (TpAccount *account, const gchar *contact_id, - gint64 timestamp) + gint64 timestamp, + GAsyncReadyCallback callback, + gpointer user_data) { empathy_dispatcher_create_text_channel (account, TP_HANDLE_TYPE_CONTACT, - contact_id, FALSE, timestamp); + contact_id, FALSE, timestamp, callback, user_data); } void @@ -554,16 +560,18 @@ empathy_dispatcher_join_muc (TpAccount *account, gint64 timestamp) { empathy_dispatcher_create_text_channel (account, TP_HANDLE_TYPE_ROOM, - room_name, FALSE, timestamp); + room_name, FALSE, timestamp, NULL, NULL); } void empathy_dispatcher_sms_contact_id (TpAccount *account, const gchar *contact_id, - gint64 timestamp) + gint64 timestamp, + GAsyncReadyCallback callback, + gpointer user_data) { empathy_dispatcher_create_text_channel (account, TP_HANDLE_TYPE_CONTACT, - contact_id, TRUE, timestamp); + contact_id, TRUE, timestamp, callback, user_data); } static gboolean diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h index 19da9dde5..0afd4e53a 100644 --- a/libempathy/empathy-dispatcher.h +++ b/libempathy/empathy-dispatcher.h @@ -60,9 +60,11 @@ GType empathy_dispatcher_get_type (void) G_GNUC_CONST; /* Requesting 1 to 1 text channels */ void empathy_dispatcher_chat_with_contact_id (TpAccount *account, const gchar *contact_id, - gint64 timestamp); + gint64 timestamp, + GAsyncReadyCallback callback, + gpointer user_data); -void empathy_dispatcher_chat_with_contact (EmpathyContact *contact, +void empathy_dispatcher_chat_with_contact (EmpathyContact *contact, gint64 timestamp); /* Request a muc channel */ @@ -70,10 +72,11 @@ void empathy_dispatcher_join_muc (TpAccount *account, const gchar *roomname, gint64 timestamp); -void -empathy_dispatcher_sms_contact_id (TpAccount *account, +void empathy_dispatcher_sms_contact_id (TpAccount *account, const gchar *contact_id, - gint64 timestamp); + gint64 timestamp, + GAsyncReadyCallback callback, + gpointer user_data); void empathy_dispatcher_find_requestable_channel_classes_async (EmpathyDispatcher *dispatcher, TpConnection *connection, diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 4728e9f64..98993fc7d 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -85,6 +85,7 @@ enum { typedef enum { CONNECTING, CONNECTED, + HELD, DISCONNECTED, REDIALING } CallState; @@ -1744,6 +1745,10 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self) g_signal_handlers_disconnect_by_func (priv->audio_input_adj, empathy_call_window_mic_volume_changed_cb, self); + if (priv->audio_output != NULL) + g_object_unref (priv->audio_output); + priv->audio_output = NULL; + if (priv->video_tee != NULL) g_object_unref (priv->video_tee); priv->video_tee = NULL; @@ -2022,6 +2027,7 @@ empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self) if (priv->audio_output == NULL) { priv->audio_output = empathy_audio_sink_new (); + g_object_ref_sink (priv->audio_output); if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output)) { @@ -2072,9 +2078,10 @@ empathy_call_window_update_timer (gpointer user_data) time_ = g_timer_elapsed (priv->timer, NULL); - /* Translators: number of minutes:seconds the caller has been connected */ - str = g_strdup_printf (_("Connected — %d:%02dm"), (int) time_ / 60, - (int) time_ % 60); + /* Translators: 'status - minutes:seconds' the caller has been connected */ + str = g_strdup_printf (_("%s — %d:%02dm"), + priv->call_state == HELD ? _("On hold") : _("Connected"), + (int) time_ / 60, (int) time_ % 60); empathy_call_window_status_message (self, str); g_free (str); @@ -2745,6 +2752,35 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message, } static void +empathy_call_window_members_changed_cb (TpyCallChannel *call, + GHashTable *members, + EmpathyCallWindow *self) +{ + EmpathyCallWindowPriv *priv = GET_PRIV (self); + GHashTableIter iter; + gpointer key, value; + gboolean held = FALSE; + + g_hash_table_iter_init (&iter, members); + while (g_hash_table_iter_next (&iter, &key, &value)) + { + if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD) + { + /* This assumes this is a 1-1 call, otherwise one participant + * putting the call on hold wouldn't mean the call is on hold + * for everyone. */ + held = TRUE; + break; + } + } + + if (held) + priv->call_state = HELD; + else if (priv->call_state == HELD) + priv->call_state = CONNECTED; +} + +static void call_handler_notify_call_cb (EmpathyCallHandler *handler, GParamSpec *spec, EmpathyCallWindow *self) @@ -2762,6 +2798,10 @@ call_handler_notify_call_cb (EmpathyCallHandler *handler, tp_g_signal_connect_object (call, "video-stream-error", G_CALLBACK (empathy_call_window_video_stream_error), self, 0); */ + + tp_g_signal_connect_object (call, "members-changed", + G_CALLBACK (empathy_call_window_members_changed_cb), self, 0); + g_object_unref (call); } @@ -2789,14 +2829,7 @@ empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window) g_object_get (priv->handler, "call-channel", &call, NULL); if (call != NULL) { -/* FIXME: part of the improvements for DRAFT2 - tp_g_signal_connect_object (call, "audio-stream-error", - G_CALLBACK (empathy_call_window_audio_stream_error), window, - 0); - tp_g_signal_connect_object (call, "video-stream-error", - G_CALLBACK (empathy_call_window_video_stream_error), window, - 0); -*/ + call_handler_notify_call_cb (priv->handler, NULL, window); g_object_unref (call); } else diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c index b31684069..eced9951c 100644 --- a/src/empathy-chat-manager.c +++ b/src/empathy-chat-manager.c @@ -61,6 +61,7 @@ typedef struct TpAccount *account; gchar *id; gboolean room; + gboolean sms; } ChatData; static ChatData * @@ -73,6 +74,7 @@ chat_data_new (EmpathyChat *chat) data->account = g_object_ref (empathy_chat_get_account (chat)); data->id = g_strdup (empathy_chat_get_id (chat)); data->room = empathy_chat_is_room (chat); + data->sms = empathy_chat_is_sms_channel (chat); return data; } @@ -397,9 +399,14 @@ empathy_chat_manager_undo_closed_chat (EmpathyChatManager *self) if (data->room) empathy_dispatcher_join_muc (data->account, data->id, TP_USER_ACTION_TIME_NOT_USER_ACTION); + else if (data->sms) + empathy_dispatcher_sms_contact_id (data->account, data->id, + TP_USER_ACTION_TIME_NOT_USER_ACTION, + NULL, NULL); else empathy_dispatcher_chat_with_contact_id (data->account, data->id, - TP_USER_ACTION_TIME_NOT_USER_ACTION); + TP_USER_ACTION_TIME_NOT_USER_ACTION, + NULL, NULL); g_signal_emit (self, signals[CHATS_CHANGED], 0, g_queue_get_length (priv->queue)); diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 7dcc996ac..bb23e016a 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1828,7 +1828,9 @@ chat_window_drag_data_received (GtkWidget *widget, if (!chat) { empathy_dispatcher_chat_with_contact_id ( - account, contact_id, gtk_get_current_event_time ()); + account, contact_id, + gtk_get_current_event_time (), + NULL, NULL); g_strfreev (strv); return; @@ -2443,6 +2445,11 @@ empathy_chat_window_present_chat (EmpathyChat *chat, window = empathy_chat_window_get_default (empathy_chat_is_room (chat)); if (!window) { window = empathy_chat_window_new (); + + /* we want to display the newly created window even if we don't present + * it */ + priv = GET_PRIV (window); + gtk_widget_show (priv->dialog); } empathy_chat_window_add_chat (window, chat); diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index e81218f2c..57bd7b67f 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -1201,6 +1201,50 @@ main_window_setup_balance (EmpathyMainWindow *window, } static void +main_window_remove_balance_action (EmpathyMainWindow *window, + TpAccount *account) +{ + EmpathyMainWindowPriv *priv = GET_PRIV (window); + GtkAction *action; + char *name; + GList *a; + + if (priv->balance_action_group == NULL) + return; + + name = main_window_account_to_action_name (account); + + action = gtk_action_group_get_action ( + priv->balance_action_group, name); + + if (action != NULL) { + guint merge_id; + + DEBUG ("Removing action"); + + merge_id = GPOINTER_TO_UINT (g_object_get_data ( + G_OBJECT (action), + "merge-id")); + + gtk_ui_manager_remove_ui (priv->ui_manager, + merge_id); + gtk_action_group_remove_action ( + priv->balance_action_group, action); + } + + g_free (name); + + a = gtk_action_group_list_actions ( + priv->balance_action_group); + + gtk_action_set_visible ( + priv->view_balance_show_in_roster, + g_list_length (a) > 0); + + g_list_free (a); +} + +static void main_window_connection_changed_cb (TpAccount *account, guint old_status, guint current, @@ -1209,8 +1253,6 @@ main_window_connection_changed_cb (TpAccount *account, GHashTable *details, EmpathyMainWindow *window) { - EmpathyMainWindowPriv *priv = GET_PRIV (window); - main_window_update_status (window); if (current == TP_CONNECTION_STATUS_DISCONNECTED && @@ -1223,42 +1265,7 @@ main_window_connection_changed_cb (TpAccount *account, EMPATHY_SOUND_ACCOUNT_DISCONNECTED); /* remove balance action if required */ - if (priv->balance_action_group != NULL) { - GtkAction *action; - char *name; - GList *a; - - name = main_window_account_to_action_name (account); - - action = gtk_action_group_get_action ( - priv->balance_action_group, name); - - if (action != NULL) { - guint merge_id; - - DEBUG ("Removing action"); - - merge_id = GPOINTER_TO_UINT (g_object_get_data ( - G_OBJECT (action), - "merge-id")); - - gtk_ui_manager_remove_ui (priv->ui_manager, - merge_id); - gtk_action_group_remove_action ( - priv->balance_action_group, action); - } - - g_free (name); - - a = gtk_action_group_list_actions ( - priv->balance_action_group); - - gtk_action_set_visible ( - priv->view_balance_show_in_roster, - g_list_length (a) > 0); - - g_list_free (a); - } + main_window_remove_balance_action (window, account); } if (current == TP_CONNECTION_STATUS_CONNECTED) { @@ -2022,6 +2029,9 @@ main_window_account_removed_cb (TpAccountManager *manager, /* remove errors if any */ main_window_remove_error (window, account); + + /* remove the balance action if required */ + main_window_remove_balance_action (window, account); } static void diff --git a/telepathy-yell b/telepathy-yell -Subproject 179a352f0f8a248d54afe0fca93d1a78ccd8d6a +Subproject 301cee6d78085d746647373454c8ac0d2affb89 |