Index: lib/Makefile.am
===================================================================
RCS file: /cvs/gnome/rhythmbox/lib/Makefile.am,v
retrieving revision 1.51
diff -u -p -r1.51 Makefile.am
--- lib/Makefile.am	24 Jun 2006 23:07:04 -0000	1.51
+++ lib/Makefile.am	6 Sep 2006 13:17:51 -0000
@@ -30,7 +30,9 @@ librb_la_SOURCES =					\
 	md5.c						\
 	md5.h						\
 	rb-proxy-config.c				\
-	rb-proxy-config.h
+	rb-proxy-config.h				\
+	rb-network-monitor.c				\
+	rb-network-monitor.h
 
 INCLUDES =						\
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"        \
@@ -42,6 +44,10 @@ INCLUDES =						\
 	$(WARN_CFLAGS)					\
 	$(SOUP_CFLAGS)					\
 	$(RHYTHMBOX_CFLAGS)
+
+if USE_NETWORK_MANAGER
+INCLUDES += $(NETWORK_MANAGER_CFLAGS)
+endif
 
 BUILT_SOURCES=
 
Index: podcast/rb-podcast-manager.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/podcast/rb-podcast-manager.c,v
retrieving revision 1.58
diff -u -p -r1.58 rb-podcast-manager.c
--- podcast/rb-podcast-manager.c	11 Aug 2006 07:36:53 -0000	1.58
+++ podcast/rb-podcast-manager.c	6 Sep 2006 13:17:50 -0000
@@ -42,6 +42,7 @@
 #include "rb-podcast-parse.h"
 #include "rb-dialog.h"
 #include "rb-metadata.h"
+#include "rb-network-monitor.h"
 
 #define CONF_STATE_PODCAST_PREFIX		CONF_PREFIX "/state/podcast"
 #define CONF_STATE_PODCAST_DOWNLOAD_DIR		CONF_STATE_PODCAST_PREFIX "/download_prefix"
@@ -51,7 +52,8 @@
 enum
 {
 	PROP_0,
-	PROP_DB
+	PROP_DB,
+	PROP_NETWORK_MONITOR
 };
 
 enum
