~ubuntu-branches/ubuntu/precise/empathy/precise-proposed-201205180810

« back to all changes in this revision

Viewing changes to libempathy-gtk/empathy-new-message-dialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Brian Curtis, Brian Curtis, Ken VanDine
  • Date: 2011-06-01 10:35:24 UTC
  • mfrom: (1.1.70 upstream) (6.3.44 experimental)
  • Revision ID: james.westby@ubuntu.com-20110601103524-wx3wgp71394730jt
Tags: 3.1.1-1ubuntu1
[ Brian Curtis ]
* Merge with Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Drop geoclue/mapping build-depends (they are in Universe)
  - Add Vcz-Bzr link
  - Add Suggests on telepathy-idle
  - Bump telepathy-butterfly, telepathy-haze to recommends
  - Don't recommend the freedesktop sound theme we have an ubuntu one
  - Add build depend for libunity-dev
* debian/rules:
  - Use autoreconf.mk
  - Disable map and location
* debian/empathy.install:
  - Install message indicator configuration
* debian/indicators/empathy:
  - Message indicator configuration
* debian/patches/01_lpi.patch:
  - Add Launchpad integration
* debian/patches/10_use_notify_osd_icons.patch:
  - Use the notify-osd image for new messages
* debian/patches/34_start_raised_execpt_in_session.patch
  - If not started with the session, we should always raise
* debian/patches/36_chat_window_default_size.patch:
  - Make the default chat window size larger
* debian/patches/37_facebook_default.patch:
  - Make facebook the default chat account type
* debian/patches/38_lp_569289.patch
  - Set freenode as default IRC network for new IRC accounts 
* debian/patches/41_unity_launcher_progress.patch
  - Display file transfer progress in the unity launcher

[ Ken VanDine ]
* debian/control
  - build depend on libgcr-3-dev instead of libgcr-dev
  - dropped build depends for libindicate, we will use telepathy-indicator
  - Depend on dconf-gsettings-backend | gsettings-backend
  - Added a Recommends for telepathy-indicator
* +debian/empathy.gsettings-override
  - Added an override for notifications-focus
* debian/patches/series
  - commented out 23_idomessagedialog_for_voip_and_ft.patch, until ido has 
    been ported to gtk3

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include <libempathy/empathy-tp-contact-factory.h>
32
32
#include <libempathy/empathy-contact-manager.h>
33
 
#include <libempathy/empathy-dispatcher.h>
 
33
#include <libempathy/empathy-request-util.h>
34
34
#include <libempathy/empathy-utils.h>
35
35
 
36
36
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
62
62
 * to be started with any contact on any enabled account.
63
63
 */
64
64
 
 
65
enum
 
66
{
 
67
  EMP_NEW_MESSAGE_TEXT,
 
68
  EMP_NEW_MESSAGE_SMS,
 
69
};
 
70
 
65
71
static void
66
72
empathy_new_message_dialog_response (GtkDialog *dialog, int response_id)
67
73
{
68
74
  TpAccount *account;
69
75
  const gchar *contact_id;
70
76
 
71
 
  if (response_id != GTK_RESPONSE_ACCEPT) goto out;
 
77
  if (response_id < EMP_NEW_MESSAGE_TEXT) goto out;
72
78
 
73
79
  contact_id = empathy_contact_selector_dialog_get_selected (
74
80
      EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), NULL, &account);
75
81
 
76
82
  if (EMP_STR_EMPTY (contact_id) || account == NULL) goto out;
77
83
 
78
 
  empathy_dispatcher_chat_with_contact_id (account, contact_id,
79
 
      gtk_get_current_event_time ());
 
84
  switch (response_id)
 
85
    {
 
86
      case EMP_NEW_MESSAGE_TEXT:
 
87
        empathy_chat_with_contact_id (account, contact_id,
 
88
            gtk_get_current_event_time ());
 
89
        break;
 
90
 
 
91
      case EMP_NEW_MESSAGE_SMS:
 
92
        empathy_sms_contact_id (account, contact_id,
 
93
            gtk_get_current_event_time ());
 
94
        break;
 
95
 
 
96
      default:
 
97
        g_warn_if_reached ();
 
98
    }
80
99
 
81
100
out:
82
101
  gtk_widget_destroy (GTK_WIDGET (dialog));
90
109
  FilterCallbackData *data = user_data;
91
110
  GError *myerr = NULL;
92
111
  TpCapabilities *caps;
93
 
  GPtrArray *classes;
94
 
  guint i;
95
112
 
96
113
  if (!tp_proxy_prepare_finish (conn, result, &myerr))
97
 
      goto out;
 
114
    {
 
115
      data->callback (FALSE, data->user_data);
 
116
      g_slice_free (FilterCallbackData, data);
 
117
    }
98
118
 
99
119
  caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
100
 
  classes = tp_capabilities_get_channel_classes (caps);
101
 
 
102
 
  for (i = 0; i < classes->len; i++)
103
 
    {
104
 
      GHashTable *fixed;
105
 
      GStrv allowed;
106
 
      const gchar *chan_type;
107
 
 
108
 
      tp_value_array_unpack (g_ptr_array_index (classes, i), 2,
109
 
          &fixed, &allowed);
110
 
 
111
 
      chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
112
 
 
113
 
      if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
114
 
        continue;
115
 
 
116
 
      if (tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL) !=
117
 
          TP_HANDLE_TYPE_CONTACT)
