[gnome-online-accounts/gnome-3-8] daemon: Do not use notifications when an account needs attention



commit 802958a071f49a301c6bc39b98c486062b7ca1ee
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Mar 4 22:13:54 2013 +0100

    daemon: Do not use notifications when an account needs attention
    
    We want the applications to handle the notification themselves if the
    credentials for an account do not work (ie., if EnsureCredentials
    fails). Having the daemon throw a notification is bad because:
      * it does not give the user sufficient context to determine what
        actually failed
      * background services might be calling EnsureCredentials, and these
        should never lead to a notification unless it was in response to
        an explicit user action
    
    This also reverts commit cbcb0da9ea39c841e4cc1f82b88379920604d0a3.
    
    Fixes: https://bugzilla.gnome.org/660882

 configure.ac                  |    4 -
 data/Makefile.am              |   13 ---
 data/goa-daemon.desktop.in.in |   12 ---
 po/POTFILES.in                |    1 -
 src/daemon/Makefile.am        |    2 -
 src/daemon/goadaemon.c        |  167 -----------------------------------------
 src/goaidentity/Makefile.am   |    2 -
 7 files changed, 0 insertions(+), 201 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 537f024..81395d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,10 +89,6 @@ PKG_CHECK_MODULES(JSON_GLIB, [json-glib-1.0])
 AC_SUBST(JSON_GLIB_CFLAGS)
 AC_SUBST(JSON_GLIB_LIBS)
 
-PKG_CHECK_MODULES(LIBNOTIFY, [libnotify >= 0.7])
-AC_SUBST(LIBNOTIFY_CFLAGS)
-AC_SUBST(LIBNOTIFY_LIBS)
-
 PKG_CHECK_MODULES(REST, [rest-0.7])
 AC_SUBST(REST_CFLAGS)
 AC_SUBST(REST_LIBS)
diff --git a/data/Makefile.am b/data/Makefile.am
index 48ad0d9..49004b8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -6,11 +6,6 @@ SUBDIRS = icons
 cssdir = $(pkgdatadir)
 css_DATA = goawebview.css
 
-desktopdir = $(datadir)/applications
-desktop_in_in_files = goa-daemon.desktop.in.in
-desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-
 servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gnome.OnlineAccounts.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
@@ -18,22 +13,14 @@ service_DATA     = $(service_in_files:.service.in=.service)
 $(service_DATA): $(service_in_files) Makefile
        @sed -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
 
-$(desktop_in_files): $(desktop_in_in_files) Makefile
-       @sed -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
-
- INTLTOOL_DESKTOP_RULE@
-
 EXTRA_DIST =                                           \
        $(css_DATA)                                     \
-       $(desktop_in_in_files)                          \
        $(service_in_files)                             \
        dbus-interfaces.xml                             \
        $(NULL)
 
 DISTCLEANFILES =                                       \
        org.gnome.OnlineAccounts.service                \
-       $(desktop_DATA)                                 \
-       $(desktop_in_files)                             \
        $(NULL)
 
 clean-local :
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6cbdad1..f61ba73 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,7 +1,6 @@
 [encoding: UTF-8]
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
-data/goa-daemon.desktop.in.in
 src/daemon/goadaemon.c
 src/goabackend/goaewsclient.c
 src/goabackend/goaexchangeprovider.c
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index bd3df44..97ad29d 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -37,7 +37,6 @@ goa_daemon_CPPFLAGS =                                         \
 goa_daemon_CFLAGS =                                            \
        $(GLIB_CFLAGS)                                          \
        $(GTK_CFLAGS)                                           \
-       $(LIBNOTIFY_CFLAGS)                                     \
        $(REST_CFLAGS)                                          \
        $(NULL)
 
@@ -46,7 +45,6 @@ goa_daemon_LDADD =                                            \
        $(top_builddir)/src/goa/libgoa-1.0.la                   \
        $(top_builddir)/src/goabackend/libgoa-backend-1.0.la    \
        $(GTK_LIBS)                                             \
-       $(LIBNOTIFY_LIBS)                                       \
        $(REST_LIBS)                                            \
        $(NULL)
 
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index c61e07c..697601a 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -22,7 +22,6 @@
 
 #include "config.h"
 #include <glib/gi18n.h>
-#include <libnotify/notify.h>
 #include <gio/gdesktopappinfo.h>
 #include <rest/rest-proxy.h>
 #include <libsoup/soup.h>
