~ubuntu-branches/ubuntu/natty/empathy/natty-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2011-02-24 11:54:47 UTC
  • mfrom: (1.1.66 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224115447-meoue6yzk3u6s2br
Tags: 2.33.2-0ubuntu1
* New upstream release
* -debian/patches/reword_subscription_dailog_to_be_less_technical.patch
  - merged upstream
* debian/control
  - Bumped build depends for tp-logger, tp-glib, folks and libunity-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <telepathy-glib/interfaces.h>
30
30
#include <telepathy-glib/simple-approver.h>
31
31
 
 
32
#include <telepathy-yell/telepathy-yell.h>
 
33
 
32
34
#include <libempathy/empathy-idle.h>
 
35
 
 
36
#include <libempathy/empathy-channel-factory.h>
33
37
#include <libempathy/empathy-tp-contact-factory.h>
34
38
#include <libempathy/empathy-contact-manager.h>
35
39
#include <libempathy/empathy-tp-chat.h>
36
 
#include <libempathy/empathy-tp-call.h>
 
40
#include <libempathy/empathy-tp-streamed-media.h>
37
41
#include <libempathy/empathy-tp-file.h>
38
42
#include <libempathy/empathy-utils.h>
39
 
#include <libempathy/empathy-call-factory.h>
40
43
#include <libempathy/empathy-gsettings.h>
41
44
 
42
45
#include <extensions/extensions.h>
400
403
      goto out;
401
404
    }
402
405
 
403
 
  if (EMPATHY_IS_TP_CALL (user_data))
404
 
    {
405
 
      empathy_tp_call_close (user_data);
 
406
  if (EMPATHY_IS_TP_STREAMED_MEDIA (user_data))
 
407
    {
 
408
      empathy_tp_streamed_media_close (user_data);
 
409
    }
 
410
  else if (TPY_IS_CALL_CHANNEL (user_data))
 
411
    {
 
412
      tpy_call_channel_hangup_async (user_data,
 
413
          TPY_CALL_STATE_CHANGE_REASON_USER_REQUESTED,
 
414
          "", "", NULL, NULL);
 
415
      tp_channel_close_async (user_data, NULL, NULL);
406
416
    }
407
417
  else if (EMPATHY_IS_TP_CHAT (user_data))
408
418
    {
485
495
  GtkWidget *dialog;
486
496
  GtkWidget *button;
487
497
  GtkWidget *image;
488
 
  EmpathyTpCall *call;
489
498
  gboolean video;
490
499
  gchar *title;
491
500
 
495
504
      return;
496
505
    }
497
506
 
498
 
  call = EMPATHY_TP_CALL (event->approval->handler_instance);
499
 
 
500
 
  video = empathy_tp_call_has_initial_video (call);
 
507
  if (event->public.type == EMPATHY_EVENT_TYPE_VOIP)
 
508
    {
 
509
      EmpathyTpStreamedMedia *call;
 
510
      call = EMPATHY_TP_STREAMED_MEDIA (event->approval->handler_instance);
 
511
      video = empathy_tp_streamed_media_has_initial_video (call);
 
512
    }
 
513
  else if (event->public.type == EMPATHY_EVENT_TYPE_CALL)
 
514
    {
 
515
      TpyCallChannel *call;
 
516
      call = TPY_CALL_CHANNEL (event->approval->handler_instance);
 
517
      g_object_get (G_OBJECT (call), "initial-video", &video, NULL);
 
518
    }
 
519
  else
 
520
    {
 
521
      g_warning ("Unknown event type: %d", event->public.type);
 
522
      return;
 
523
    }
501
524
 
502
525
  dialog = gtk_message_dialog_new (NULL, 0,
503
526
      GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
601
624
 
602
625
      channel_type = tp_channel_get_channel_type_id (approval->main_channel);
603
626
 
604
 
      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
 
627
      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA ||
 
628
          channel_type == TPY_IFACE_QUARK_CHANNEL_TYPE_CALL)
605
629
        {
606
630
          priv->ringing--;
607
631
          if (priv->ringing == 0)
638
662
}
639
663
 
640
664
static void
 
665
event_manager_call_channel_got_contact_cb (TpConnection *connection,
 
666
                                 EmpathyContact *contact,
 
667
                                 const GError *error,
 
668
                                 gpointer user_data,
 
669
                                 GObject *object)
 
670
{
 
671
  EventManagerApproval *approval = (EventManagerApproval *) user_data;
 
672
  EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
 
673
  GtkWidget *window;
 
674
  TpyCallChannel *call;
 
675
  gchar *header;
 
676
  gboolean video;
 
677
 
 
678
  if (error != NULL)
 
679
    {
 
680
      DEBUG ("Can't get the contact for the call.. Rejecting?");
 
681
      reject_approval (approval);
 
682
      return;
 
683
    }
 
684
 
 
685
  window = empathy_main_window_dup ();
 
686
  approval->contact = g_object_ref (contact);
 
687
 
 
688
  call = TPY_CALL_CHANNEL (approval->handler_instance);
 
689
 
 
690
  g_object_get (G_OBJECT (call), "initial-video", &video, NULL);
 
691
 
 
692
  header = g_strdup_printf (
 
693
    video ? _("Incoming video call from %s") :_("Incoming call from %s"),
 
694
    empathy_contact_get_alias (approval->contact));
 
695
 
 
696
  event_manager_add (approval->manager, NULL,
 
697
      approval->contact, EMPATHY_EVENT_TYPE_CALL,
 
698
      video ? EMPATHY_IMAGE_VIDEO_CALL : EMPATHY_IMAGE_VOIP,
 
699
      header, NULL, approval,
 
700
      event_channel_process_voip_func, NULL);
 
701
 
 
702
  g_free (header);
 
703
 
 
704
  priv->ringing++;
 
705
  if (priv->ringing == 1)
 
706
    empathy_sound_start_playing (window,
 
707
        EMPATHY_SOUND_PHONE_INCOMING, MS_BETWEEN_RING);
 
708
 
 
709
  g_object_unref (window);
 
710
}
 
711
 
 
712
static void
641
713
event_manager_media_channel_got_contact (EventManagerApproval *approval)
642
714
{
643
715
  EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager);
644
716
  GtkWidget *window = empathy_main_window_dup ();
645
717
  gchar *header;
646
 
  EmpathyTpCall *call;
 
718
  EmpathyTpStreamedMedia *call;
647
719
  gboolean video;
648
720
 
649
 
  call = EMPATHY_TP_CALL (approval->handler_instance);
 
721
  call = EMPATHY_TP_STREAMED_MEDIA (approval->handler_instance);
650
722
 
651
 
  video = empathy_tp_call_has_initial_video (call);
 
723
  video = empathy_tp_streamed_media_has_initial_video (call);
652
724
 
653
725
  header = g_strdup_printf (
654
726
    video ? _("Incoming video call from %s") :_("Incoming call from %s"),
671
743
}
672
744
 
673
745
static void
674
 
event_manager_media_channel_contact_changed_cb (EmpathyTpCall *call,
 
746
event_manager_media_channel_contact_changed_cb (EmpathyTpStreamedMedia *call,
675
747
  GParamSpec *param, EventManagerApproval *approval)
676
748
{
677
749
  EmpathyContact *contact;
871
943
      channel_type = tp_channel_get_channel_type_id (channel);
872
944
 
873
945
      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA ||
 
946
          channel_type == TPY_IFACE_QUARK_CHANNEL_TYPE_CALL ||
874
947
          channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER ||
875
948
          channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION)
876
949
        return channel;
964
1037
  else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
965
1038
    {
966
1039
      EmpathyContact *contact;
967
 
      EmpathyTpCall *call = empathy_tp_call_new (account, channel);
 
1040
      EmpathyTpStreamedMedia *call = empathy_tp_streamed_media_new (account,
 
1041
        channel);
968
1042
 
969
1043
      approval->handler_instance = G_OBJECT (call);
970
1044
 
983
1057
        }
984
1058
 
985
1059
    }
 
1060
  else if (channel_type == TPY_IFACE_QUARK_CHANNEL_TYPE_CALL)
 
1061
    {
 
1062
      TpyCallChannel *call = TPY_CALL_CHANNEL (channel);
 
1063
      const gchar *id;
 
1064
 
 
1065
      approval->handler_instance = g_object_ref (call);
 
1066
 
 
1067
      id = tp_channel_get_identifier (channel);
 
1068
 
 
1069
      empathy_tp_contact_factory_get_from_id (connection, id,
 
1070
        event_manager_call_channel_got_contact_cb,
 
1071
        approval, NULL, G_OBJECT (self));
 
1072
    }
986
1073
  else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
987
1074
    {
988
1075
      TpHandle handle;
992
1079
 
993
1080
      handle = tp_channel_get_handle (channel, NULL);
994
1081
 
995
 
      connection = tp_channel_borrow_connection (channel);
996
1082
      empathy_tp_contact_factory_get_from_handle (connection, handle,
997
1083
        event_manager_ft_got_contact_cb, approval, NULL, G_OBJECT (self));
998
1084
    }
1054
1140
      return;
1055
1141
    }
