~bcurtiswx/ubuntu/precise/empathy/3.4.2.3-0ubuntu1

« back to all changes in this revision

Viewing changes to .pc/23_idomessagedialog_for_voip_and_ft.patch/src/empathy-event-manager.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2011-12-21 15:12:56 UTC
  • mfrom: (1.1.84)
  • Revision ID: package-import@ubuntu.com-20111221151256-9b1pny75wphfmqd6
Tags: 3.3.3-0ubuntu1
* New upstream version
  - Require folks >= 0.6.6 (LP: #907501)
* debian/control
  - bump build depends for folks to >= 0.6.6
* debian/watch
  - use the .xz file

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include <libempathy/empathy-presence-manager.h>
35
35
#include <libempathy/empathy-tp-contact-factory.h>
36
 
#include <libempathy/empathy-contact-manager.h>
 
36
#include <libempathy/empathy-connection-aggregator.h>
37
37
#include <libempathy/empathy-tp-chat.h>
38
38
#include <libempathy/empathy-tp-streamed-media.h>
39
 
#include <libempathy/empathy-tp-file.h>
40
39
#include <libempathy/empathy-utils.h>
41
40
#include <libempathy/empathy-gsettings.h>
42
41
 
81
80
typedef struct {
82
81
  TpBaseClient *approver;
83
82
  TpBaseClient *auth_approver;
84
 
  EmpathyContactManager *contact_manager;
 
83
  EmpathyConnectionAggregator *conn_aggregator;
85
84
  GSList *events;
86
85
  /* Ongoing approvals */
87
86
  GSList *approvals;
92
91
  GSettings *gsettings_ui;
93
92
 
94
93
  EmpathySoundManager *sound_mgr;
 
94
 
 
95
  /* TpContact -> EmpathyContact */
 
96
  GHashTable *contacts;
95
97
} EmpathyEventManagerPriv;
96
98
 
97
99
typedef struct _EventPriv EventPriv;
422
424
    {
423
425
      empathy_tp_chat_leave (user_data, "");
424
426
    }
425
 
  else if (EMPATHY_IS_TP_FILE (user_data))
 
427
  else if (TP_IS_FILE_TRANSFER_CHANNEL (user_data))
426
428
    {
427
 
      empathy_tp_file_close (user_data);
 
429
      tp_channel_close_async (user_data, NULL, NULL);
428
430
    }
429
431
 
430
432
out:
1115
1117
        event_manager_call_channel_got_contact_cb,
1116
1118
        approval, NULL, G_OBJECT (self));
1117
1119
    }
1118
 
  else if (EMPATHY_IS_TP_FILE (channel))
 
1120
  else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
1119
1121
    {
1120
1122
      TpHandle handle;
1121
1123
 
1179
1181
}
1180
1182
 
1181
1183
static void
1182
 
event_manager_pendings_changed_cb (EmpathyContactList  *list,
1183
 
  EmpathyContact *contact, EmpathyContact *actor,
1184
 
  guint reason, gchar *message, gboolean is_pending,
1185
 
  EmpathyEventManager *manager)
 
1184
check_publish_state (EmpathyEventManager *self,
 
1185
    TpContact *tp_contact)
1186
1186
{
1187
 
  EmpathyEventManagerPriv *priv = GET_PRIV (manager);
1188
 
  gchar                   *header, *event_msg;
1189
 
 
1190
 
  if (!is_pending)
 
1187
  EmpathyEventManagerPriv *priv = GET_PRIV (self);
 
1188
  gchar *header, *event_msg;
 
1189
  TpSubscriptionState state;
 
1190
  EmpathyContact *contact;
 
1191
  const gchar *message;
 
1192
 
 
1193
  state = tp_contact_get_publish_state (tp_contact);
 
1194
 
 
1195
  contact = empathy_contact_dup_from_tp_contact (tp_contact);
 
1196
 
 
1197
  if (state != TP_SUBSCRIPTION_STATE_ASK)
1191
1198
    {
1192
1199
      GSList *l;
1193
1200
 
1203
1210
            }
1204
1211
        }
