aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-06-04 17:19:23 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-06-04 17:19:23 -0500
commit09ed92a81c950f6b2221652281c04c1c85e68177 (patch)
tree973bf8e5b62b578c6d56022a511c7db112926e8c
parent7a2f7f702c12558905b52335cf34b4fd9cf60233 (diff)
downloadayatana-indicator-session-09ed92a81c950f6b2221652281c04c1c85e68177.tar.gz
ayatana-indicator-session-09ed92a81c950f6b2221652281c04c1c85e68177.tar.bz2
ayatana-indicator-session-09ed92a81c950f6b2221652281c04c1c85e68177.zip
remove the software updates menuitem; it's no longer in the spec
-rw-r--r--configure.ac13
-rw-r--r--src/Makefile.am10
-rw-r--r--src/apt-watcher.c287
-rw-r--r--src/apt-watcher.h55
-rw-r--r--src/device-menu-mgr.c38
5 files changed, 7 insertions, 396 deletions
diff --git a/configure.ac b/configure.ac
index 84c5c2e..f17db0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,18 +84,6 @@ AC_SUBST(GTKLOGOUTHELPER_CFLAGS)
AC_SUBST(GTKLOGOUTHELPER_LIBS)
###########################
-# APT support
-###########################
-AC_ARG_ENABLE([apt],
- AC_HELP_STRING([--disable-apt], [disable APT support]),,
- [enable_apt=yes])
-AM_CONDITIONAL([BUILD_APT], [test "x$enable_apt" != "xno"])
-
-if test "x$enable_apt" != "xno"; then
- AC_DEFINE(HAVE_APT, 1, [Define to 1 to enable APT support])
-fi
-
-###########################
# Check to see if we're local
###########################
@@ -240,7 +228,6 @@ SUS Indicator Configuration:
Prefix: $prefix
Indicator Dir: $INDICATORDIR
Logout Helper: $have_gtklogouthelper
- APT support: $enable_apt
Unit Tests: $enable_tests
Coverage reporting: $use_gcov
])
diff --git a/src/Makefile.am b/src/Makefile.am
index 76c9c03..fd3480f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -116,16 +116,6 @@ indicator_session_service_SOURCES = \
device-menu-mgr.c \
sane-rules.h
-if BUILD_APT
-indicator_session_service_SOURCES += \
- apt-watcher.h \
- apt-watcher.c
-else
-EXTRA_DIST += \
- apt-watcher.h \
- apt-watcher.c
-endif
-
if HAS_GUDEV
indicator_session_service_SOURCES += \
udev-mgr.h \
diff --git a/src/apt-watcher.c b/src/apt-watcher.c
deleted file mode 100644
index 092942f..0000000
--- a/src/apt-watcher.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
-Copyright 2011 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-// Conor - 6/2/2012
-// Please pull in packagekit's client lib
-// using apt-get install --no-install-recommends libpackagekit-glib2-dev
-// make sure you don't install package-kit
-#define I_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
-
-#include <glib/gi18n.h>
-#include <packagekit-glib2/packagekit.h>
-#include "apt-watcher.h"
-#include "dbus-shared-names.h"
-
-static guint watcher_id;
-
-struct _AptWatcher
-{
- GObject parent_instance;
- SessionDbus* session_dbus_interface;
- DbusmenuMenuitem* apt_item;
- AptState current_state;
- GCancellable * proxy_cancel;
- GDBusProxy * proxy;
-};
-
-G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT);
-
-
-static void
-get_updates_complete (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- g_return_if_fail (APT_IS_WATCHER (user_data));
- AptWatcher* self = APT_WATCHER (user_data);
-
- PkResults *results;
- PkRestartEnum restart_required;
- GError *error = NULL;
- results = pk_client_generic_finish (PK_CLIENT(source_object), res, &error);
-
- if (error != NULL){
- g_warning ("Unable to query for updates - error - %s", error->message);
- return;
- }
-
- GPtrArray *packages;
- packages = pk_results_get_package_array (results);
-
- const gchar* disposition;
- disposition = dbusmenu_menuitem_property_get (self->apt_item,
- DBUSMENU_MENUITEM_PROP_DISPOSITION);
- gboolean do_update;
- do_update = g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) != 0;
-
- if (packages->len > 0){
- g_print ("Apparently we have updates available - change dbmitem %i", do_update);
- if (do_update)
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Updates Available…"));
- }
- else{
- g_print ("No updates available - change dbmitem - %i", do_update);
- if (do_update)
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
- }
-
- /* check if there was a restart required info in the signal */
- restart_required = pk_results_get_require_restart_worst (results);
- if (restart_required == PK_RESTART_ENUM_SYSTEM ||
- restart_required == PK_RESTART_ENUM_SECURITY_SYSTEM) {
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Restart to Complete Updates…"));
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_DISPOSITION,
- DBUSMENU_MENUITEM_DISPOSITION_ALERT);
- session_dbus_restart_required (self->session_dbus_interface);
- }
-
- g_ptr_array_unref (packages);
- g_object_unref (results);
- g_object_unref (source_object);
-}
-
-static void
-apt_watcher_check_for_updates (AptWatcher* self)
-{
- PkClient* client;
- client = pk_client_new ();
-
- pk_client_get_updates_async (client,
- PK_FILTER_ENUM_NONE,
- NULL, NULL, NULL,
- (GAsyncReadyCallback)get_updates_complete,
- self);
-}
-
-static void apt_watcher_signal_cb ( GDBusProxy* proxy,
- gchar* sender_name,
- gchar* signal_name,
- GVariant* parameters,
- gpointer user_data)
-{
- g_return_if_fail (APT_IS_WATCHER (user_data));
- AptWatcher* self = APT_WATCHER (user_data);
-
- g_debug ("apt-watcher-signal cb signal name - %s", signal_name);
- if (g_strcmp0(signal_name, "UpdatesChanged") == 0){
- g_debug ("updates changed signal received");
- apt_watcher_check_for_updates (self);
- }
-}
-
-static void
-apt_watcher_on_name_appeared (GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
- gpointer user_data)
-{
- g_return_if_fail (APT_IS_WATCHER (user_data));
- // AptWatcher* watcher = APT_WATCHER (user_data);
-
- g_print ("Name %s on %s is owned by %s\n",
- name,
- "the system bus",
- name_owner);
-}
-
-
-static void
-apt_watcher_on_name_vanished (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_debug ("Name %s does not exist or has just vanished",
- name);
- g_return_if_fail (APT_IS_WATCHER (user_data));
-}
-
-static void
-fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
-{
- GError * error = NULL;
-
- AptWatcher* self = APT_WATCHER(user_data);
- g_return_if_fail(self != NULL);
-
- GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
-
- if (self->proxy_cancel != NULL) {
- g_object_unref (self->proxy_cancel);
- self->proxy_cancel = NULL;
- }
-
- if (error != NULL) {
- g_warning("Could not grab DBus proxy for %s: %s",
- "org.debian.apt", error->message);
- g_error_free(error);
- return;
- }
-
- self->proxy = proxy;
- // Set up the watch.
- watcher_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
- "org.freedesktop.PackageKit",
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- apt_watcher_on_name_appeared,
- apt_watcher_on_name_vanished,
- self,
- NULL);
- g_signal_connect (self->proxy,
- "g-signal",
- G_CALLBACK(apt_watcher_signal_cb),
- self);
-}
-
-static gboolean
-apt_watcher_start_apt_interaction (gpointer data)
-{
- g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
- AptWatcher* self = APT_WATCHER (data);
- g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "org.freedesktop.PackageKit",
- "/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit",
- self->proxy_cancel,
- fetch_proxy_cb,
- self);
- apt_watcher_check_for_updates (self);
- return FALSE;
-}
-
-
-static void
-apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
- guint timestamp,
- gpointer userdata)
-{
- GError * error = NULL;
- g_return_if_fail (APT_IS_WATCHER (userdata));
- AptWatcher* self = APT_WATCHER (userdata);
- const gchar* disposition = NULL;
- disposition = dbusmenu_menuitem_property_get (self->apt_item,
- DBUSMENU_MENUITEM_PROP_DISPOSITION);
-
- if (g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) == 0){
- gchar * helper = g_build_filename (LIBEXECDIR, "gtk-logout-helper", NULL);
- gchar * dialog_line = g_strdup_printf ("%s --%s", helper, "restart");
- g_free(helper);
- if (!g_spawn_command_line_async(dialog_line, &error)) {
- g_warning("Unable to show dialog: %s", error->message);
- g_error_free(error);
- }
- g_free(dialog_line);
- }
- else{
- if (!g_spawn_command_line_async("update-manager", &error))
- {
- g_warning("Unable to show update-manager: %s", error->message);
- g_error_free(error);
- }
- }
-}
-
-static void
-apt_watcher_init (AptWatcher *self)
-{
- self->current_state = UP_TO_DATE;
- g_timeout_add_seconds (60,
- apt_watcher_start_apt_interaction,
- self);
-}
-
-static void
-apt_watcher_finalize (GObject *object)
-{
- g_bus_unwatch_name (watcher_id);
- AptWatcher* self = APT_WATCHER (object);
-
- if (self->proxy != NULL)
- g_object_unref (self->proxy);
-
- G_OBJECT_CLASS (apt_watcher_parent_class)->finalize (object);
-}
-
-static void
-apt_watcher_class_init (AptWatcherClass *klass)
-{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = apt_watcher_finalize;
-}
-
-AptWatcher* apt_watcher_new (SessionDbus* session_dbus,
- DbusmenuMenuitem* item)
-{
- AptWatcher* watcher = g_object_new (APT_TYPE_WATCHER, NULL);
- watcher->session_dbus_interface = session_dbus;
- watcher->apt_item = item;
- g_signal_connect (G_OBJECT(watcher->apt_item),
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(apt_watcher_show_apt_dialog), watcher);
- return watcher;
-}
-
diff --git a/src/apt-watcher.h b/src/apt-watcher.h
deleted file mode 100644
index c571502..0000000
--- a/src/apt-watcher.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright 2011 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _APT_WATCHER_H_
-#define _APT_WATCHER_H_
-
-#include <glib-object.h>
-
-#include <libdbusmenu-glib/client.h>
-
-#include <gtk/gtk.h>
-#include <libdbusmenu-gtk/menuitem.h>
-
-#include "session-dbus.h"
-
-G_BEGIN_DECLS
-
-#define APT_TYPE_WATCHER (apt_watcher_get_type ())
-#define APT_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APT_TYPE_WATCHER, AptWatcher))
-#define APT_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APT_TYPE_WATCHER, AptWatcherClass))
-#define APT_IS_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APT_TYPE_WATCHER))
-#define APT_IS_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APT_TYPE_WATCHER))
-#define APT_WATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APT_TYPE_WATCHER, AptWatcherClass))
-
-typedef struct _AptWatcherClass AptWatcherClass;
-typedef struct _AptWatcher AptWatcher;
-
-struct _AptWatcherClass
-{
- GObjectClass parent_class;
-};
-
-GType apt_watcher_get_type (void) G_GNUC_CONST;
-
-AptWatcher* apt_watcher_new (SessionDbus* session_dbus,
- DbusmenuMenuitem* apt_item);
-G_END_DECLS
-
-#endif /* _APT_WATCHER_H_ */
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index 654e967..81182b9 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -18,7 +18,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-gtk/menuitem.h>
#include "device-menu-mgr.h"
#include "settings-helper.h"
@@ -27,10 +32,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "lock-helper.h"
#include "upower-client.h"
-#ifdef HAVE_APT
-#include "apt-watcher.h"
-#endif /* HAVE_APT */
-
#ifdef HAS_GUDEV
#include "udev-mgr.h"
#endif /* HAS_GUDEV */
@@ -43,12 +44,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
struct _DeviceMenuMgr
{
- GObject parent_instance;
+ GObject parent_instance;
DbusmenuMenuitem* root_item;
SessionDbus* session_dbus_interface;
-#ifdef HAVE_APT
- AptWatcher* apt_watcher;
-#endif /* HAVE_APT */
#ifdef HAS_GUDEV
UdevMgr* udev_mgr;
#endif /* HAS_GUDEV */
@@ -58,9 +56,6 @@ static GSettings *lockdown_settings = NULL;
static GSettings *keybinding_settings = NULL;
static DbusmenuMenuitem *lock_menuitem = NULL;
static DbusmenuMenuitem *system_settings_menuitem = NULL;
-#ifdef HAVE_APT
-static DbusmenuMenuitem *software_updates_menuitem = NULL;
-#endif /* HAVE_APT */
static DBusGProxyCall * suspend_call = NULL;
static DBusGProxyCall * hibernate_call = NULL;
@@ -101,9 +96,6 @@ G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT);
static void
device_menu_mgr_init (DeviceMenuMgr *self)
{
-#ifdef HAVE_APT
- self->apt_watcher = NULL;
-#endif /* HAVE_APT */
self->root_item = dbusmenu_menuitem_new ();
setup_up(self);
g_idle_add(lock_screen_setup, NULL);
@@ -441,21 +433,11 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self)
system_settings_menuitem,
0);
-#ifdef HAVE_APT
- software_updates_menuitem = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set (software_updates_menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
- dbusmenu_menuitem_child_add_position(self->root_item,
- software_updates_menuitem,
- 1);
-#endif /* HAVE_APT */
-
DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (separator1,
DBUSMENU_MENUITEM_PROP_TYPE,
DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_add_position (self->root_item, separator1, 2);
+ dbusmenu_menuitem_child_add_position (self->root_item, separator1, 1);
}
static void
@@ -644,11 +626,5 @@ DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_
DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL);
device_mgr->session_dbus_interface = session_dbus;
device_menu_mgr_build_static_items (device_mgr, greeter_mode);
-#ifdef HAVE_APT
- if (software_updates_menuitem != NULL) {
- device_mgr->apt_watcher = apt_watcher_new (session_dbus,
- software_updates_menuitem);
- }
-#endif /* HAVE_APT */
return device_mgr;
}