118
 
        continue;
119
 
 
120
 
      data->callback (TRUE, data->user_data);
121
 
      g_slice_free (FilterCallbackData, data);
122
 
      return;
123
 
    }
124
 
 
125
 
out:
126
 
  data->callback (FALSE, data->user_data);
 
120
  data->callback (tp_capabilities_supports_text_chats (caps),
 
121
      data->user_data);
 
122
 
127
123
  g_slice_free (FilterCallbackData, data);
128
124
}
129
125
 
158
154
  tp_proxy_prepare_async (connection, features, conn_prepared_cb, cb_data);
159
155
}
160
156
 
 
157
static void
 
158
empathy_new_message_dialog_update_sms_button_sensitivity (GtkWidget *widget,
 
159
    GParamSpec *pspec,
 
160
    GtkWidget *button)
 
161
{
 
162
  GtkWidget *self = gtk_widget_get_toplevel (widget);
 
163
  EmpathyContactSelectorDialog *dialog;
 
164
  TpConnection *conn;
 
165
  GPtrArray *rccs;
 
166
  gboolean sensitive = FALSE;
 
167
  guint i;
 
168
 
 
169
  g_return_if_fail (EMPATHY_IS_NEW_MESSAGE_DIALOG (self));
 
170
 
 
171
  dialog = EMPATHY_CONTACT_SELECTOR_DIALOG (self);
 
172
 
 
173
  /* if the Text widget isn't sensitive, don't bother checking the caps */
 
174
  if (!gtk_widget_get_sensitive (dialog->button_action))
 
175
    goto finally;
 
176
 
 
177
  empathy_contact_selector_dialog_get_selected (dialog, &conn, NULL);
 
178
 
 
179
  if (conn == NULL)
 
180
    goto finally;
 
181
 
 
182
  /* iterate the rccs to find if SMS channels are supported, this should
 
183
   * be in tp-glib */
 
184
  rccs = tp_capabilities_get_channel_classes (
 
185
      tp_connection_get_capabilities (conn));
 
186
 
 
187
  for (i = 0; i < rccs->len; i++)
 
188
    {
 
189
      GHashTable *fixed;
 
190
      GStrv allowed;
 
191
      const char *type;
 
192
      gboolean sms_channel;
 
193
 
 
194
      tp_value_array_unpack (g_ptr_array_index (rccs, i), 2,
 
195
          &fixed,
 
196
          &allowed);
 
197
 
 
198
      /* SMS channels are type:Text and sms-channel:True */
 
199
      type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
 
200
      sms_channel = tp_asv_get_boolean (fixed,
 
201
          TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, NULL);
 
202
 
 
203
      sensitive = sms_channel &&
 
204
        !tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_TEXT);
 
205
 
 
206
      if (sensitive)
 
207
        break;
 
208
    }
 
209
 
 
210
finally:
 
211
  gtk_widget_set_sensitive (button, sensitive);
 
212
}
 
213
 
161
214
static GObject *
162
215
empathy_new_message_dialog_constructor (GType type,
163
216
    guint n_props,
188
241
{
189
242
  EmpathyContactSelectorDialog *parent = EMPATHY_CONTACT_SELECTOR_DIALOG (
190
243
        dialog);
 
244
  GtkWidget *button;
191
245
  GtkWidget *image;
192
246
 
 
247
  /* add an SMS button */
 
248
  button = gtk_button_new_with_mnemonic (_("_SMS"));
 
249
  image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_SMS,
 
250
      GTK_ICON_SIZE_BUTTON);
 
251
  gtk_button_set_image (GTK_BUTTON (button), image);
 
252
 
 
253
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
 
254
      EMP_NEW_MESSAGE_SMS);
 
255
  gtk_widget_show (button);
 
256
 
193
257
  /* add chat button */
194
258
  parent->button_action = gtk_button_new_with_mnemonic (_("C_hat"));
195
259
  image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_NEW_MESSAGE,
197
261
  gtk_button_set_image (GTK_BUTTON (parent->button_action), image);
198
262
 
199
263
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), parent->button_action,
200
 
      GTK_RESPONSE_ACCEPT);
 
264
      EMP_NEW_MESSAGE_TEXT);
201
265
  gtk_widget_show (parent->button_action);
202
266
 
 
267
  /* the parent class will update the sensitivity of button_action, propagate
 
268
   * it */
 
269
  g_signal_connect (parent->button_action, "notify::sensitive",
 
270
      G_CALLBACK (empathy_new_message_dialog_update_sms_button_sensitivity),
 
271
      button);
 
272
  g_signal_connect (dialog, "notify::selected-account",
 
273
      G_CALLBACK (empathy_new_message_dialog_update_sms_button_sensitivity),
 
274
      button);
 
275
 
203
276
  /* Tweak the dialog */
204
277
  gtk_window_set_title (GTK_WINDOW (dialog), _("New Conversation"));
205
278
  gtk_window_set_role (GTK_WINDOW (dialog), "new_message");