1205
1212
 
1206
 
      return;
 
1213
      goto out;
1207
1214
    }
1208
1215
 
1209
1216
  header = g_strdup_printf (
1210
1217
      _("%s would like permission to see when you are online"),
1211
1218
      empathy_contact_get_alias (contact));
1212
1219
 
 
1220
  message = tp_contact_get_publish_request (tp_contact);
 
1221
 
1213
1222
  if (!EMP_STR_EMPTY (message))
1214
1223
    event_msg = g_strdup_printf (_("\nMessage: %s"), message);
1215
1224
  else
1216
1225
    event_msg = NULL;
1217
1226
 
1218
 
  event_manager_add (manager, NULL, contact, EMPATHY_EVENT_TYPE_SUBSCRIPTION,
 
1227
  event_manager_add (self, NULL, contact, EMPATHY_EVENT_TYPE_SUBSCRIPTION,
1219
1228
      GTK_STOCK_DIALOG_QUESTION, header, event_msg, NULL,
1220
1229
      event_pending_subscribe_func, NULL);
1221
1230
 
1222
1231
  g_free (event_msg);
1223
1232
  g_free (header);
 
1233
 
 
1234
out:
 
1235
  g_object_unref (contact);
 
1236
}
 
1237
 
 
1238
static void
 
1239
event_manager_publish_state_changed_cb (TpContact *contact,
 
1240
    GParamSpec *spec,
 
1241
    EmpathyEventManager *self)
 
1242
{
 
1243
  check_publish_state (self, contact);
1224
1244
}
1225
1245
 
1226
1246
static void
1289
1309
  g_object_unref (window);
1290
1310
}
1291
1311
 
1292
 
static void
1293
 
event_manager_members_changed_cb (EmpathyContactList  *list,
1294
 
    EmpathyContact *contact,
1295
 
    EmpathyContact *actor,
1296
 
    guint reason,
1297
 
    gchar *message,
1298
 
    gboolean is_member,
1299
 
    EmpathyEventManager *manager)
1300
 
{
1301
 
  if (is_member)
1302
 
    g_signal_connect (contact, "presence-changed",
1303
 
        G_CALLBACK (event_manager_presence_changed_cb), manager);
1304
 
  else
1305
 
    g_signal_handlers_disconnect_by_func (contact,
1306
 
        event_manager_presence_changed_cb, manager);
1307
 
}
1308
 
 
1309
1312
static GObject *
1310
1313
event_manager_constructor (GType type,
1311
1314
                           guint n_props,
1338
1341
  g_slist_free (priv->events);
1339
1342
  g_slist_foreach (priv->approvals, (GFunc) event_manager_approval_free, NULL);
1340
1343
  g_slist_free (priv->approvals);
1341
 
  g_object_unref (priv->contact_manager);
 
1344
  g_object_unref (priv->conn_aggregator);
1342
1345
  g_object_unref (priv->approver);
1343
1346
  g_object_unref (priv->auth_approver);
1344
1347
  g_object_unref (priv->gsettings_notif);
1345
1348
  g_object_unref (priv->gsettings_ui);
1346
1349
  g_object_unref (priv->sound_mgr);
 
1350
  g_hash_table_unref (priv->contacts);
1347
1351
}
1348
1352
 
1349
1353
static void
1386
1390
}
1387
1391
 
1388
1392
static void
 
1393
contact_list_changed_cb (EmpathyConnectionAggregator *aggregator,
 
1394
    GPtrArray *added,
 
1395
    GPtrArray *removed,
 
1396
    EmpathyEventManager *self)
 
