]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-observer.c
EmpathySmileyManager: use the proper Unicode characters
[empathy.git] / src / empathy-call-observer.c
index 2019cd02f60433cc3df53bc9db78d00f3b4ba8f4..82887b00978b206ae926e6edf5784771094067e2 100644 (file)
  * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
  */
 
-#include <config.h>
+#include "config.h"
+#include "empathy-call-observer.h"
 
 #include <glib/gi18n-lib.h>
+#include <tp-account-widgets/tpaw-images.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
 
-#include <telepathy-glib/telepathy-glib.h>
-
-#include <libnotify/notification.h>
-
-#include <libempathy/empathy-utils.h>
-
-#include <libempathy-gtk/empathy-images.h>
-#include <libempathy-gtk/empathy-notify-manager.h>
-
-#include <extensions/extensions.h>
-
-#include "empathy-call-observer.h"
+#include "empathy-notify-manager.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 struct _EmpathyCallObserverPriv {
   EmpathyNotifyManager *notify_mgr;
@@ -102,29 +94,16 @@ auto_reject_ctx_free (AutoRejectCtx *ctx)
 }
 
 static void
-get_contact_cb (TpConnection *connection,
-    guint n_contacts,
-    TpContact * const *contacts,
-    guint n_failed,
-    const TpHandle *failed,
-    const GError *error,
-    gpointer user_data,
-    GObject *weak_object)
+display_reject_notification (EmpathyCallObserver *self,
+    TpChannel *channel)
 {
-  EmpathyCallObserver *self = (EmpathyCallObserver *) weak_object;
-  NotifyNotification *notification;
   TpContact *contact;
+  NotifyNotification *notification;
   gchar *summary, *body;
   EmpathyContact *emp_contact;
   GdkPixbuf *pixbuf;
 
-  if (n_contacts != 1)
-    {
-      DEBUG ("Failed to get TpContact; ignoring notification bubble");
-      return;
-    }
-
-  contact = contacts[0];
+  contact = tp_channel_get_target_contact (channel);
 
   summary = g_strdup_printf (_("Missed call from %s"),
       tp_contact_get_alias (contact));
@@ -132,11 +111,12 @@ get_contact_cb (TpConnection *connection,
       _("%s just tried to call you, but you were in another call."),
       tp_contact_get_alias (contact));
 
-  notification = notify_notification_new (summary, body, NULL);
+  notification = empathy_notify_manager_create_notification (summary, body,
+      NULL);
 
   emp_contact = empathy_contact_dup_from_tp_contact (contact);
   pixbuf = empathy_notify_manager_get_pixbuf_for_notification (
-      self->priv->notify_mgr, emp_contact, EMPATHY_IMAGE_AVATAR_DEFAULT);
+      self->priv->notify_mgr, emp_contact, TPAW_IMAGE_AVATAR_DEFAULT);
 
   if (pixbuf != NULL)
     {
@@ -152,21 +132,6 @@ get_contact_cb (TpConnection *connection,
   g_object_unref (emp_contact);
 }
 
-static void
-display_reject_notification (EmpathyCallObserver *self,
-    TpChannel *channel)
-{
-  TpHandle handle;
-  TpContactFeature features[] = { TP_CONTACT_FEATURE_ALIAS,
-      TP_CONTACT_FEATURE_AVATAR_DATA };
-
-  handle = tp_channel_get_handle (channel, NULL);
-
-  tp_connection_get_contacts_by_handle (tp_channel_borrow_connection (channel),
-      1, &handle, G_N_ELEMENTS (features), features, get_contact_cb,
-      g_object_ref (channel), g_object_unref, G_OBJECT (self));
-}
-
 static TpChannel *
 find_main_channel (GList *channels)
 {
@@ -182,8 +147,7 @@ find_main_channel (GList *channels)
 
       channel_type = tp_channel_get_channel_type_id (channel);
 
-      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA ||
-          channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_CALL)
+      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_CALL)
         return channel;
     }
 
@@ -252,10 +216,10 @@ observe_channels (TpSimpleObserver *observer,
   channel = find_main_channel (channels);
   if (channel == NULL)
     {
-      GError err = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+      GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
           "Unknown channel type" };
 
-      DEBUG ("Didn't find any Call or StreamedMedia channel; ignoring");
+      DEBUG ("Didn't find any Call channel; ignoring");
 
       tp_observe_channels_context_fail (context, &err);
       return;
@@ -359,14 +323,7 @@ empathy_call_observer_init (EmpathyCallObserver *self)
       "Empathy.CallObserver", FALSE,
       observe_channels, self, NULL);
 
-  /* Observe Call and StreamedMedia channels */
-  tp_base_client_take_observer_filter (self->priv->observer,
-      tp_asv_new (
-        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
-          TP_HANDLE_TYPE_CONTACT,
-        NULL));
+  /* Observe Call channels */
   tp_base_client_take_observer_filter (self->priv->observer,
       tp_asv_new (
         TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,