[packages/gnome-packagekit] - updated to 3.14.2 - python bindings are gone

baggins baggins at pld-linux.org
Sun Mar 22 21:59:54 CET 2015


commit c4d5c1a74f63767490b226e41510a4cb8e87a59d
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Mar 22 21:59:34 2015 +0100

    - updated to 3.14.2
    - python bindings are gone

 gnome-packagekit.spec  |  43 +---
 systemd-fallback.patch | 615 +++++++++++++++++++++++++++++++++++++------------
 2 files changed, 474 insertions(+), 184 deletions(-)
---
diff --git a/gnome-packagekit.spec b/gnome-packagekit.spec
index 80b1e38..9ff4fb5 100644
--- a/gnome-packagekit.spec
+++ b/gnome-packagekit.spec
@@ -5,12 +5,12 @@
 Summary:	GNOME PackageKit Client
 Summary(pl.UTF-8):	Klient PackageKit dla GNOME
 Name:		gnome-packagekit
-Version:	3.6.1
+Version:	3.14.2
 Release:	1
 License:	GPL v2+
 Group:		X11/Applications
-Source0:	http://ftp.gnome.org/pub/GNOME/sources/gnome-packagekit/3.6/%{name}-%{version}.tar.xz
-# Source0-md5:	a4467f482ffb77ae9b2650d25970583f
+Source0:	http://ftp.gnome.org/pub/GNOME/sources/gnome-packagekit/3.14/%{name}-%{version}.tar.xz
+# Source0-md5:	a503defd4d21203407e2f2c6d92928b4
 Patch0:		systemd-fallback.patch
 URL:		http://www.packagekit.org/
 BuildRequires:	PackageKit-devel >= 0.8.0
@@ -61,20 +61,6 @@ removing packages.
 Ten pakiet dostarcza aplikacje sesji dla API PackageKit. Zawiera kilka
 narzędzi stworzonych do instalacji, aktualizacji i usuwania pakietów.
 
-%package -n python-gnome-packagekit
-Summary:	Widgets to use PackageKit in GTK+ applications
-Summary(pl.UTF-8):	Widgety do użycia PackageKit w aplikacjach GTK+
-Group:		Libraries/Python
-Requires:	gnome-packagekit = %{version}-%{release}
-Requires:	python-packagekit
-Requires:	python-pygtk-gtk
-
-%description -n python-gnome-packagekit
-This module provides widgets to use PackageKit in GTK+ applications.
-
-%description -n python-gnome-packagekit -l pl.UTF-8
-Ten moduł dostarcza widgety do użycia PackageKit w aplikacjach GTK+.
-
 %prep
 %setup -q
 %patch0 -p1
@@ -120,16 +106,12 @@ rm -rf $RPM_BUILD_ROOT
 %doc AUTHORS ChangeLog COPYING NEWS README
 %attr(755,root,root) %{_bindir}/gpk-application
 %attr(755,root,root) %{_bindir}/gpk-dbus-service
-%attr(755,root,root) %{_bindir}/gpk-distro-upgrade
-%attr(755,root,root) %{_bindir}/gpk-install-catalog
 %attr(755,root,root) %{_bindir}/gpk-install-local-file
-%attr(755,root,root) %{_bindir}/gpk-install-mime-type
-%attr(755,root,root) %{_bindir}/gpk-install-package-name
-%attr(755,root,root) %{_bindir}/gpk-install-provide-file
 %attr(755,root,root) %{_bindir}/gpk-log
 %attr(755,root,root) %{_bindir}/gpk-prefs
-%attr(755,root,root) %{_bindir}/gpk-service-pack
 %attr(755,root,root) %{_bindir}/gpk-update-viewer
+%{_datadir}/appdata/gpk-application.appdata.xml
+%{_datadir}/appdata/gpk-update-viewer.appdata.xml
 %{_datadir}/GConf/gsettings/org.gnome.packagekit.gschema.migrate
 %{_datadir}/dbus-1/services/org.freedesktop.PackageKit.service
 %{_datadir}/glib-2.0/schemas/org.gnome.packagekit.gschema.xml
