[packages/NetworkManager] Update to 0.9.8.0

megabajt megabajt at pld-linux.org
Thu Feb 21 16:11:53 CET 2013


commit d7d26b92f430a261059aab0ea3e32abb18fffa8c
Author: Marcin Banasiak <marcin.banasiak at gmail.com>
Date:   Thu Feb 21 15:57:18 2013 +0100

    Update to 0.9.8.0
    
    - -pld.patch is no longer needed
    - systemd-fallback.patch: updated and added fallback to upower in
      sleep-monitor
    - ConsoleKit-x11 is not required when using systemd

 NetworkManager-pld.patch | 243 -----------------------------------------------
 NetworkManager.init      |  75 +++++++++++++++
 NetworkManager.spec      |  44 +++++----
 systemd-fallback.patch   | 129 ++++++++++++++++++++++---
 4 files changed, 216 insertions(+), 275 deletions(-)
---
diff --git a/NetworkManager.spec b/NetworkManager.spec
index 1ff23ed..ef227a7 100644
--- a/NetworkManager.spec
+++ b/NetworkManager.spec
@@ -7,21 +7,21 @@
 Summary:	Network Manager for GNOME
 Summary(pl.UTF-8):	Zarządca sieci dla GNOME
 Name:		NetworkManager
-Version:	0.9.6.4
-Release:	3
+Version:	0.9.8.0
+Release:	1
 Epoch:		2
 License:	GPL v2+
 Group:		Networking/Admin
 Source0:	http://ftp.gnome.org/pub/GNOME/sources/NetworkManager/0.9/%{name}-%{version}.tar.xz
-# Source0-md5:	54ca5200edeb5155086ced43d00b0cad
+# Source0-md5:	38d28f6bd9220d85dfff47210706195c
 Source1:	%{name}.conf
 Source2:	%{name}.upstart
 Source3:	%{name}.tmpfiles
-Patch0:		%{name}-pld.patch
-Patch1:		ifcfg-path.patch
-Patch2:		systemd-fallback.patch
-Patch3:		llh340.patch
-Patch4:		11-initialize-nm-remote-settings.patch
+Source4:	%{name}.init
+Patch0:		ifcfg-path.patch
+Patch1:		systemd-fallback.patch
+Patch2:		llh340.patch
+Patch3:		11-initialize-nm-remote-settings.patch
 URL:		http://projects.gnome.org/NetworkManager/
 BuildRequires:	autoconf >= 2.63
 BuildRequires:	automake >= 1:1.10
@@ -35,7 +35,7 @@ BuildRequires:	gtk-doc >= 1.0
 BuildRequires:	gtk-doc-automake >= 1.0
 BuildRequires:	intltool >= 0.40.0
 BuildRequires:	libiw-devel >= 1:28-0.pre9.1
-BuildRequires:	libnl-devel >= 3.0
+BuildRequires:	libnl-devel >= 3.2.7
 BuildRequires:	libsoup-devel >= 2.26.0
 BuildRequires:	libtool >= 2:2.2
 BuildRequires:	libuuid-devel
@@ -46,17 +46,21 @@ BuildRequires:	ppp-plugin-devel >= 3:2.4.5
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.629
 BuildRequires:	sed >= 4.0
-%{?with_systemd:BuildRequires:	systemd-devel}
+%{?with_systemd:BuildRequires:	systemd-devel >= 183}
 BuildRequires:	tar >= 1:1.22
 BuildRequires:	udev-devel
-BuildRequires:	udev-glib-devel >= 1:147
+BuildRequires:	udev-glib-devel >= 1:165
 %{?with_vala:BuildRequires:	vala >= 2:0.17.1.24}
 %{?with_wimax:BuildRequires:	wimax-devel >= 1.5.1}
 BuildRequires:	xz
 Requires(post,preun):	/sbin/chkconfig
 Requires(post,preun,postun):	systemd-units >= 38
 Requires:	%{name}-libs = %{epoch}:%{version}-%{release}
+%if %{with systemd}
+Suggests:	ConsoleKit-x11
+%else
 Requires:	ConsoleKit-x11
+%endif
 Requires:	dhcp-client
 Requires:	filesystem >= 3.0-37
 Requires:	polkit >= 0.97
@@ -98,7 +102,7 @@ Group:		Libraries
 Requires:	dbus-glib >= 0.94
 Requires:	glib2 >= 1:2.24.0
 Requires:	nss >= 3.11
