[empathy] set a category on chat related notifications



commit aaf4798dd5eb270c95964441cf29768e580ef80b
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Mar 29 10:07:01 2011 +0200

    set a category on chat related notifications
    
    That can be used by the Shell to filter out notifications it's handling itself
    directly (#645932).

 libempathy-gtk/empathy-notify-manager.h |    1 +
 src/empathy-notifications-approver.c    |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-notify-manager.h b/libempathy-gtk/empathy-notify-manager.h
index f7c5e4c..dd7565c 100644
--- a/libempathy-gtk/empathy-notify-manager.h
+++ b/libempathy-gtk/empathy-notify-manager.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 #define EMPATHY_NOTIFY_MANAGER_CAP_BODY_HYPERLINKS     "body-hyperlinks"
 #define EMPATHY_NOTIFY_MANAGER_CAP_BODY_IMAGES         "body-images"
 #define EMPATHY_NOTIFY_MANAGER_CAP_BODY_MARKUP         "body-markup"
+#define EMPATHY_NOTIFY_MANAGER_CAP_CATEGORY            "category"
 #define EMPATHY_NOTIFY_MANAGER_CAP_ICON_MULTI          "icon-multi"
 #define EMPATHY_NOTIFY_MANAGER_CAP_ICON_STATIC         "icon-static"
 #define EMPATHY_NOTIFY_MANAGER_CAP_IMAGE_SVG_XML       "image/svg+xml"
diff --git a/src/empathy-notifications-approver.c b/src/empathy-notifications-approver.c
index 9f1774a..4bfe23c 100644
--- a/src/empathy-notifications-approver.c
+++ b/src/empathy-notifications-approver.c
@@ -244,6 +244,24 @@ notification_is_urgent (EmpathyNotificationsApprover *self,
   return FALSE;
 }
 
+static const gchar *
+get_category_for_event_type (EmpathyEventType type)
+{
+  switch (type) {
+    case EMPATHY_EVENT_TYPE_CHAT:
+      return "im.received";
+    case EMPATHY_EVENT_TYPE_VOIP:
+    case EMPATHY_EVENT_TYPE_TRANSFER:
+    case EMPATHY_EVENT_TYPE_INVITATION:
+    case EMPATHY_EVENT_TYPE_AUTH:
+    case EMPATHY_EVENT_TYPE_SUBSCRIPTION:
+    case EMPATHY_EVENT_TYPE_PRESENCE:
+      return NULL;
+  }
+
+  return NULL;
+}
+
 static void
 update_notification (EmpathyNotificationsApprover *self)
 {
@@ -283,6 +301,8 @@ update_notification (EmpathyNotificationsApprover *self)
     }
   else
     {
+      const gchar *category;
+
       /* if the notification server supports x-canonical-append,
        * the hint will be added, so that the message from the
        * just created notification will be automatically appended
@@ -313,6 +333,11 @@ update_notification (EmpathyNotificationsApprover *self)
 
       if (notification_is_urgent (self, notification))
         notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
+
+      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);
     }
 
   pixbuf = empathy_notify_manager_get_pixbuf_for_notification (



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]