@@ -137,24 +119,13 @@ rm -rf $RPM_BUILD_ROOT
 %{_iconsdir}/hicolor/*/*/*
 %{_desktopdir}/gpk-application.desktop
 %{_desktopdir}/gpk-dbus-service.desktop
-%{_desktopdir}/gpk-distro-upgrade.desktop
-%{_desktopdir}/gpk-install-catalog.desktop
 %{_desktopdir}/gpk-install-local-file.desktop
 %{_desktopdir}/gpk-log.desktop
 %{_desktopdir}/gpk-prefs.desktop
-%{_desktopdir}/gpk-service-pack.desktop
 %{_desktopdir}/gpk-update-viewer.desktop
 %{_mandir}/man1/gpk-application.1*
-%{_mandir}/man1/gpk-backend-status.1*
+%{_mandir}/man1/gpk-dbus-service.1*
 %{_mandir}/man1/gpk-install-local-file.1*
-%{_mandir}/man1/gpk-install-mime-type.1*
-%{_mandir}/man1/gpk-install-package-name.1*
-%{_mandir}/man1/gpk-install-provide-file.1*
+%{_mandir}/man1/gpk-log.1*
 %{_mandir}/man1/gpk-prefs.1*
-%{_mandir}/man1/gpk-repo.1*
-%{_mandir}/man1/gpk-update-icon.1*
 %{_mandir}/man1/gpk-update-viewer.1*