1056
1142
 
1057
 
  header = g_strdup_printf (_("%s would like permission to see when you are available"),
1058
 
    empathy_contact_get_alias (contact));
 
1143
  header = g_strdup_printf (
 
1144
      _("%s would like permission to see when you are online"),
 
1145
      empathy_contact_get_alias (contact));
1059
1146
 
1060
1147
  if (!EMP_STR_EMPTY (message))
1061
1148
    event_msg = g_strdup_printf (_("\nMessage: %s"), message);
1238
1325
  EmpathyEventManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
1239
1326
    EMPATHY_TYPE_EVENT_MANAGER, EmpathyEventManagerPriv);
1240
1327
  TpDBusDaemon *dbus;
 
1328
  EmpathyChannelFactory *factory;
1241
1329
  GError *error = NULL;
1242
1330
 
1243
1331
  manager->priv = priv;
1260
1348
  priv->approver = tp_simple_approver_new (dbus, "Empathy.EventManager", FALSE,
1261
1349
      approve_channels, manager, NULL);
1262
1350
 
 
1351
  factory = empathy_channel_factory_new ();
 
1352
  tp_base_client_set_channel_factory (priv->approver,
 
1353
      TP_CLIENT_CHANNEL_FACTORY (factory));
 
1354
  g_object_unref (factory);
 
1355
 
1263
1356
  /* Private text channels */
1264
1357
  tp_base_client_take_approver_filter (priv->approver,
1265
1358
      tp_asv_new (
1289
1382
          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
1290
1383
        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
1291
1384
        NULL));
 
1385
  tp_base_client_take_approver_filter (priv->approver,
 
1386
      tp_asv_new (
 
1387
        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
 
1388
          TPY_IFACE_CHANNEL_TYPE_CALL,
 
1389
        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
 
1390
        NULL));
1292
1391
 
1293
1392
  /* I don't feel good about doing this, and I'm sorry, but the
1294
1393
   * capabilities connection feature is added earlier because it's