@@ -53,8 +52,6 @@ struct _GoaDaemon
   GoaIdentityService *identity_service;
 #endif
 
-  NotifyNotification *notification;
-
   guint config_timeout_id;
 };
 
@@ -88,13 +85,6 @@ static gboolean on_account_handle_ensure_credentials (GoaAccount            *acc
 
 static void goa_daemon_reload_configuration (GoaDaemon *daemon);
 
-static void on_notification_closed (NotifyNotification *notification,
-                                    gpointer            user_data);
-
-static void account_on_attention_needed_notify (GObject     *object,
-                                                GParamSpec  *pspec,
-                                                gpointer     user_data);
-
 G_DEFINE_TYPE (GoaDaemon, goa_daemon, G_TYPE_OBJECT);
 
 static void
@@ -107,13 +97,6 @@ goa_daemon_finalize (GObject *object)
       g_source_remove (daemon->config_timeout_id);
     }
 
-  if (daemon->notification != NULL)
-    {
-      g_signal_handlers_disconnect_by_func (daemon->notification,
-                                            G_CALLBACK (on_notification_closed),
-                                            daemon);
-      g_object_unref (daemon->notification);
-    }
   if (daemon->system_conf_dir_monitor != NULL)
     {
       g_signal_handlers_disconnect_by_func (daemon->system_conf_dir_monitor, on_file_monitor_changed, 
daemon);
@@ -209,8 +192,6 @@ goa_daemon_init (GoaDaemon *daemon)
   goa_error_domain = GOA_ERROR;
   goa_error_domain; /* shut up -Wunused-but-set-variable */
 
-  notify_init (_("Online Accounts"));
-
   /* TODO: maybe nicer to pass in a GDBusConnection* construct property */
   daemon->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
 
@@ -603,9 +584,6 @@ process_config_entries (GoaDaemon  *daemon,
       object = GOA_OBJECT (g_dbus_object_manager_get_object (G_DBUS_OBJECT_MANAGER (daemon->object_manager), 
object_path));
       g_warn_if_fail (object != NULL);
       g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
-                                            G_CALLBACK (account_on_attention_needed_notify),
-                                            daemon);
-      g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
                                             G_CALLBACK (on_account_handle_remove),
                                             daemon);
       goa_debug ("removing %s", object_path);
@@ -633,10 +611,6 @@ process_config_entries (GoaDaemon  *daemon,
         {
           g_dbus_object_manager_server_export (daemon->object_manager, G_DBUS_OBJECT_SKELETON (object));
           g_signal_connect (goa_object_peek_account (GOA_OBJECT (object)),
-                            "notify::attention-needed",
-                            G_CALLBACK (account_on_attention_needed_notify),
-                            daemon);
-          g_signal_connect (goa_object_peek_account (GOA_OBJECT (object)),
                             "handle-remove",
                             G_CALLBACK (on_account_handle_remove),
                             daemon);
@@ -670,9 +644,6 @@ process_config_entries (GoaDaemon  *daemon,
                                   FALSE))
         {
           g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
-                                                G_CALLBACK (account_on_attention_needed_notify),
-                                                daemon);
-          g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
                                                 G_CALLBACK (on_account_handle_remove),
                                                 daemon);
           g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