-Requires:	udev-glib >= 1:147
+Requires:	udev-glib >= 1:165
 Conflicts:	NetworkManager < 0.6.4-0.2
 
 %description libs
@@ -116,7 +120,7 @@ Requires:	dbus-glib-devel >= 0.94
 Requires:	glib2-devel >= 1:2.24.0
 Requires:	libuuid-devel
 Requires:	nss-devel >= 3.11
-Requires:	udev-glib-devel >= 1:147
+Requires:	udev-glib-devel >= 1:165
 
 %description devel
 Network Manager includes and more.
@@ -152,10 +156,9 @@ API języka Vala do bibliotek NetworkManagera.
 %prep
 %setup -q
 %patch0 -p1
-%patch1 -p1
-%{?with_systemd:%patch2 -p1}
+%{?with_systemd:%patch1 -p1}
+%patch2 -p1
 %patch3 -p1
-%patch4 -p1
 
 %build
 %{__gtkdocize}
@@ -168,13 +171,14 @@ API języka Vala do bibliotek NetworkManagera.
 %configure \
 	--disable-silent-rules \
 	--with-html-dir=%{_gtkdocdir} \
-	--with-distro=pld \
+	--enable-ifcfg-rh \
 	--enable-more-warnings=yes \
 	--with-dhclient=/sbin/dhclient \
 	--with-iptables=/usr/sbin/iptables \
 	--with-system-ca-path=/etc/certs \
 	--with-systemdsystemunitdir=%{systemdunitdir} \
 	--with-session-tracking=%{?with_systemd:systemd}%{!?with_systemd:ck} \
+	--with-suspend-resume=%{?with_systemd:systemd}%{!?with_systemd:upower} \
 	--with-pppd-plugin-dir=%{_libdir}/pppd/plugins \
 	--with-dist-version=%{version}-%{release} \
 	--with-docs \