-
-%files -n python-gnome-packagekit
-%defattr(644,root,root,755)
-%{py_sitescriptdir}/packagekit/*.py[co]
diff --git a/systemd-fallback.patch b/systemd-fallback.patch
index d579eaf..3c53d3b 100644
--- a/systemd-fallback.patch
+++ b/systemd-fallback.patch
@@ -10,133 +10,46 @@ diff -urN gnome-packagekit-3.6.0/configure.ac gnome-packagekit-3.6.0.new/configu
                    [have_systemd=yes], [have_systemd=no])
  
  AC_MSG_CHECKING([whether to use systemd])
-diff -urN gnome-packagekit-3.6.0/src/gpk-distro-upgrade.c gnome-packagekit-3.6.0.new/src/gpk-distro-upgrade.c
---- gnome-packagekit-3.6.0/src/gpk-distro-upgrade.c	2012-06-26 12:18:11.000000000 +0200
-+++ gnome-packagekit-3.6.0.new/src/gpk-distro-upgrade.c	2012-10-09 14:08:20.213457912 +0200
-@@ -27,10 +27,10 @@
- #include <packagekit-glib2/packagekit.h>
- 
- #ifdef HAVE_SYSTEMD
-+#include <systemd/sd-daemon.h>
- #include "systemd-proxy.h"
--#else
--#include "egg-console-kit.h"
- #endif
-+#include "egg-console-kit.h"
- 
- #include "gpk-animated-icon.h"
- #include "gpk-common.h"
-@@ -47,9 +47,8 @@
- typedef struct {
- #ifdef HAVE_SYSTEMD
-         SystemdProxy    *systemd_proxy;
--#else
--	EggConsoleKit	*console_kit;
- #endif
-+	EggConsoleKit	*console_kit;
- 	GCancellable	*cancellable;
- 	GtkListStore	*distro_upgrade_store;
- 	GtkWidget	*assistant;
-@@ -118,10 +117,12 @@
- 	/* restart */
- 	if (response_id == GTK_RESPONSE_OK) {
- #ifdef HAVE_SYSTEMD
--                ret = systemd_proxy_restart (priv->systemd_proxy, &error);
--#else
--		ret = egg_console_kit_restart (priv->console_kit, &error);
-+		if (priv->systemd_proxy != NULL)
-+            		ret = systemd_proxy_restart (priv->systemd_proxy, &error);
-+		else
- #endif
-+			ret = egg_console_kit_restart (priv->console_kit, &error);
-+
- 		if (!ret) {
- 			g_warning ("Cannot restart: %s", error->message);
- 			g_error_free (error);
-@@ -178,11 +179,13 @@
- 						  _("Make sure you have saved any unsaved work before restarting."));
+diff -urN gnome-packagekit-3.6.0/src/Makefile.am gnome-packagekit-3.6.0.new/src/Makefile.am
+--- gnome-packagekit-3.6.0/src/Makefile.am	2012-05-15 14:44:47.000000000 +0200
++++ gnome-packagekit-3.6.0.new/src/Makefile.am	2012-10-09 13:59:32.313986610 +0200
+@@ -87,6 +87,8 @@
+ 	gpk-task.h					\
+ 	gpk-error.c					\
+ 	gpk-error.h					\
++	egg-console-kit.c				\
++	egg-console-kit.h				\
+ 	$(NULL)
  
- #ifdef HAVE_SYSTEMD
--        ret = systemd_proxy_can_restart (priv->systemd_proxy, &can_restart, &error);
--#else
--	/* check with ConsoleKit we can restart */
--	ret = egg_console_kit_can_restart (priv->console_kit, &can_restart, &error);
-+	if (priv->systemd_proxy != NULL)
-+    		ret = systemd_proxy_can_restart (priv->systemd_proxy, &can_restart, &error);
-+    	else
- #endif
-+		/* check with ConsoleKit we can restart */
-+		ret = egg_console_kit_can_restart (priv->console_kit, &can_restart, &error);
-+
- 	if (!ret) {
- 		g_warning ("cannot get consolekit CanRestart data: %s", error->message);
- 		g_error_free (error);
-@@ -768,10 +771,12 @@
- 	gtk_init (&argc, &argv);
- 	priv = g_new0 (GpkDistroUpgradePrivate, 1);
- #ifdef HAVE_SYSTEMD
--        priv->systemd_proxy = systemd_proxy_new ();
--#else
--	priv->console_kit = egg_console_kit_new ();
-+	if (sd_booted () > 0)
-+    		priv->systemd_proxy = systemd_proxy_new ();
-+    	else
- #endif
-+		priv->console_kit = egg_console_kit_new ();
-+
- 	priv->cancellable = g_cancellable_new ();
- 	priv->client = pk_client_new ();
- 	g_object_set (priv->client,
-@@ -807,10 +812,12 @@
- 	g_object_unref (priv->cancellable);
- 	g_object_unref (priv->client);
- #ifdef HAVE_SYSTEMD
--        systemd_proxy_free (priv->systemd_proxy);
--#else
--	g_object_unref (priv->console_kit);
-+	if (priv->systemd_proxy != NULL)
-+    		systemd_proxy_free (priv->systemd_proxy);
-+    	else
- #endif
-+		g_object_unref (priv->console_kit);
-+
- 	g_free (priv);
-         if (application)
-                 g_object_unref (application);
-diff -urN gnome-packagekit-3.6.0/src/gpk-update-viewer.c gnome-packagekit-3.6.0.new/src/gpk-update-viewer.c
---- gnome-packagekit-3.6.0/src/gpk-update-viewer.c	2012-07-12 10:01:38.000000000 +0200
-+++ gnome-packagekit-3.6.0.new/src/gpk-update-viewer.c	2012-10-09 14:03:49.276526624 +0200
-@@ -33,10 +33,10 @@
+ if WITH_SYSTEMD
+--- gnome-packagekit-3.14.2/src/gpk-update-viewer.c.orig	2014-10-07 09:53:09.000000000 +0200
++++ gnome-packagekit-3.14.2/src/gpk-update-viewer.c	2015-03-22 21:50:12.853724854 +0100
+@@ -33,8 +33,10 @@
  #include "egg-string.h"
  #include "egg-markdown.h"
  #ifdef HAVE_SYSTEMD
 +#include <systemd/sd-daemon.h>
  #include "systemd-proxy.h"
--#else
--#include "egg-console-kit.h"
  #endif
 +#include "egg-console-kit.h"
  
  #include "gpk-cell-renderer-info.h"
  #include "gpk-cell-renderer-restart.h"
-@@ -63,9 +63,8 @@
- static	PkRestartEnum		 restart_worst = 0;
+@@ -61,6 +63,7 @@
  #ifdef HAVE_SYSTEMD
- static  SystemdProxy            *proxy = NULL;
--#else
--static	EggConsoleKit		*console = NULL;
+ static  SystemdProxy		*proxy = NULL;
  #endif
 +static	EggConsoleKit		*console = NULL;
  static	EggMarkdown		*markdown = NULL;
  static	GCancellable		*cancellable = NULL;
  static	GSettings		*settings = NULL;
-@@ -249,10 +248,11 @@
+@@ -245,10 +248,11 @@
  	if (restart_update == PK_RESTART_ENUM_SYSTEM ||
  	    restart_update == PK_RESTART_ENUM_SECURITY_SYSTEM) {
  #ifdef HAVE_SYSTEMD
--                systemd_proxy_can_restart (proxy, &show_button, NULL);
+-		systemd_proxy_can_restart (proxy, &show_button, NULL);
 -#else
--		egg_console_kit_can_restart (console, &show_button, NULL);
+-		show_button = FALSE;
 +		if (proxy != NULL)
 +            		systemd_proxy_can_restart (proxy, &show_button, NULL);
 +            	else
@@ -145,31 +58,32 @@ diff -urN gnome-packagekit-3.6.0/src/gpk-update-viewer.c gnome-packagekit-3.6.0.
  	}
  
  	/* only show the button if we can do the action */
-@@ -273,11 +273,13 @@
+@@ -269,13 +274,18 @@
  	/* do the action */
- 	if (restart_update == PK_RESTART_ENUM_SYSTEM)
+ 	if (restart_update == PK_RESTART_ENUM_SYSTEM) {
  #ifdef HAVE_SYSTEMD
--                ret = systemd_proxy_restart (proxy, &error);
--#else
--		/* use consolekit to restart */
--		ret = egg_console_kit_restart (console, &error);
+-		ret = systemd_proxy_restart (proxy, &error);
 +		if (proxy != NULL)
 +            		ret = systemd_proxy_restart (proxy, &error);
 +            	else
- #endif
++#endif
 +			/* use consolekit to restart */
 +			ret = egg_console_kit_restart (console, &error);
 +
  		if (!ret) {
  			/* TRANSLATORS: the PackageKit request did not complete, and it did not send an error */
  			gpk_update_viewer_error_dialog (_("Could not restart"), NULL, error->message);
-@@ -3238,10 +3240,12 @@
+ 			g_error_free (error);
+ 		}
+-#endif
+ 	} else if (restart_update == PK_RESTART_ENUM_SESSION) {
+ 		GpkSession *session;
+ 		session = gpk_session_new ();
+@@ -3215,8 +3225,12 @@
  
  	settings = g_settings_new (GPK_SETTINGS_SCHEMA);
  #ifdef HAVE_SYSTEMD
--        proxy = systemd_proxy_new ();
--#else
--	console = egg_console_kit_new ();
+-	proxy = systemd_proxy_new ();
 +	if (sd_booted () > 0)
 +    		proxy = systemd_proxy_new ();
 +    	else
@@ -179,37 +93,442 @@ diff -urN gnome-packagekit-3.6.0/src/gpk-update-viewer.c gnome-packagekit-3.6.0.
  	cancellable = g_cancellable_new ();
  	markdown = egg_markdown_new ();
  	egg_markdown_set_output (markdown, EGG_MARKDOWN_OUTPUT_PANGO);
-@@ -3484,10 +3488,9 @@
- #ifdef HAVE_SYSTEMD
-         if (proxy != NULL)
-                 systemd_proxy_free (proxy);
--#else
-+#endif
- 	if (console != NULL)
- 		g_object_unref (console);
--#endif
+@@ -3459,6 +3473,8 @@
+ 	if (proxy != NULL)
+ 		systemd_proxy_free (proxy);
+ #endif
++	if (console != NULL)
++		g_object_unref (console);
  	if (control != NULL)
  		g_object_unref (control);
  	if (settings != NULL)
-diff -urN gnome-packagekit-3.6.0/src/Makefile.am gnome-packagekit-3.6.0.new/src/Makefile.am
---- gnome-packagekit-3.6.0/src/Makefile.am	2012-05-15 14:44:47.000000000 +0200
-+++ gnome-packagekit-3.6.0.new/src/Makefile.am	2012-10-09 13:59:32.313986610 +0200
-@@ -87,16 +87,14 @@
- 	gpk-task.h					\
- 	gpk-error.c					\
- 	gpk-error.h					\
-+	egg-console-kit.c				\
-+	egg-console-kit.h				\
- 	$(NULL)
- 
- if WITH_SYSTEMD
- libgpkshared_a_SOURCES +=				\
- 	systemd-proxy.c					\
- 	systemd-proxy.h
--else
--libgpkshared_a_SOURCES +=				\
--	egg-console-kit.c				\
--	egg-console-kit.h
- endif
- 
- shared_LIBS =						\
+diff -urN gnome-packagekit-3.14.2/src/egg-console-kit.c gnome-packagekit-3.10.1/src/egg-console-kit.c
+--- gnome-packagekit-3.14.2/src/egg-console-kit.c	1970-01-01 01:00:00.000000000 +0100
++++ gnome-packagekit-3.10.1/src/egg-console-kit.c	2013-08-23 10:08:08.000000000 +0200
+@@ -0,0 +1,351 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
++ *
++ * Copyright (C) 2006-2008 Richard Hughes <richard at hughsie.com>
++ *
++ * Licensed under the GNU General Public License Version 2
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY 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, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++ */
++
++#include "config.h"
++
++#include <string.h>
++#include <unistd.h>
++#include <stdio.h>
++#include <glib.h>
++#include <dbus/dbus-glib.h>
++#include <dbus/dbus.h>
++
++#include "egg-console-kit.h"
++
++static void     egg_console_kit_finalize	(GObject		*object);
++
++#define EGG_CONSOLE_KIT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_CONSOLE_KIT, EggConsoleKitPrivate))
++
++#define CONSOLEKIT_NAME			"org.freedesktop.ConsoleKit"
++#define CONSOLEKIT_PATH			"/org/freedesktop/ConsoleKit"
++#define CONSOLEKIT_INTERFACE		"org.freedesktop.ConsoleKit"
++
++#define CONSOLEKIT_MANAGER_PATH	 	"/org/freedesktop/ConsoleKit/Manager"
++#define CONSOLEKIT_MANAGER_INTERFACE    "org.freedesktop.ConsoleKit.Manager"
++#define CONSOLEKIT_SEAT_INTERFACE       "org.freedesktop.ConsoleKit.Seat"
++#define CONSOLEKIT_SESSION_INTERFACE    "org.freedesktop.ConsoleKit.Session"
++
++struct EggConsoleKitPrivate
++{
++	DBusGConnection		*connection;
++	DBusGProxy		*proxy_manager;
++	DBusGProxy		*proxy_session;
++	gchar			*session_id;
++};
++
++enum {
++	EGG_CONSOLE_KIT_ACTIVE_CHANGED,
++	EGG_CONSOLE_KIT_LAST_SIGNAL
++};
++
++static guint signals [EGG_CONSOLE_KIT_LAST_SIGNAL] = { 0 };
++G_DEFINE_TYPE (EggConsoleKit, egg_console_kit, G_TYPE_OBJECT)
++
++/**
++ * egg_console_kit_restart:
++ **/
++gboolean
++egg_console_kit_restart (EggConsoleKit *console, GError **error)
++{
++	gboolean ret;
++	GError *error_local = NULL;
++
++	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
++	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
++
++	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Restart", &error_local,
++				 G_TYPE_INVALID, G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("Couldn't restart: %s", error_local->message);
++		g_set_error (error, 1, 0, "%s", error_local->message);
++		g_error_free (error_local);
++	}
++	return ret;
++}
++
++/**
++ * egg_console_kit_stop:
++ **/
++gboolean
++egg_console_kit_stop (EggConsoleKit *console, GError **error)
++{
++	gboolean ret;
++	GError *error_local = NULL;
++
++	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
++	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
++
++	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Stop", &error_local,
++				 G_TYPE_INVALID, G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("Couldn't stop: %s", error_local->message);
++		g_set_error (error, 1, 0, "%s", error_local->message);
++		g_error_free (error_local);
++	}
++	return ret;
++}
++
++/**
++ * egg_console_kit_can_stop:
++ **/
++gboolean
++egg_console_kit_can_stop (EggConsoleKit *console, gboolean *can_stop, GError **error)
++{
++	gboolean ret;
++	GError *error_local = NULL;
++
++	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
++	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
++
++	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanStop", &error_local,
++				 G_TYPE_INVALID,
++				 G_TYPE_BOOLEAN, can_stop, G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("Couldn't do CanStop: %s", error_local->message);
++		g_set_error (error, 1, 0, "%s", error_local->message);
++		g_error_free (error_local);
++		/* CanStop was only added in new versions of ConsoleKit,
++		 * so assume true if this failed */
++		*can_stop = TRUE;
++	}
++	return ret;
++}
++
++/**
++ * egg_console_kit_can_restart:
++ **/
++gboolean
++egg_console_kit_can_restart (EggConsoleKit *console, gboolean *can_restart, GError **error)
++{
++	gboolean ret;
++	GError *error_local = NULL;
++
++	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
++	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
++
++	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanRestart", &error_local,
++				 G_TYPE_INVALID,
++				 G_TYPE_BOOLEAN, can_restart, G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("Couldn't do CanRestart: %s", error_local->message);
++		g_set_error (error, 1, 0, "%s", error_local->message);
++		g_error_free (error_local);
++		/* CanRestart was only added in new versions of ConsoleKit,
++		 * so assume true if this failed */
++		*can_restart = TRUE;
++	}
++	return ret;
++}
++
++/**
++ * egg_console_kit_is_local:
++ *
++ * Return value: Returns whether the session is local
++ **/
++gboolean
++egg_console_kit_is_local (EggConsoleKit *console)
++{
++	gboolean ret = FALSE;
++	gboolean value = FALSE;
++	GError *error = NULL;
++
++	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
++
++	/* maybe console kit does not know about our session */
++	if (console->priv->proxy_session == NULL) {
++		g_warning ("no ConsoleKit session");
++		goto out;
++	}
++
++	/* is our session local */
++	ret = dbus_g_proxy_call (console->priv->proxy_session, "IsLocal", &error, G_TYPE_INVALID,
++				 G_TYPE_BOOLEAN, &value, G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("IsLocal failed: %s", error->message);
++		g_error_free (error);
++		goto out;
++	}
++
++	/* return value only if we successed */
++	ret = value;
++out:
++	return ret;
++}
++
++/**
++ * egg_console_kit_is_active:
++ *
++ * Return value: Returns whether the session is active on the Seat that it is attached to.
++ **/
++gboolean
++egg_console_kit_is_active (EggConsoleKit *console)
++{
++	gboolean ret = FALSE;
++	gboolean value = FALSE;
++	GError *error = NULL;
++
++	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
++
++	/* maybe console kit does not know about our session */
++	if (console->priv->proxy_session == NULL) {
++		g_warning ("no ConsoleKit session");
++		goto out;
++	}
++
++	/* is our session active */
++	ret = dbus_g_proxy_call (console->priv->proxy_session, "IsActive", &error, G_TYPE_INVALID,
++				 G_TYPE_BOOLEAN, &value, G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("IsActive failed: %s", error->message);
++		g_error_free (error);
++		goto out;
++	}
++
++	/* return value only if we successed */
++	ret = value;
++out:
++	return ret;
++}
++
++/**
++ * egg_console_kit_active_changed_cb:
++ **/
++static void
++egg_console_kit_active_changed_cb (DBusGProxy *proxy, gboolean active, EggConsoleKit *console)
++{
++	g_debug ("emitting active: %i", active);
++	g_signal_emit (console, signals [EGG_CONSOLE_KIT_ACTIVE_CHANGED], 0, active);
++}
++
++/**
++ * egg_console_kit_class_init:
++ * @klass: The EggConsoleKitClass
++ **/
++static void
++egg_console_kit_class_init (EggConsoleKitClass *klass)
++{
++	GObjectClass *object_class = G_OBJECT_CLASS (klass);
++	object_class->finalize = egg_console_kit_finalize;
++	g_type_class_add_private (klass, sizeof (EggConsoleKitPrivate));
++	signals [EGG_CONSOLE_KIT_ACTIVE_CHANGED] =
++		g_signal_new ("active-changed",
++			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
++			      G_STRUCT_OFFSET (EggConsoleKitClass, active_changed),
++			      NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
++			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
++}
++
++/**
++ * egg_console_kit_init:
++ **/
++static void
++egg_console_kit_init (EggConsoleKit *console)
++{
++	gboolean ret;
++	GError *error = NULL;
++	guint32 pid;
++
++	console->priv = EGG_CONSOLE_KIT_GET_PRIVATE (console);
++	console->priv->proxy_manager = NULL;
++	console->priv->session_id = NULL;
++
++	/* connect to D-Bus */
++	console->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
++	if (console->priv->connection == NULL) {
++		g_warning ("Failed to connect to the D-Bus daemon: %s", error->message);
++		g_error_free (error);
++		goto out;
++	}
++
++	/* connect to ConsoleKit */
++	console->priv->proxy_manager =
++		dbus_g_proxy_new_for_name (console->priv->connection, CONSOLEKIT_NAME,
++					   CONSOLEKIT_MANAGER_PATH, CONSOLEKIT_MANAGER_INTERFACE);
++	if (console->priv->proxy_manager == NULL) {
++		g_warning ("cannot connect to ConsoleKit");
++		goto out;
++	}
++
++	/* get the session we are running in */
++	pid = getpid ();
++	ret = dbus_g_proxy_call (console->priv->proxy_manager, "GetSessionForUnixProcess", &error,
++				 G_TYPE_UINT, pid,
++				 G_TYPE_INVALID,
++				 DBUS_TYPE_G_OBJECT_PATH, &console->priv->session_id,
++				 G_TYPE_INVALID);
++	if (!ret) {
++		g_warning ("Failed to get session for pid %i: %s", pid, error->message);
++		g_error_free (error);
++		goto out;
++	}
++	g_debug ("ConsoleKit session ID: %s", console->priv->session_id);
++
++	/* connect to session */
++	console->priv->proxy_session =
++		dbus_g_proxy_new_for_name (console->priv->connection, CONSOLEKIT_NAME,
++					   console->priv->session_id, CONSOLEKIT_SESSION_INTERFACE);
++	if (console->priv->proxy_session == NULL) {
++		g_warning ("cannot connect to: %s", console->priv->session_id);
++		goto out;
++	}
++	dbus_g_proxy_add_signal (console->priv->proxy_session, "ActiveChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
++	dbus_g_proxy_connect_signal (console->priv->proxy_session, "ActiveChanged",
++				     G_CALLBACK (egg_console_kit_active_changed_cb), console, NULL);
++
++out:
++	return;
++}
++
++/**
++ * egg_console_kit_finalize:
++ * @object: The object to finalize
++ **/
++static void
++egg_console_kit_finalize (GObject *object)
++{
++	EggConsoleKit *console;
++
++	g_return_if_fail (EGG_IS_CONSOLE_KIT (object));
++
++	console = EGG_CONSOLE_KIT (object);
++
++	g_return_if_fail (console->priv != NULL);
++	if (console->priv->proxy_manager != NULL)
++		g_object_unref (console->priv->proxy_manager);
++	if (console->priv->proxy_session != NULL)
++		g_object_unref (console->priv->proxy_session);
++	g_free (console->priv->session_id);
++
++	G_OBJECT_CLASS (egg_console_kit_parent_class)->finalize (object);
++}
++
++/**
++ * egg_console_kit_new:
++ *
++ * Return value: a new EggConsoleKit object.
++ **/
++EggConsoleKit *
++egg_console_kit_new (void)
++{
++	EggConsoleKit *console;
++	console = g_object_new (EGG_TYPE_CONSOLE_KIT, NULL);
++	return EGG_CONSOLE_KIT (console);
++}
+diff -urN gnome-packagekit-3.14.2/src/egg-console-kit.h gnome-packagekit-3.10.1/src/egg-console-kit.h
+--- gnome-packagekit-3.14.2/src/egg-console-kit.h	1970-01-01 01:00:00.000000000 +0100
++++ gnome-packagekit-3.10.1/src/egg-console-kit.h	2011-07-04 18:05:18.000000000 +0200
+@@ -0,0 +1,71 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
++ *
++ * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
++ *
++ * Licensed under the GNU General Public License Version 2
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY 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, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++ */
++
++#ifndef __EGG_CONSOLE_KIT_H
++#define __EGG_CONSOLE_KIT_H
++
++#include <glib-object.h>
++
++G_BEGIN_DECLS
++
++#define EGG_TYPE_CONSOLE_KIT		(egg_console_kit_get_type ())
++#define EGG_CONSOLE_KIT(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_CONSOLE_KIT, EggConsoleKit))
++#define EGG_CONSOLE_KIT_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_CONSOLE_KIT, EggConsoleKitClass))
++#define EGG_IS_CONSOLE_KIT(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_CONSOLE_KIT))
++#define EGG_IS_CONSOLE_KIT_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_CONSOLE_KIT))
++#define EGG_CONSOLE_KIT_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_CONSOLE_KIT, EggConsoleKitClass))
++#define EGG_CONSOLE_KIT_ERROR		(egg_console_kit_error_quark ())
++#define EGG_CONSOLE_KIT_TYPE_ERROR	(egg_console_kit_error_get_type ())
++
++typedef struct EggConsoleKitPrivate EggConsoleKitPrivate;
++
++typedef struct
++{
++	 GObject		 parent;
++	 EggConsoleKitPrivate	*priv;
++} EggConsoleKit;
++
++typedef struct
++{
++	GObjectClass	parent_class;
++	void		(* active_changed)		(EggConsoleKit	*console,
++							 gboolean	 active);
++} EggConsoleKitClass;
++
++GType		 egg_console_kit_get_type	  	(void);
++EggConsoleKit	*egg_console_kit_new			(void);
++gboolean	 egg_console_kit_is_local		(EggConsoleKit	*console);
++gboolean	 egg_console_kit_is_active		(EggConsoleKit	*console);
++gboolean	 egg_console_kit_stop			(EggConsoleKit	*console,
++							 GError		**error);
++gboolean	 egg_console_kit_restart		(EggConsoleKit	*console,
++							 GError		**error);
++gboolean	 egg_console_kit_can_stop		(EggConsoleKit	*console,
++							 gboolean	*can_stop,
++							 GError		**error);
++gboolean	 egg_console_kit_can_restart		(EggConsoleKit	*console,
++							 gboolean	*can_restart,
++							 GError		**error);
++
++G_END_DECLS
++
++#endif /* __EGG_CONSOLE_KIT_H */
++
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gnome-packagekit.git/commitdiff/c4d5c1a74f63767490b226e41510a4cb8e87a59d



More information about the pld-cvs-commit mailing list