1397
{
 
1398
  EmpathyEventManagerPriv *priv = GET_PRIV (self);
 
1399
  guint i;
 
1400
 
 
1401
  for (i = 0; i < added->len; i++)
 
1402
    {
 
1403
      TpContact *tp_contact = g_ptr_array_index (added, i);
 
1404
      EmpathyContact *contact;
 
1405
 
 
1406
      if (g_hash_table_lookup (priv->contacts, tp_contact) != NULL)
 
1407
        continue;
 
1408
 
 
1409
      contact = empathy_contact_dup_from_tp_contact (tp_contact);
 
1410
 
 
1411
      tp_g_signal_connect_object (contact, "presence-changed",
 
1412
          G_CALLBACK (event_manager_presence_changed_cb), self, 0);
 
1413
 
 
1414
      tp_g_signal_connect_object (tp_contact, "notify::publish-state",
 
1415
          G_CALLBACK (event_manager_publish_state_changed_cb), self, 0);
 
1416
 
 
1417
      check_publish_state (self, tp_contact);
 
1418
 
 
1419
      /* Pass ownership to the hash table */
 
1420
      g_hash_table_insert (priv->contacts, g_object_ref (tp_contact), contact);
 
1421
    }
 
1422
 
 
1423
  for (i = 0; i < removed->len; i++)
 
1424
    {
 
1425
      TpContact *tp_contact = g_ptr_array_index (removed, i);
 
1426
      EmpathyContact *contact;
 
1427
 
 
1428
      contact = g_hash_table_lookup (priv->contacts, tp_contact);
 
1429
      if (contact == NULL)
 
1430
        continue;
 
1431
 
 
1432
      g_signal_handlers_disconnect_by_func (contact,
 
1433
          event_manager_presence_changed_cb, self);
 
1434
 
 
1435
      g_signal_handlers_disconnect_by_func (tp_contact,
 
1436
          event_manager_publish_state_changed_cb, self);
 
1437
 
 
1438
      g_hash_table_remove (priv->contacts, tp_contact);
 
1439
    }
 
1440
}
 
1441
 
 
1442
static void
1389
1443
empathy_event_manager_init (EmpathyEventManager *manager)
1390
1444
{
1391
1445
  EmpathyEventManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
1392
1446
    EMPATHY_TYPE_EVENT_MANAGER, EmpathyEventManagerPriv);
1393
1447
  GError *error = NULL;
1394
1448
  TpAccountManager *am;
 
1449
  GPtrArray *contacts, *empty;
1395
1450
 
1396
1451
  manager->priv = priv;
1397
1452
 
1400
1455
 
1401
1456
  priv->sound_mgr = empathy_sound_manager_dup_singleton ();
1402
1457
 
1403
 
  priv->contact_manager = empathy_contact_manager_dup_singleton ();
1404
 
  g_signal_connect (priv->contact_manager, "pendings-changed",
1405
 
    G_CALLBACK (event_manager_pendings_changed_cb), manager);
1406
 
 
1407
 
  g_signal_connect (priv->contact_manager, "members-changed",
1408
 
    G_CALLBACK (event_manager_members_changed_cb), manager);
 
1458
  priv->contacts = g_hash_table_new_full (NULL, NULL, g_object_unref,
 
1459
      g_object_unref);
 
1460
 
 
1461
  priv->conn_aggregator = empathy_connection_aggregator_dup_singleton ();
 
1462
 
 
1463
  tp_g_signal_connect_object (priv->conn_aggregator, "contact-list-changed",
 
1464
      G_CALLBACK (contact_list_changed_cb), manager, 0);
 
1465
 
 
1466
  contacts = empathy_connection_aggregator_dup_all_contacts (
 
1467
      priv->conn_aggregator);
 
1468
 
 
1469
  empty = g_ptr_array_new ();
 
1470
 
 
1471
  contact_list_changed_cb (priv->conn_aggregator, contacts, empty, manager);
 
1472
 
 
1473
  g_ptr_array_unref (contacts);
 
1474
  g_ptr_array_unref (empty);
1409
1475
 
1410
1476
   am = tp_account_manager_dup ();
1411
1477