@@ -192,6 +196,8 @@ install -d $RPM_BUILD_ROOT{/etc/rc.d/init.d,/var/run/%{name},%{systemdtmpfilesdi
 %{__make} install \
 	DESTDIR=$RPM_BUILD_ROOT
 
+install -p %{SOURCE4} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+
 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
 
 install -d $RPM_BUILD_ROOT/etc/init
@@ -257,7 +263,6 @@ exit 0
 %attr(755,root,root) %{_libexecdir}/nm-avahi-autoipd.action
 %attr(755,root,root) %{_libexecdir}/nm-dhcp-client.action
 %attr(755,root,root) %{_libexecdir}/nm-dispatcher.action
-%attr(755,root,root) %{_libexecdir}/nm-crash-logger
 %attr(755,root,root) %{_libdir}/pppd/plugins/nm-pppd-plugin.so
 %attr(754,root,root) /etc/rc.d/init.d/NetworkManager
 %config(noreplace) %verify(not md5 mtime size) /etc/init/NetworkManager.conf
@@ -265,8 +270,6 @@ exit 0
 %{systemdunitdir}/NetworkManager-wait-online.service
 %{_datadir}/dbus-1/system-services/org.freedesktop.NetworkManager.service
 %{systemdtmpfilesdir}/%{name}.conf
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}/gdb-cmd
 %{_datadir}/dbus-1/system-services/org.freedesktop.nm_dispatcher.service
 %{_datadir}/polkit-1/actions/org.freedesktop.NetworkManager.policy
 /lib/udev/rules.d/77-nm-olpc-mesh.rules
@@ -283,6 +286,7 @@ exit 0
 %{_mandir}/man1/nm-online.1*
 %{_mandir}/man1/nm-tool.1*
 %{_mandir}/man1/nmcli.1*
+%{_mandir}/man5/nm-settings.5*
 %{_mandir}/man5/nm-system-settings.conf.5*
 %{_mandir}/man5/NetworkManager.conf.5*
 %{_mandir}/man8/NetworkManager.8*
diff --git a/NetworkManager-pld.patch b/NetworkManager-pld.patch
deleted file mode 100644
index 752ae9f..0000000
--- a/NetworkManager-pld.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -urN NetworkManager-0.9.4.0/configure.ac NetworkManager-0.9.4.0.new/configure.ac
---- NetworkManager-0.9.4.0/configure.ac	2012-03-23 21:11:15.000000000 +0100
-+++ NetworkManager-0.9.4.0.new/configure.ac	2012-03-24 11:29:26.057723008 +0100
-@@ -107,9 +107,10 @@
- dnl
- AC_C_BIGENDIAN
- 
--AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva, pardus, linexa, exherbo or lfs]))
-+AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva, pardus, linexa, exherbo, lfs or pld]))
- if test "z$with_distro" = "z"; then
- 	AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
-+	AC_CHECK_FILE(/etc/pld-release,with_distro="pld")
- 	AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
- 	AC_CHECK_FILE(/etc/fedora-release,with_distro="redhat")
- 	AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
-@@ -133,7 +134,7 @@
- 	exit 1
- else
- 	case $with_distro in
--		redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo|lfs|generic) ;;
-+		redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo|lfs|pld|generic) ;;
- 		*)
- 			echo "Your distribution (${with_distro}) is not yet supported!  (patches welcome)"
- 			exit 1
-@@ -205,6 +206,11 @@
-   AC_DEFINE(TARGET_EXHERBO, 1, [Define if you have Exherbo])
- fi
- 
-+AM_CONDITIONAL(TARGET_PLD, test x"$with_distro" = xpld)
-+if test x"$with_distro" = xpld; then
-+  AC_DEFINE(TARGET_PLD, 1, [Define if you have PLD])
-+fi  
-+
- dnl
- dnl Distribution version string
- dnl
-@@ -790,6 +796,8 @@
- initscript/paldo/NetworkManager
- initscript/Mandriva/Makefile
- initscript/Mandriva/networkmanager
-+initscript/PLD/Makefile
-+initscript/PLD/NetworkManager
- initscript/linexa/Makefile
- initscript/linexa/networkmanager
- introspection/Makefile
-diff -urN NetworkManager-0.9.4.0/initscript/Makefile.am NetworkManager-0.9.4.0.new/initscript/Makefile.am
---- NetworkManager-0.9.4.0/initscript/Makefile.am	2011-04-19 07:06:22.000000000 +0200
-+++ NetworkManager-0.9.4.0.new/initscript/Makefile.am	2012-03-24 11:25:37.842292690 +0100
-@@ -26,3 +26,6 @@
- if TARGET_LINEXA
- SUBDIRS += linexa
- endif
-+if TARGET_PLD
-+SUBDIRS += PLD
-+endif
-diff -urN NetworkManager-0.9.4.0/initscript/PLD/Makefile.am NetworkManager-0.9.4.0.new/initscript/PLD/Makefile.am
---- NetworkManager-0.9.4.0/initscript/PLD/Makefile.am	1970-01-01 01:00:00.000000000 +0100
-+++ NetworkManager-0.9.4.0.new/initscript/PLD/Makefile.am	2012-03-24 11:25:37.845626005 +0100
-@@ -0,0 +1,5 @@
-+EXTRA_DIST = NetworkManager
-+DISTCLEANFILES = NetworkManager
-+
-+initddir = $(sysconfdir)/rc.d/init.d
-+initd_SCRIPTS = NetworkManager
-diff -urN NetworkManager-0.9.4.0/initscript/PLD/NetworkManager.in NetworkManager-0.9.4.0.new/initscript/PLD/NetworkManager.in
---- NetworkManager-0.9.4.0/initscript/PLD/NetworkManager.in	1970-01-01 01:00:00.000000000 +0100
-+++ NetworkManager-0.9.4.0.new/initscript/PLD/NetworkManager.in	2012-03-24 11:25:37.845626005 +0100
-@@ -0,0 +1,75 @@
-+#!/bin/sh
-+#
-+# NetworkManager	NetworkManager daemon
-+#
-+# chkconfig:		345 99 01
-+#
-+# description:		This is a daemon for automatically switching network \
-+#			connections to the best available connection.
-+#
-+# processname:		NetworkManager
-+# pidfile:		/var/run/NetworkManager.pid
-+#
-+
-+# Source function library.
-+. /etc/rc.d/init.d/functions
-+
-+upstart_controlled
-+
-+# Source networking configuration.
-+. /etc/sysconfig/network
-+
-+# Check that networking is up.
-+if is_yes "${NETWORKING}"; then
-+	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
-+		msg_network_down NetworkManager
-+		exit 1
-+	fi
-+else
-+	exit 0
-+fi
-+
-+start() {
-+	# Check if the service is already running?
-+	if [ ! -f /var/lock/subsys/NetworkManager ]; then
-+		msg_starting NetworkManager
-+		daemon NetworkManager --pid-file=/var/run/NetworkManager.pid
-+		RETVAL=$?
-+		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/NetworkManager
-+	else
-+		msg_already_running NetworkManager
-+	fi
-+}
-+stop() {
-+	if [ -f /var/lock/subsys/NetworkManager ]; then
-+		# Stop daemons.
-+		msg_stopping NetworkManager
-+		killproc NetworkManager
-+		rm -f /var/lock/subsys/NetworkManager
-+	else
-+		msg_not_running NetworkManager
-+	fi
-+}
-+
-+RETVAL=0
-+case "$1" in
-+  start)
-+	start
-+	;;
-+  stop)
-+	stop
-+	;;
-+  restart)
-+	stop
-+	start
-+	;;
-+  status)
-+	status NetworkManager
-+	RETVAL=$?
-+	;;
-+  *)
-+	msg_usage "$0 {start|stop|restart|status}"
-+	exit 3
-+esac
-+	        
-+exit $RETVAL
-diff -urN NetworkManager-0.9.4.0/src/backends/Makefile.am NetworkManager-0.9.4.0.new/src/backends/Makefile.am
---- NetworkManager-0.9.4.0/src/backends/Makefile.am	2012-02-27 16:57:16.000000000 +0100
-+++ NetworkManager-0.9.4.0.new/src/backends/Makefile.am	2012-03-24 11:30:34.634018164 +0100
-@@ -64,6 +64,10 @@
- libnmbackend_la_SOURCES += NetworkManagerExherbo.c
- endif
- 
-+if TARGET_PLD
-+libnmbackend_la_SOURCES += NetworkManagerPLD.c
-+endif
-+
- libnmbackend_la_LIBADD += \
- 	$(top_builddir)/src/logging/libnm-logging.la \
- 	$(LIBNL_LIBS) \
-diff -urN NetworkManager-0.9.4.0/src/backends/NetworkManagerPLD.c NetworkManager-0.9.4.0.new/src/backends/NetworkManagerPLD.c
---- NetworkManager-0.9.4.0/src/backends/NetworkManagerPLD.c	1970-01-01 01:00:00.000000000 +0100
-+++ NetworkManager-0.9.4.0.new/src/backends/NetworkManagerPLD.c	2012-03-24 11:46:34.925482485 +0100
-@@ -0,0 +1,68 @@
-+/* NetworkManager -- Network link manager
-+ *
-+ * Patryk Zawadzki <patrys at pld-linux.org>
-+ *
-+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+ *
-+ * (C) Copyright 2004 RedHat, Inc.
-+ * (C) Copyright 2004 Narayan Newton
-+ * (C) Copyright 2005 wrobell <wrobell at pld-linux.org>
-+ * (C) Copyright 2007, 2012 Marcin Banasiak <megabajt at pld-linux.org>
-+ * (C) Copyright 2005-2008 Patryk Zawadzki <patrys at pld-linux.org>
-+ */
-+
-+#ifdef HAVE_CONFIG_H
-+#include <config.h>
-+#endif
-+
-+#include "NetworkManagerGeneric.h"
-+#include "NetworkManagerUtils.h"
-+
-+/*
-+ * nm_backend_enable_loopback
-+ *
-+ * Bring up the loopback interface
-+ *
-+ */
-+void nm_backend_enable_loopback (void)
-+{
-+	nm_generic_enable_loopback ();
-+}
-+
-+/*
-+ * nm_backend_update_dns
-+ *
-+ * Invalidate the nscd host cache, if it exists, since
-+ * we changed resolv.conf.
-+ *
-+ */
-+void nm_backend_update_dns (void)
-+{
-+	if (g_file_test ("/usr/sbin/nscd", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE | G_FILE_TEST_IS_REGULAR)) {
-+		nm_spawn_process ("/usr/sbin/nscd -i hosts");
-+	}
-+}
-+
-+/*
-+ * nm_backend_ipv6_use_tempaddr
-+ *
-+ * Get net.ipv6.conf.default.use_tempaddr from /etc/sysctl.conf or
-+ * /lib/sysctl.d/sysctl.conf
-+ *
-+ */
-+int nm_backend_ipv6_use_tempaddr (void)
-+{
-+	return nm_generic_ipv6_use_tempaddr ();
-+}
-diff -urN NetworkManager-0.9.4.0/src/settings/plugins/Makefile.am NetworkManager-0.9.4.0.new/src/settings/plugins/Makefile.am
---- NetworkManager-0.9.4.0/src/settings/plugins/Makefile.am	2012-02-08 17:44:53.000000000 +0100
-+++ NetworkManager-0.9.4.0.new/src/settings/plugins/Makefile.am	2012-03-24 11:25:37.845626005 +0100
-@@ -4,6 +4,10 @@
- SUBDIRS+=ifcfg-rh
- endif
- 
-+if TARGET_PLD
-+SUBDIRS+=ifcfg-rh
-+endif
-+
- if TARGET_SUSE
- SUBDIRS+=ifcfg-suse
- endif
diff --git a/NetworkManager.init b/NetworkManager.init
new file mode 100644
index 0000000..c0be336
--- /dev/null
+++ b/NetworkManager.init
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# NetworkManager	NetworkManager daemon
+#
+# chkconfig:		345 99 01
+#
+# description:		This is a daemon for automatically switching network \
+#			connections to the best available connection.
+#
+# processname:		NetworkManager
+# pidfile:		/var/run/NetworkManager.pid
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+upstart_controlled
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+		msg_network_down NetworkManager
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+start() {
+	# Check if the service is already running?
+	if [ ! -f /var/lock/subsys/NetworkManager ]; then
+		msg_starting NetworkManager
+		daemon NetworkManager --pid-file=/var/run/NetworkManager.pid
+		RETVAL=$?
+		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/NetworkManager
+	else
+		msg_already_running NetworkManager
+	fi
+}
+stop() {
+	if [ -f /var/lock/subsys/NetworkManager ]; then
+		# Stop daemons.
+		msg_stopping NetworkManager
+		killproc NetworkManager
+		rm -f /var/lock/subsys/NetworkManager
+	else
+		msg_not_running NetworkManager
+	fi
+}
+
+RETVAL=0
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  status)
+	status NetworkManager
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|status}"
+	exit 3
+esac
+	        
+exit $RETVAL
diff --git a/systemd-fallback.patch b/systemd-fallback.patch
index cef24b0..f1651c0 100644
--- a/systemd-fallback.patch
+++ b/systemd-fallback.patch
@@ -1,15 +1,14 @@
-diff -u -Nr NetworkManager-0.9.3.995/configure.ac NetworkManager-0.9.3.995-systemd-fallback/configure.ac
---- NetworkManager-0.9.3.995/configure.ac	2012-03-02 01:05:21.000000000 +0100
-+++ NetworkManager-0.9.3.995-systemd-fallback/configure.ac	2012-03-06 16:55:58.294793902 +0100
-@@ -344,7 +344,7 @@
- case $with_session_tracking in
-     ck|none) ;;
-     systemd)
--        PKG_CHECK_MODULES(SYSTEMD, [libsystemd-login])
-+        PKG_CHECK_MODULES(SYSTEMD, [libsystemd-daemon libsystemd-login])
-         ;;
-     *)
- 	AC_MSG_ERROR(--with-session-tracking must be one of [none, ck, systemd])
+--- NetworkManager-0.9.8.0/configure.ac~	2013-02-21 14:04:19.582661393 +0100
++++ NetworkManager-0.9.8.0/configure.ac	2013-02-21 14:23:32.286416661 +0100
+@@ -283,7 +283,7 @@
+ AM_CONDITIONAL(SESSION_TRACKING_CK, test "$with_session_tracking" = "consolekit")
+ AM_CONDITIONAL(SESSION_TRACKING_SYSTEMD, test "xwith_session_tracking" = "systemd")
+ if test "$with_session_tracking" = "systemd"; then
+-	PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login])
++	PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-daemon libsystemd-login])
+ 	AC_SUBST(SYSTEMD_LOGIN_CFLAGS)
+ 	AC_SUBST(SYSTEMD_LOGIN_LIBS)
+ fi
 --- NetworkManager-0.9.6.4/src/nm-session-monitor-systemd.c.orig	2012-09-12 22:37:01.000000000 +0200
 +++ NetworkManager-0.9.6.4/src/nm-session-monitor-systemd.c	2012-11-01 08:58:24.084129513 +0100
 @@ -28,6 +28,10 @@