@@ -81,6 +83,7 @@ typedef enum
 struct RBPodcastManagerPrivate
 {
 	RhythmDB *db;
+	RBNetworkMonitor *network_monitor;
 	GList *download_list;
 	guint next_time;
 	guint source_sync;
@@ -161,6 +164,9 @@ static void rb_podcast_manager_db_entry_
 static gboolean rb_podcast_manager_next_file 		(RBPodcastManager * pd);
 static void rb_podcast_manager_insert_feed 		(RBPodcastManager *pd, RBPodcastChannel *data);
 static void rb_podcast_manager_abort_subscribe 		(RBPodcastManager *pd);
+static void rb_podcast_manager_network_cb		(RBNetworkMonitor *monitor,
+							 GParamSpec *pspec,
+							 RBPodcastManager *pd);
 
 /* event loop */
 static gboolean rb_podcast_manager_event_loop		(RBPodcastManager *pd) ;
@@ -199,13 +205,20 @@ rb_podcast_manager_class_init (RBPodcast
 	object_class->set_property = rb_podcast_manager_set_property;
         object_class->get_property = rb_podcast_manager_get_property;
 
-	 g_object_class_install_property (object_class,
-                                          PROP_DB,
-                                          g_param_spec_object ("db",
-							       "db",
-							       "database",
-							       RHYTHMDB_TYPE,
-							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_DB,
+					 g_param_spec_object ("db",
+							      "db",
+							      "database",
+							      RHYTHMDB_TYPE,
+							      G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_NETWORK_MONITOR,
+					 g_param_spec_object ("network-monitor",
+							      "network-monitor",
+							      "network monitor",
+							      RB_TYPE_NETWORK_MONITOR,
+							      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
 	rb_podcast_manager_signals[STATUS_CHANGED] =
 	       g_signal_new ("status_changed",
@@ -363,6 +376,13 @@ rb_podcast_manager_set_property (GObject
 	                                 pd, G_CONNECT_SWAPPED);
 
 		break;
+	case PROP_NETWORK_MONITOR:
+		pd->priv->network_monitor = g_value_get_object (value);
+		g_signal_connect_object (G_OBJECT (pd->priv->network_monitor),
+					 "notify::network-available",
+					 G_CALLBACK (rb_podcast_manager_network_cb),
+					 pd, 0);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 	}
@@ -380,6 +400,9 @@ rb_podcast_manager_get_property (GObject
 	case PROP_DB:
 		g_value_set_object (value, pd->priv->db);
 		break;
+	case PROP_NETWORK_MONITOR:
+		g_value_set_object (value, pd->priv->network_monitor);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 	}
@@ -387,11 +410,14 @@ rb_podcast_manager_get_property (GObject
 }
 
 RBPodcastManager *
-rb_podcast_manager_new (RhythmDB *db)
+rb_podcast_manager_new (RhythmDB *db, RBNetworkMonitor *monitor)
 {
 	RBPodcastManager *pd;
 
-	pd = g_object_new (RB_TYPE_PODCAST_MANAGER, "db", db, NULL);
+	pd = g_object_new (RB_TYPE_PODCAST_MANAGER, 
+			   "db", db, 
+			   "network-monitor", monitor,
+			   NULL);
 	return pd;
 }
 
@@ -470,20 +498,29 @@ rb_podcast_manager_start_sync (RBPodcast
 		}
 		pd->priv->source_sync = g_timeout_add (next_time * 1000, (GSourceFunc ) rb_podcast_manager_sync_head_cb, pd);
 	}
-
 }
 
 static gboolean
 rb_podcast_manager_sync_head_cb (gpointer data)
 {
 	RBPodcastManager *pd = RB_PODCAST_MANAGER (data);
+	gboolean network;
 
 	GDK_THREADS_ENTER ();
 
-	rb_podcast_manager_update_feeds (pd);
-	pd->priv->source_sync = 0;
-	pd->priv->next_time = 0;
-	rb_podcast_manager_update_synctime (RB_PODCAST_MANAGER (data));
+	g_object_get (pd->priv->network_monitor, "network-available", &network, NULL);
+	if (network) {
+		rb_podcast_manager_update_feeds (pd);
+		pd->priv->source_sync = 0;
+		pd->priv->next_time = 0;
+		rb_podcast_manager_update_synctime (RB_PODCAST_MANAGER (data));
+	} else {
+		/* Deliberately fail to call rb_podcast_manager_update_synctime()
+		 * so we'll try to update feeds as soon as the network comes back.
+		 */
+		rb_debug ("Network unavailable; not syncing podcast feeds");
+	}
+
 	GDK_THREADS_LEAVE ();
 	return FALSE;
 }
@@ -533,12 +570,16 @@ rb_podcast_manager_head_query_cb (GtkTre
 }
 
 static gboolean
-rb_podcast_manager_next_file (RBPodcastManager * pd)
+rb_podcast_manager_next_file (RBPodcastManager *pd)
 {
+	gboolean network;
+
 	GDK_THREADS_ENTER ();
-	
-	rb_debug ("try lock file_process mutex");
-	if (g_mutex_trylock (pd->priv->mutex_job) == TRUE) {
+
+	g_object_get (pd->priv->network_monitor, "network-available", &network, NULL);
+	if (!network) {
+		rb_debug ("network unavailable; not downloading podcast episode");
+	} else if (g_mutex_trylock (pd->priv->mutex_job) == TRUE) {
 		gint size;
 
 		g_mutex_lock (pd->priv->download_list_mutex);
@@ -549,8 +590,6 @@ rb_podcast_manager_next_file (RBPodcastM
 			rb_podcast_manager_copy_post (pd);
 		else
 			g_mutex_unlock (pd->priv->mutex_job);
-	} else {
-		rb_debug ("not start");
 	}
 
 	GDK_THREADS_LEAVE ();
@@ -779,8 +818,10 @@ gboolean
 rb_podcast_manager_subscribe_feed (RBPodcastManager *pd, const char *url)
 {
 	RBPodcastThreadInfo *info;
-	gchar *valid_url = gnome_vfs_make_uri_from_input (url);
-
+	gboolean network_available;
+	gchar *valid_url;
+		
+	valid_url = gnome_vfs_make_uri_from_input (url);
 	if (valid_url == NULL) {
 		rb_error_dialog (NULL, _("Invalid URL"),
 				 _("The URL \"%s\" is not valid, please check it."), url);
@@ -798,6 +839,12 @@ rb_podcast_manager_subscribe_feed (RBPod
 		}
 	}
 
+	g_object_get (pd->priv->network_monitor, "network-available", &network_available, NULL);
+	if (network_available == FALSE) {
+		rb_debug ("Network unavailable; not downloading feed");
+		return TRUE;
+	}
+
 	info = g_new0 (RBPodcastThreadInfo, 1);
 	info->pd = pd;
 	info->url = valid_url;
@@ -1706,3 +1756,26 @@ rb_podcast_manager_get_podcast_dir (RBPo
 
 	return conf_dir_name;
 }
+
+static void 
+rb_podcast_manager_network_cb (RBNetworkMonitor *monitor,
+			       GParamSpec *pspec,
+			       RBPodcastManager *pd)
+{
+	gboolean available;
+
+	g_object_get (monitor, "network-available", &available, NULL);
+
+	if (available) {
+		/* check if we should update feeds */
+		GDK_THREADS_ENTER ();
+		rb_podcast_manager_start_sync (pd);
+		GDK_THREADS_LEAVE ();
+
+		/* resume downloading */
+		g_idle_add ((GSourceFunc) rb_podcast_manager_next_file, pd);
+	} else {
+		/* kill downloads? */
+	}
+}
+
Index: podcast/rb-podcast-manager.h
===================================================================
RCS file: /cvs/gnome/rhythmbox/podcast/rb-podcast-manager.h,v
retrieving revision 1.8
diff -u -p -r1.8 rb-podcast-manager.h
--- podcast/rb-podcast-manager.h	14 Jul 2006 12:28:24 -0000	1.8
+++ podcast/rb-podcast-manager.h	6 Sep 2006 13:17:51 -0000
@@ -22,6 +22,7 @@
 
 #include <glib.h>
 #include "rhythmdb.h"
+#include "rb-network-monitor.h"
 
 #ifndef RB_PODCAST_MANAGER_H
 #define RB_PODCAST_MANAGER_H
@@ -58,7 +59,7 @@ typedef struct
 } RBPodcastManagerClass;
 
 GType                   rb_podcast_manager_get_type    		(void);
-RBPodcastManager*      	rb_podcast_manager_new         		(RhythmDB *db);
+RBPodcastManager*      	rb_podcast_manager_new         		(RhythmDB *db, RBNetworkMonitor *monitor);
 void			rb_podcast_manager_cancel_all		(RBPodcastManager *pd);
 void                    rb_podcast_manager_download_entry  	(RBPodcastManager *pd, RhythmDBEntry *entry);
 void		        rb_podcast_manager_cancel_download	(RBPodcastManager *pd, RhythmDBEntry *entry);
Index: shell/Makefile.am
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/Makefile.am,v
retrieving revision 1.86
diff -u -p -r1.86 Makefile.am
--- shell/Makefile.am	31 Jul 2006 13:57:52 -0000	1.86
+++ shell/Makefile.am	6 Sep 2006 13:17:52 -0000
@@ -124,6 +124,10 @@ endif
 if USE_NOTIFY
 rhythmbox_LDADD += $(NOTIFY_LIBS)
 INCLUDES += $(NOTIFY_CFLAGS)
+endif
+
+if USE_NETWORK_MANAGER
+rhythmbox_LDADD += $(NETWORK_MANAGER_LIBS)
 endif
 
 if ENABLE_PYTHON
Index: shell/rb-shell.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell.c,v
retrieving revision 1.472
diff -u -p -r1.472 rb-shell.c
--- shell/rb-shell.c	15 Aug 2006 11:41:03 -0000	1.472
+++ shell/rb-shell.c	6 Sep 2006 13:17:57 -0000
@@ -88,6 +88,7 @@
 #include "rb-plugins-engine.h"
 #include "rb-plugin-manager.h"
 #include "rb-proxy-config.h"
+#include "rb-network-monitor.h"
 #include "rb-util.h"
 #include "rb-sourcelist-model.h"
 #include "rb-song-info.h"
@@ -279,6 +280,7 @@ enum
 	PROP_LIBRARY_SOURCE,
 	PROP_SOURCELIST_MODEL,
 	PROP_VISIBILITY,
+	PROP_NETWORK_MONITOR,
 };
 
 /* prefs */
@@ -362,6 +364,7 @@ struct RBShellPrivate
 	RBSource *import_errors_source;
 
 	RBProxyConfig *proxy_config;
+	RBNetworkMonitor *network_monitor;
 
 	RBSource *selected_source;
 
@@ -635,6 +638,13 @@ rb_shell_class_init (RBShellClass *klass
 							      "RBSourcelistModel",
 							      RB_TYPE_SOURCELIST_MODEL,
 							      G_PARAM_READABLE));
+	g_object_class_install_property (object_class,
+					 PROP_NETWORK_MONITOR,
+					 g_param_spec_object ("network-monitor",
+						 	      "network-monitor",
+							      "Network availability monitor",
+							      RB_TYPE_NETWORK_MONITOR,
+							      G_PARAM_READABLE));
 
 	g_object_class_install_property (object_class,
 					 PROP_VISIBILITY,
@@ -804,6 +814,9 @@ rb_shell_get_property (GObject *object,
 	case PROP_VISIBILITY:
 		g_value_set_boolean (value, rb_shell_get_visibility (shell));
 		break;
+	case PROP_NETWORK_MONITOR:
+		g_value_set_object (value, shell->priv->network_monitor);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -912,6 +925,7 @@ rb_shell_finalize (GObject *object)
 	g_object_unref (G_OBJECT (shell->priv->removable_media_manager));
 
 	g_object_unref (G_OBJECT (shell->priv->proxy_config));
+	g_object_unref (G_OBJECT (shell->priv->network_monitor));
 
 	rb_debug ("unreffing clipboard shell");
 	g_object_unref (G_OBJECT (shell->priv->clipboard_shell));
@@ -1167,7 +1181,8 @@ construct_widgets (RBShell *shell)
 	gtk_container_add (GTK_CONTAINER (win), shell->priv->main_vbox);
 
 	shell->priv->proxy_config = rb_proxy_config_new ();
-
+	shell->priv->network_monitor = rb_network_monitor_new ();
+ 
 	rb_profile_end ("constructing widgets");
 }
 
--- /dev/null	2006-09-01 21:53:50.000000000 +1000
+++ lib/rb-network-monitor.h	2006-05-28 15:29:34.000000000 +1000
@@ -0,0 +1,53 @@
+/*
+ *  Copyright (C) 2006  Jonathan Matthew  <jonathan@kaolin.wh9.net>
+ *
+ *  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 St, Fifth Floor, Boston, MA  
+ *  02110-1301  USA
+ */
+
+#ifndef RB_NETWORK_MONITOR_H
+#define RB_NETWORK_MONITOR_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define RB_TYPE_NETWORK_MONITOR		(rb_network_monitor_get_type ())
+#define RB_NETWORK_MONITOR(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), RB_TYPE_NETWORK_MONITOR, RBNetworkMonitor))
+#define RB_NETWORK_MONITOR_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), RB_TYPE_NETWORK_MONITOR, RBNetworkMonitorClass))
+#define RB_IS_NETWORK_MONITOR(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), RB_TYPE_NETWORK_MONITOR))
+#define RB_IS_NETWORK_MONITOR_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), RB_TYPE_NETWORK_MONITOR))
+#define RB_NETWORK_MONITOR_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), RB_TYPE_NETWORK_MONITOR, RBNetworkMonitorClass))
+
+typedef struct _RBNetworkMonitorPrivate RBNetworkMonitorPrivate;
+
+typedef struct
+{
+	GObject parent;
+	RBNetworkMonitorPrivate *priv;
+} RBNetworkMonitor;
+
+typedef struct
+{
+	GObjectClass parent_class;
+} RBNetworkMonitorClass;
+
+GType			rb_network_monitor_get_type (void);
+
+RBNetworkMonitor *	rb_network_monitor_new (void);
+
+#endif	/* RB_NETWORK_MONITOR_H */
+
--- /dev/null	2006-09-01 21:53:50.000000000 +1000
+++ lib/rb-network-monitor.c	2006-05-28 15:54:31.000000000 +1000
@@ -0,0 +1,168 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ *  Copyright (C) 2006  Jonathan Matthew  <jonathan@kaolin.wh9.net>
+ *
+ *  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.
+ *
+ */
+
+#include "config.h"
+
+#include "rb-network-monitor.h"
+#include "rb-debug.h"
+
+#ifdef WITH_NETWORK_MANAGER
+#include <NetworkManager/libnm_glib.h>
+#endif
+
+enum
+{
+	PROP_0,
+	PROP_NETWORK_AVAILABLE
+};
+
+static void	rb_network_monitor_class_init (RBNetworkMonitorClass *klass);
+static void	rb_network_monitor_init (RBNetworkMonitor *config);
+static void	rb_network_monitor_dispose (GObject *object);
+static void	rb_network_monitor_get_property (GObject *object,
+						 guint prop_id,
+						 GValue *value,
+						 GParamSpec *pspec);
+#ifdef WITH_NETWORK_MANAGER
+static void	rb_network_monitor_cb (libnm_glib_ctx *ctx, RBNetworkMonitor *monitor);
+#endif
+
+struct _RBNetworkMonitorPrivate
+{
+	gboolean network_available;
+#ifdef WITH_NETWORK_MANAGER
+	libnm_glib_ctx *nm_context;
+	guint nm_callback_id;
+#endif
+};
+
+G_DEFINE_TYPE (RBNetworkMonitor, rb_network_monitor, G_TYPE_OBJECT)
+
+static void
+rb_network_monitor_class_init (RBNetworkMonitorClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->dispose = rb_network_monitor_dispose;
+	object_class->get_property = rb_network_monitor_get_property;
+
+	g_object_class_install_property (object_class,
+					 PROP_NETWORK_AVAILABLE,
+					 g_param_spec_boolean ("network-available",
+						 	       "network-available",
+							       "network availability flag",
+							       TRUE,
+							       G_PARAM_READABLE));
+
+
+	g_type_class_add_private (klass, sizeof (RBNetworkMonitorPrivate));
+}
+
+static void
+rb_network_monitor_init (RBNetworkMonitor *monitor)
+{
+	monitor->priv = G_TYPE_INSTANCE_GET_PRIVATE (monitor, RB_TYPE_NETWORK_MONITOR, RBNetworkMonitorPrivate);
+#ifdef WITH_NETWORK_MANAGER
+	monitor->priv->nm_context = libnm_glib_init ();
+
+	monitor->priv->nm_callback_id = 
+		libnm_glib_register_callback (monitor->priv->nm_context,
+					      (libnm_glib_callback_func) rb_network_monitor_cb,
+					      monitor,
+					      NULL);	/* ?? */
+	rb_network_monitor_cb (monitor->priv->nm_context, monitor);
+#else
+	monitor->priv->network_available = TRUE;
+#endif
+}
+
+static void
+rb_network_monitor_dispose (GObject *object)
+{
+	RBNetworkMonitor *monitor;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (RB_IS_NETWORK_MONITOR (object));
+	monitor = RB_NETWORK_MONITOR (object);
+	g_return_if_fail (monitor->priv != NULL);
+
+#ifdef WITH_NETWORK_MANAGER
+	if (monitor->priv->nm_context) {
+		libnm_glib_unregister_callback (monitor->priv->nm_context,
+						monitor->priv->nm_callback_id);
+		
+		libnm_glib_shutdown (monitor->priv->nm_context);
+		monitor->priv->nm_context = NULL;
+	}
+#endif
+
+	G_OBJECT_CLASS (rb_network_monitor_parent_class)->dispose (object);
+}
+void
+rb_network_monitor_get_property (GObject *object,
+				 guint prop_id,
+				 GValue *value,
+				 GParamSpec *pspec)
+{
+	RBNetworkMonitor *mon = RB_NETWORK_MONITOR (object);
+	switch (prop_id) {
+	case PROP_NETWORK_AVAILABLE:
+		g_value_set_boolean (value, mon->priv->network_available);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+RBNetworkMonitor *
+rb_network_monitor_new ()
+{
+	return g_object_new (RB_TYPE_NETWORK_MONITOR, NULL);
+}
+
+#ifdef WITH_NETWORK_MANAGER
+static void
+rb_network_monitor_cb (libnm_glib_ctx *ctx, RBNetworkMonitor *monitor)
+{
+	libnm_glib_state state;
+
+	state = libnm_glib_get_network_state (ctx);
+	switch (state) {
+	case LIBNM_NO_DBUS:
+	case LIBNM_NO_NETWORKMANAGER:
+	case LIBNM_INVALID_CONTEXT:
+		rb_debug ("NetworkManager doesn't know if a network connection is available");
+		monitor->priv->network_available = TRUE;
+		break;
+	case LIBNM_ACTIVE_NETWORK_CONNECTION:
+		rb_debug ("NetworkManager says network is available");
+		monitor->priv->network_available = TRUE;
+		break;
+	case LIBNM_NO_NETWORK_CONNECTION:
+		rb_debug ("NetworkManager says network is not available");
+		monitor->priv->network_available = FALSE;
+		break;
+	}
+
+	g_object_notify (G_OBJECT (monitor), "network-available");
+}
+#endif
+
Index: sources/rb-podcast-source.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/sources/rb-podcast-source.c,v
retrieving revision 1.78
diff -u -p -r1.78 rb-podcast-source.c
--- sources/rb-podcast-source.c	14 Aug 2006 09:03:25 -0000	1.78
+++ sources/rb-podcast-source.c	7 Sep 2006 12:30:10 -0000
@@ -54,6 +54,7 @@
 #include "rb-podcast-manager.h"
 #include "rb-static-playlist-source.h"
 #include "rb-cut-and-paste-code.h"
+#include "rb-network-monitor.h"
 
 typedef enum
 {
@@ -208,6 +209,9 @@ static void rb_podcast_source_entry_acti
 						  RBPodcastSource *source);
 static void rb_podcast_source_cmd_new_podcast	 (GtkAction *action,
 						  RBPodcastSource *source);
+static void rb_podcast_source_network_cb	 (RBNetworkMonitor *monitor,
+						  GParamSpec *pspec,
+						  RBPodcastSource *source);
 
 /* source methods */
 static char *impl_get_browser_key	 		(RBSource *source);
@@ -323,7 +327,8 @@ enum
 {
 	PROP_0,
 	PROP_ENTRY_TYPE,
-	PROP_PODCAST_MANAGER
+	PROP_PODCAST_MANAGER,
+	PROP_NETWORK_MONITOR
 };
 
 G_DEFINE_TYPE (RBPodcastSource, rb_podcast_source, RB_TYPE_SOURCE)
@@ -518,6 +523,7 @@ rb_podcast_source_constructor (GType typ
 	RBShell *shell;
 	RhythmDBQueryModel *query_model;
 	GPtrArray *query;
+	RBNetworkMonitor *monitor;
 
 	klass = RB_PODCAST_SOURCE_CLASS (g_type_class_peek (RB_TYPE_PODCAST_SOURCE));
 
@@ -525,7 +531,10 @@ rb_podcast_source_constructor (GType typ
 			constructor (type, n_construct_properties, construct_properties));
 
 	g_object_get (source, "shell", &shell, NULL);
-	g_object_get (shell, "db", &source->priv->db, NULL);
+	g_object_get (shell, 
+		      "db", &source->priv->db, 
+		      "network-monitor", &monitor, 
+		      NULL);
 
 	source->priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
 								       "PodcastActions",
@@ -543,8 +552,14 @@ rb_podcast_source_constructor (GType typ
 
 	gtk_idle_add ((GtkFunction) rb_podcast_source_load_finish_cb, source);
 
-	source->priv->podcast_mgr = rb_podcast_manager_new (source->priv->db);
+	source->priv->podcast_mgr = rb_podcast_manager_new (source->priv->db, monitor);
+
+	g_signal_connect_object (G_OBJECT (monitor),
+				 "notify::network-available",
+				 G_CALLBACK (rb_podcast_source_network_cb),
+				 source, 0);
 
+	g_object_unref (monitor);
 	g_object_unref (shell);
 
 	/* set up posts view */
@@ -1046,6 +1061,7 @@ rb_podcast_source_feeds_show_popup_cb (R
 		act_delete = gtk_action_group_get_action (source->priv->action_group, "PodcastFeedDelete");
 
 		if (lst) {
+			gtk_action_set_visible (act_update, TRUE);
 			gtk_action_set_visible (act_properties, TRUE);
 			gtk_action_set_visible (act_delete, TRUE);
 		} else {
@@ -2017,5 +2033,26 @@ impl_add_uri (RBSource *asource, const c
 	RBPodcastSource *source = RB_PODCAST_SOURCE (asource);
 	rb_podcast_manager_subscribe_feed (source->priv->podcast_mgr, uri);
 	return TRUE;
+}
+
+static void
+rb_podcast_source_network_cb (RBNetworkMonitor *monitor, GParamSpec *pspec, RBPodcastSource *source)
+{
+	GtkAction *action;
+	gboolean available;
+
+	g_object_get (monitor, "network-available", &available, NULL);
+
+	/* disable update actions when network is not available.
+	 * we leave "download episode" enabled as it'll queue them
+	 * up for download when network access is available again.
+	 */
+	action = gtk_action_group_get_action (source->priv->action_group, 
+					      "PodcastFeedUpdate");
+	gtk_action_set_sensitive (action, available);
+	
+	action = gtk_action_group_get_action (source->priv->action_group, 
+					      "PodcastUpdateAllFeeds");
+	gtk_action_set_sensitive (action, available);
 }
 
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/rhythmbox/configure.ac,v
retrieving revision 1.256
diff -u -p -r1.256 configure.ac
--- configure.ac	2 Sep 2006 13:41:13 -0000	1.256
+++ configure.ac	7 Sep 2006 12:30:12 -0000
@@ -712,6 +712,22 @@ if test x"$enable_lirc" != xno; then
 fi
 AM_CONDITIONAL(WITH_LIRC, test x"$with_lirc" = xyes)
 
+dnl NetworkManager
+AC_ARG_ENABLE(network-manager,
+	AC_HELP_STRING([--enable-network-manager],[enable NetworkManager support]))
+have_network_manager=no
+if test x"$enable_network_manager" != xno; then
+	PKG_CHECK_MODULES(NETWORK_MANAGER, libnm_glib, have_network_manager=yes,
+		          have_network_manager=no)
+        if test "x$with_network_manager" = xyes && test "x$have_network_manager" = xno; then
+	   AC_MSG_ERROR([NetworkManager explicitly requested but no support found])	   
+	fi
+        if test "x$have_network_manager" = xyes; then
+		AC_DEFINE(WITH_NETWORK_MANAGER, 1, [Define if NetworkManager is enabled])	   
+	fi
+fi
+AM_CONDITIONAL(USE_NETWORK_MANAGER, test x"$have_network_manager" = xyes)
+
 
 AC_ARG_ENABLE(uninstalled-build,
               AC_HELP_STRING([--enable-uninstalled-build],
