]> git.0d.be Git - empathy.git/commitdiff
Add Accept/Decline button in subscription notifications (#630706)
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 28 Oct 2010 13:08:18 +0000 (15:08 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 9 Nov 2010 08:04:35 +0000 (09:04 +0100)
src/empathy-status-icon.c

index e61e0cfd407f96a3dc47c8e5ec9ba8a24926f6cc..6bfb2f3a0ed874af8d7d010b286793fd8e2c1b7e 100644 (file)
@@ -35,6 +35,7 @@
 #include <telepathy-glib/account-manager.h>
 #include <telepathy-glib/util.h>
 
+#include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-gsettings.h>
 #include <libempathy/empathy-utils.h>
 
@@ -129,6 +130,48 @@ notification_decline_cb (NotifyNotification *notification,
                empathy_event_decline (priv->event);
 }
 
+static void
+notification_decline_subscription_cb (NotifyNotification *notification,
+                       gchar              *action,
+                       EmpathyStatusIcon  *icon)
+{
+       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+       EmpathyContactManager *manager;
+
+       if (priv->event == NULL)
+               return;
+
+
+       manager = empathy_contact_manager_dup_singleton ();
+       empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager),
+                                    priv->event->contact, "");
+
+       empathy_event_remove (priv->event);
+
+       g_object_unref (manager);
+}
+
+static void
+notification_accept_subscription_cb (NotifyNotification *notification,
+                       gchar              *action,
+                       EmpathyStatusIcon  *icon)
+{
+       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+       EmpathyContactManager *manager;
+
+       if (priv->event == NULL)
+               return;
+
+
+       manager = empathy_contact_manager_dup_singleton ();
+       empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
+                                 priv->event->contact, "");
+
+       empathy_event_remove (priv->event);
+
+       g_object_unref (manager);
+}
+
 static void
 add_notification_actions (EmpathyStatusIcon *self,
                          NotifyNotification *notification)
@@ -163,6 +206,17 @@ add_notification_actions (EmpathyStatusIcon *self,
                                        self, NULL);
                        break;
 
+               case EMPATHY_EVENT_TYPE_SUBSCRIPTION:
+                       notify_notification_add_action (notification,
+                               "decline", _("Decline"),
+                                       (NotifyActionCallback) notification_decline_subscription_cb,
+                                       self, NULL);
+
+                       notify_notification_add_action (notification,
+                               "accept", _("Accept"),
+                                       (NotifyActionCallback) notification_accept_subscription_cb,
+                                       self, NULL);
+
                default:
                        break;
        }