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) { EmpathyCallObserver *self = (EmpathyCallObserver *) weak_object; NotifyNotification *notification; TpContact *contact; gchar *summary, *body; EmpathyContact *emp_contact; GdkPixbuf *pixbuf; if (n_contacts != 1) { DEBUG ("Failed to get TpContact; ignoring notification bubble"); return; } contact = contacts[0]; summary = g_strdup_printf (_("Missed call from %s"), tp_contact_get_alias (contact)); body = g_strdup_printf ( _("%s just tried to call you, but you were in another call."), tp_contact_get_alias (contact)); notification = notify_notification_new (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); if (pixbuf != NULL) { notify_notification_set_icon_from_pixbuf (notification, pixbuf); g_object_unref (pixbuf); } notify_notification_show (notification, NULL); g_object_unref (notification); g_free (summary); g_free (body); g_object_unref (emp_contact); }
static void status_icon_update_notification (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); GdkPixbuf *pixbuf = NULL; if (!empathy_notify_manager_notification_is_enabled (priv->notify_mgr)) { /* always close the notification if this happens */ notification_close_helper (priv); return; } if (priv->event) { gchar *message_esc = NULL; gboolean has_x_canonical_append; NotifyNotification *notification = priv->notification; if (priv->event->message != NULL) message_esc = g_markup_escape_text (priv->event->message, -1); has_x_canonical_append = empathy_notify_manager_has_capability (priv->notify_mgr, EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND); if (notification != NULL && ! has_x_canonical_append) { /* if the notification server supports x-canonical-append, it is better to not use notify_notification_update to avoid overwriting the current notification message */ notify_notification_update (notification, priv->event->header, message_esc, NULL); } else { /* 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 to an existing notification with the same title. In this way the previous message will not be lost: the new message will appear below it, in the same notification */ notification = notify_notification_new_with_status_icon (priv->event->header, message_esc, NULL, priv->icon); if (priv->notification == NULL) { priv->notification = notification; } notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); if (has_x_canonical_append) { notify_notification_set_hint_string (notification, EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND, ""); } if (empathy_notify_manager_has_capability (priv->notify_mgr, EMPATHY_NOTIFY_MANAGER_CAP_ACTIONS) && priv->event->type != EMPATHY_EVENT_TYPE_PRESENCE) { notify_notification_add_action (notification, "respond", _("Respond"), (NotifyActionCallback) notification_action_cb, icon, NULL); } g_signal_connect (notification, "closed", G_CALLBACK (status_icon_notification_closed_cb), icon); } pixbuf = empathy_notify_manager_get_pixbuf_for_notification ( priv->notify_mgr, priv->event->contact, priv->event->icon_name); if (pixbuf != NULL) { notify_notification_set_icon_from_pixbuf (notification, pixbuf); g_object_unref (pixbuf); } notify_notification_show (notification, NULL); g_free (message_esc); } else { notification_close_helper (priv); } }