@@ -489,3 +488,109 @@ diff -u -Nr NetworkManager-0.9.3.995/configure.ac NetworkManager-0.9.3.995-syste
  	}
 -	return ret > 0 ? TRUE : FALSE;
  }
+
+--- NetworkManager-0.9.8.0/src/nm-sleep-monitor-systemd.c.new	2013-02-21 15:01:09.404910471 +0100
++++ NetworkManager-0.9.8.0/src/nm-sleep-monitor-systemd.c	2013-02-21 15:10:58.429453872 +0100
+@@ -25,6 +25,7 @@
+ #include <dbus/dbus-glib.h>
+ #include <gio/gio.h>
+ #include <gio/gunixfdlist.h>
++#include <systemd/sd-daemon.h>
+ 
+ #include "nm-logging.h"
+ #include "nm-dbus-manager.h"
+@@ -35,6 +36,8 @@
+ #define SD_PATH              "/org/freedesktop/login1"
+ #define SD_INTERFACE         "org.freedesktop.login1.Manager"
+ 
++#define UPOWER_DBUS_SERVICE "org.freedesktop.UPower"
++
+ /* Do we have GDBus (glib >= 2.26) and GUnixFDList (glib >= 2.30) support ? */
+ #if GLIB_CHECK_VERSION(2,30,0)
+ #define IS_GDBUS_UNIXFD_AVAILABLE 1
+@@ -50,6 +53,8 @@ struct _NMSleepMonitor {
+ 	DBusGProxy *sd_proxy;
+ #endif
+ 	gint inhibit_fd;
++	
++	DBusGProxy *upower_proxy;
+ };
+ 
+ struct _NMSleepMonitorClass {
+@@ -71,6 +76,20 @@ G_DEFINE_TYPE (NMSleepMonitor, nm_sleep_
+ 
+ /********************************************************************/
+ 
++static void
++upower_sleeping_cb (DBusGProxy *proxy, gpointer user_data)
++{
++        nm_log_dbg (LOGD_SUSPEND, "Received UPower sleeping signal");
++        g_signal_emit (user_data, signals[SLEEPING], 0);
++}
++
++static void
++upower_resuming_cb (DBusGProxy *proxy, gpointer user_data)
++{
++        nm_log_dbg (LOGD_SUSPEND, "Received UPower resuming signal");
++        g_signal_emit (user_data, signals[RESUMING], 0);
++}
++
+ static gboolean
+ drop_inhibitor (NMSleepMonitor *self)
+ {
+@@ -304,9 +323,34 @@ sleep_setup (NMSleepMonitor *self)
+ static void
+ nm_sleep_monitor_init (NMSleepMonitor *self)
+ {
+-	self->inhibit_fd = -1;
+-	sleep_setup (self);
+-	take_inhibitor (self);
++	if (sd_booted () > 0) {
++		self->inhibit_fd = -1;
++		sleep_setup (self);
++		take_inhibitor (self);
++	} else {
++		NMDBusManager *dbus_mgr;
++		DBusGConnection *bus;
++
++		dbus_mgr = nm_dbus_manager_get ();
++        bus = nm_dbus_manager_get_connection (dbus_mgr);
++        self->upower_proxy = dbus_g_proxy_new_for_name (bus,
++                                                        UPOWER_DBUS_SERVICE,
++                                                        "/org/freedesktop/UPower",
++                                                        "org.freedesktop.UPower");
++        if (self->upower_proxy) {
++			dbus_g_proxy_add_signal (self->upower_proxy, "Sleeping", G_TYPE_INVALID);
++			dbus_g_proxy_connect_signal (self->upower_proxy, "Sleeping",
++										 G_CALLBACK (upower_sleeping_cb),
++										 self, NULL);
++
++			dbus_g_proxy_add_signal (self->upower_proxy, "Resuming", G_TYPE_INVALID);
++			dbus_g_proxy_connect_signal (self->upower_proxy, "Resuming",
++										 G_CALLBACK (upower_resuming_cb),
++										 self, NULL);
++        } else
++				nm_log_warn (LOGD_SUSPEND, "could not initialize UPower D-Bus proxy");
++        g_object_unref (dbus_mgr);
++	}
+ }
+ 
+ static void
+@@ -314,9 +358,14 @@ finalize (GObject *object)
+ {
+ 	NMSleepMonitor *self = NM_SLEEP_MONITOR (object);
+ 
+-	drop_inhibitor (self);
+-	if (self->sd_proxy)
+-		g_object_unref (self->sd_proxy);
++	if (sd_booted () > 0) {
++		drop_inhibitor (self);
++		if (self->sd_proxy)
++			g_object_unref (self->sd_proxy);
++	} else {
++		if (self->upower_proxy)
++			g_object_unref (self->upower_proxy);
++	}
+ 
+ 	if (G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize != NULL)
+ 		G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize (object);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/NetworkManager.git/commitdiff/d7d26b92f430a261059aab0ea3e32abb18fffa8c



More information about the pld-cvs-commit mailing list