@@ -918,144 +889,6 @@ on_manager_handle_add_account (GoaManager             *manager,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static void
-notification_cb (NotifyNotification *notification,
-                 gchar              *action,
-                 gpointer            user_data)
-{
-  GAppLaunchContext *ctx;
-  GDesktopAppInfo *app;
-  GError *error;
-
-  /* TODO: Hmm, would be nice to set the screen, timestamp etc etc */
-  ctx = g_app_launch_context_new ();
-
-  app = g_desktop_app_info_new ("gnome-online-accounts-panel.desktop");
-
-  error = NULL;
-  if (!g_app_info_launch (G_APP_INFO (app),
-                          NULL, /* files */
-                          ctx,
-                          &error))
-    {
-      goa_warning ("Error launching: %s (%s, %d)",
-                   error->message, g_quark_to_string (error->domain), error->code);
-      g_error_free (error);
-    }
-  g_object_unref (app);
-  g_object_unref (ctx);
-}
-
-static void
-on_notification_closed (NotifyNotification *notification,
-                        gpointer            user_data)
-{
-  GoaDaemon *daemon = GOA_DAEMON (user_data);
-  g_signal_handlers_disconnect_by_func (daemon->notification,
-                                        G_CALLBACK (on_notification_closed),
-                                        daemon);
-  g_object_unref (daemon->notification);
-  daemon->notification = NULL;
-}
-
-static void
-goa_daemon_update_notifications (GoaDaemon *daemon)
-{
-  gboolean show_notification;
-  GList *objects;
-  GList *l;
-
-  show_notification = FALSE;
-  objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (daemon->object_manager));
-  for (l = objects; l != NULL; l = l->next)
-    {
-      GoaObject *object = GOA_OBJECT (l->data);
-      GoaAccount *account;
-      account = goa_object_peek_account (object);
-      if (account != NULL)
-        {
-          if (goa_account_get_attention_needed (account))
-            {
-              show_notification = TRUE;
-              break;
-            }
-        }
-    }
-
-  if (show_notification)
-    {
-      if (daemon->notification == NULL)
-        {
-          GError *error;
-          GVariant *desktop_entry;
-
-          daemon->notification = notify_notification_new (_("An online account needs attention"),
-                                                          NULL,
-                                                          NULL);
-          desktop_entry = g_variant_new_string ("goa-daemon");
-          notify_notification_set_hint (daemon->notification, "desktop-entry", desktop_entry);
-          notify_notification_set_timeout (daemon->notification, NOTIFY_EXPIRES_NEVER);
-          g_object_set (daemon->notification, "icon-name", "gtk-dialog-error", NULL);
-          notify_notification_add_action (daemon->notification,
-                                          "open-online-accounts",
-                                          _("Open Online Accounts..."),
-                                          notification_cb,
-                                          daemon,
-                                          NULL); /* GFreeFunc */
-
-          error = NULL;
-          if (!notify_notification_show (daemon->notification, &error))
-            {
-              goa_warning ("Error showing notification: %s (%s, %d)",
-                           error->message, g_quark_to_string (error->domain), error->code);
-              g_error_free (error);
-              g_object_unref (daemon->notification);
-              daemon->notification = NULL;
-            }
-          else
-            {
-              g_signal_connect (daemon->notification,
-                                "closed",
-                                G_CALLBACK (on_notification_closed),
-                                daemon);
-            }
-        }
-    }
-  else
-    {
-      if (daemon->notification != NULL)
-        {
-          GError *error;
-          error = NULL;
-          if (!notify_notification_close (daemon->notification, &error))
-            {
-              goa_warning ("Error closing notification: %s (%s, %d)",
-                           error->message, g_quark_to_string (error->domain), error->code);
-              g_error_free (error);
-            }
-          g_signal_handlers_disconnect_by_func (daemon->notification,
-                                                G_CALLBACK (on_notification_closed),
-                                                daemon);
-          g_object_unref (daemon->notification);
-          daemon->notification = NULL;
-        }
-    }
-
-  g_list_foreach (objects, (GFunc) g_object_unref, NULL);
-  g_list_free (objects);
-}
-
-static void
-account_on_attention_needed_notify (GObject     *object,
-                                    GParamSpec  *pspec,
-                                    gpointer     user_data)
-{
-  GoaDaemon *daemon = GOA_DAEMON (user_data);
-  goa_daemon_update_notifications (daemon);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
 static gboolean
 on_account_handle_remove (GoaAccount            *account,
                           GDBusMethodInvocation *invocation,
diff --git a/src/goaidentity/Makefile.am b/src/goaidentity/Makefile.am
index 036c576..dbce960 100644
--- a/src/goaidentity/Makefile.am
+++ b/src/goaidentity/Makefile.am
@@ -110,7 +110,6 @@ libgoaidentity_la_CPPFLAGS =                                        \
 libgoaidentity_la_CFLAGS =                                     \
        $(GLIB_CFLAGS)                                          \
        $(GTK_CFLAGS)                                           \
-       $(LIBNOTIFY_CFLAGS)                                     \
        $(KRB5_CFLAGS)                                          \
        $(GCR_CFLAGS)                                           \
        $(NULL)
@@ -118,7 +117,6 @@ libgoaidentity_la_CFLAGS =                                  \
 libgoaidentity_la_LIBADD =                                     \
        $(GLIB_LIBS)                                            \
        $(GTK_LIBS)                                             \
-       $(LIBNOTIFY_LIBS)                                       \
        $(KRB5_LIBS)                                            \
        $(GCR_LIBS)                                             \
        $(NULL)


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