]> git.0d.be Git - empathy.git/blobdiff - src/empathy-notifications-approver.c
Merge branch 'change-audio'
[empathy.git] / src / empathy-notifications-approver.c
index 8939ecb1d310d7e9b65c3cdcbfc778210a99b441..aa46308493d4526d0da5f4f3d3e066c159624023 100644 (file)
 #include <libnotify/notify.h>
 #include <telepathy-glib/telepathy-glib.h>
 
+#include <telepathy-yell/telepathy-yell.h>
+
 #include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-tp-streamed-media.h>
 
 #include <libempathy-gtk/empathy-notify-manager.h>
 
@@ -118,6 +121,20 @@ notification_close_helper (EmpathyNotificationsApprover *self)
     }
 }
 
+static void
+notification_approve_no_video_cb (NotifyNotification *notification,
+    gchar *action,
+    EmpathyNotificationsApprover *self)
+{
+  if (self->priv->event)
+    {
+      tpy_call_channel_send_video (
+          TPY_CALL_CHANNEL (self->priv->event->handler_instance),
+          FALSE);
+      empathy_event_approve (self->priv->event);
+    }
+}
+
 static void
 notification_approve_cb (NotifyNotification *notification,
     gchar *action,
@@ -178,6 +195,8 @@ static void
 add_notification_actions (EmpathyNotificationsApprover *self,
     NotifyNotification *notification)
 {
+  gboolean video;
+
   switch (self->priv->event->type) {
     case EMPATHY_EVENT_TYPE_CHAT:
       notify_notification_add_action (notification,
@@ -187,12 +206,26 @@ add_notification_actions (EmpathyNotificationsApprover *self,
 
     case EMPATHY_EVENT_TYPE_VOIP:
     case EMPATHY_EVENT_TYPE_CALL:
+      if (self->priv->event->type == EMPATHY_EVENT_TYPE_VOIP)
+        video = empathy_tp_streamed_media_has_initial_video (
+            EMPATHY_TP_STREAMED_MEDIA (self->priv->event->handler_instance));
+      else
+        video = tpy_call_channel_has_initial_video (
+            TPY_CALL_CHANNEL (self->priv->event->handler_instance));
+
       notify_notification_add_action (notification,
         "reject", _("Reject"), (NotifyActionCallback) notification_decline_cb,
           self, NULL);
 
+      if (video && self->priv->event->type == EMPATHY_EVENT_TYPE_CALL)
+          notify_notification_add_action (notification,
+          "answer-no-video", _("Answer"),
+          (NotifyActionCallback) notification_approve_no_video_cb,
+          self, NULL);
+
       notify_notification_add_action (notification,
-        "answer", _("Answer"), (NotifyActionCallback) notification_approve_cb,
+          "answer", video ? _("Answer with video") : _("Answer"),
+          (NotifyActionCallback) notification_approve_cb,
           self, NULL);
       break;
 
@@ -257,6 +290,8 @@ notification_is_urgent (EmpathyNotificationsApprover *self,
   return FALSE;
 }
 
+/* Use x-empathy as prefix for unofficial categories
+ * http://www.galago-project.org/specs/notification/0.9/x211.html */
 static const gchar *
 get_category_for_event_type (EmpathyEventType type)
 {
@@ -269,11 +304,15 @@ get_category_for_event_type (EmpathyEventType type)
       return "presence.offline";
     case EMPATHY_EVENT_TYPE_VOIP:
     case EMPATHY_EVENT_TYPE_CALL:
+      return "x-empathy.call.incoming";
     case EMPATHY_EVENT_TYPE_TRANSFER:
+      return "x-empathy.transfer.incoming";
     case EMPATHY_EVENT_TYPE_INVITATION:
+      return "x-empathy.im.room-invitation";
     case EMPATHY_EVENT_TYPE_AUTH:
+      return "x-empathy.network.auth-request";
     case EMPATHY_EVENT_TYPE_SUBSCRIPTION:
-      return NULL;
+      return "x-empathy.im.subscription-request";
   }
 
   return NULL;
@@ -341,9 +380,11 @@ update_notification (EmpathyNotificationsApprover *self)
           NOTIFY_EXPIRES_DEFAULT);
 
       if (has_x_canonical_append)
-        /* We have to set a not empty string to keep libnotify happy */
-        notify_notification_set_hint_string (notification,
-            EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND, "1");
+        {
+          notify_notification_set_hint (notification,
+              EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND,
+              g_variant_new_boolean (TRUE));
+        }
 
       if (empathy_notify_manager_has_capability (self->priv->notify_mgr,
             EMPATHY_NOTIFY_MANAGER_CAP_ACTIONS))
@@ -354,8 +395,11 @@ update_notification (EmpathyNotificationsApprover *self)
 
       category = get_category_for_event_type (self->priv->event->type);
       if (category != NULL)
-        notify_notification_set_hint_string (notification,
-            EMPATHY_NOTIFY_MANAGER_CAP_CATEGORY, category);
+        {
+          notify_notification_set_hint (notification,
+              EMPATHY_NOTIFY_MANAGER_CAP_CATEGORY,
+              g_variant_new_string (category));
+        }
     }
 
   pixbuf = empathy_notify_manager_get_pixbuf_for_notification (
@@ -364,7 +408,7 @@ update_notification (EmpathyNotificationsApprover *self)
 
   if (pixbuf != NULL)
     {
-      notify_notification_set_icon_from_pixbuf (notification, pixbuf);
+      notify_notification_set_image_from_pixbuf (notification, pixbuf);
       g_object_unref (pixbuf);
     }