[Slim-Checkins] r12221 - in /trunk/server: Changelog6.html HTML/EN/settings/server/networking.html Slim/Networking/UPnP/ControlPoint.pm Slim/Utils/UPnPMediaServer.pm Slim/Web/Settings/Server/Network.pm slimserver.pl strings.txt

andy at svn.slimdevices.com andy at svn.slimdevices.com
Fri Jun 8 13:15:39 PDT 2007


Author: andy
Date: Fri Jun  8 13:15:39 2007
New Revision: 12221

URL: http://svn.slimdevices.com?rev=12221&view=rev
Log:
Bug 4357, add a Network pref to enable/disable UPnP.  Changes take effect immediately, no restart required

Modified:
    trunk/server/Changelog6.html
    trunk/server/HTML/EN/settings/server/networking.html
    trunk/server/Slim/Networking/UPnP/ControlPoint.pm
    trunk/server/Slim/Utils/UPnPMediaServer.pm
    trunk/server/Slim/Web/Settings/Server/Network.pm
    trunk/server/slimserver.pl
    trunk/server/strings.txt

Modified: trunk/server/Changelog6.html
URL: http://svn.slimdevices.com/trunk/server/Changelog6.html?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/Changelog6.html (original)
+++ trunk/server/Changelog6.html Fri Jun  8 13:15:39 2007
@@ -12,6 +12,13 @@
 	<li>Integration:
 	<ul> 
 		<li>Support for MoodLogic has been dropped.</li>
+	</ul>
+	</li>
+	<br />
+	
+	<li>Settings:
+	<ul>
+		<li>UPnP client may now be enabled/disabled from the Network settings page.</li>
 	</ul>
 	</li>
 	<br />
@@ -29,10 +36,11 @@
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=1604">#3972</a> - Null-delimited lists in ID3v2.4 text frames</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4110">#4110</a> - Incorrect display with browser refresh after adding Internet Radio station from playlist</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4193">#4193</a> - album (no album) a mess</li>
-		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4437">#4437</a> - Navigating unsorted lists with the number keys doesn't work
+		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4357">#4357</a> - add an option to not show UPnP servers under browse</li>
+		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4437">#4437</a> - Navigating unsorted lists with the number keys doesn't work</li>
+		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4694">#4694</a> - When "Composer, band and orchestra in artists" are disabled, song info items for composer, conductor &amp; orchestra are displayed but show "Empty" when moving right</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4812">#4812</a> - Rescan done callback not called in all situations</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4882">#4882</a> - multiple roles for same contributor removed from contributor_album table</li>
-		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4694">#4694</a> - When "Composer, band and orchestra in artists" are disabled, song info items for composer, conductor & orchestra are displayed but show "Empty" when moving right</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=5028">#5028</a> - "Select Player Font" dropbox not completely localized</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=5090">#5090</a> - If no local DNS server is available, bad things happen</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=5093">#5093</a> - Nokia770 skin on Nokia N800 shows a vertical scroll bar and the page footer moves bottom of the page when scrolling</li>

Modified: trunk/server/HTML/EN/settings/server/networking.html
URL: http://svn.slimdevices.com/trunk/server/HTML/EN/settings/server/networking.html?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/HTML/EN/settings/server/networking.html (original)
+++ trunk/server/HTML/EN/settings/server/networking.html Fri Jun  8 13:15:39 2007
@@ -34,6 +34,18 @@
 				[% IF option == 9999 %][% "NO_LIMIT" | string %][% ELSE %][% option %] [% 'KBPS' | string %][% END %]</option>
 		[%- END -%]
 
+		</select>
+		
+		<div class="prefHead">[% "SETUP_NOUPNP" | string | upper %]</div>
+		<div class="prefDesc">[% "SETUP_NOUPNP_DESC" | string %]</div>
+		
+		<select class="stdedit" name="noupnp" id="noupnp">
+			<option [% IF prefs.noupnp == 0 %]selected="selected" [% END %]value="0">
+				[% 'SETUP_UPNP_ENABLE' | string %]
+			</option>
+			<option [% IF prefs.noupnp == 1 %]selected="selected" [% END %]value="1">
+				[% 'SETUP_UPNP_DISABLE' | string %]
+			</option>
 		</select>
 
 		[% IF mDNSname.size %]

Modified: trunk/server/Slim/Networking/UPnP/ControlPoint.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Networking/UPnP/ControlPoint.pm?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/Slim/Networking/UPnP/ControlPoint.pm (original)
+++ trunk/server/Slim/Networking/UPnP/ControlPoint.pm Fri Jun  8 13:15:39 2007
@@ -23,6 +23,9 @@
 use Slim::Networking::Async::Socket::UDP;
 use Slim::Utils::Log;
 
+# A global socket that listens for UPnP events
+our $sock;
+
 # all devices we currently know about
 our $devices = {};
 
@@ -57,7 +60,7 @@
 
 	$ssdp_header =~ s/\r?\n/\015\012/g;
 	
-	my $sock = Slim::Networking::Async::Socket::UDP->new(
+	$sock = Slim::Networking::Async::Socket::UDP->new(
 		LocalPort => $Net::UPnP::SSDP_PORT,
 		ReuseAddr => 1,
 	);
@@ -80,6 +83,23 @@
 	
 	# send the search query
 	$sock->mcast_send( $ssdp_header, $mcast_addr );
+}
+
+# Stop listening for UPnP events
+sub shutdown {
+	my $class = shift;
+	
+	if ( defined $sock ) {
+		Slim::Networking::Select::removeRead( $sock );
+	
+		$sock->close;
+	
+		$sock = undef;
+	}
+	
+	while ( my ($udn, $device) = each %{$devices} ) {
+		removeDevice( $device );
+	}
 }
 
 # A way for other code to remove a device

Modified: trunk/server/Slim/Utils/UPnPMediaServer.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/UPnPMediaServer.pm?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/Slim/Utils/UPnPMediaServer.pm (original)
+++ trunk/server/Slim/Utils/UPnPMediaServer.pm Fri Jun  8 13:15:39 2007
@@ -22,9 +22,14 @@
 use Slim::Utils::Log;
 use Slim::Utils::Misc;
 
+our %devices             = ();
 our $registeredCallbacks = [];
 
+my $log = logger('network.upnp');
+
 sub init {
+	$log->info('UPnP: Starting up');
+	
 	Slim::Buttons::BrowseUPnPMediaServer::init();
 	Slim::Web::UPnPMediaServer::init();
 	
@@ -35,10 +40,20 @@
 	} );
 }
 
+sub shutdown {
+	$log->info('UPnP: Shutting down');
+	
+	Slim::Networking::UPnP::ControlPoint->shutdown();
+	
+	while ( my ($udn, $device) = each %devices ) {
+		$log->info( sprintf( "UPnP: Removing device %s", $device->getfriendlyname ) );
+		
+		foundDevice( $device, 'remove' );
+	}
+}		
+
 sub foundDevice {
 	my ( $device, $event ) = @_;
-
-	my $log = logger('network.upnp');
 	
 	# We'll get a callback for all UPnP devices, but we only look for media servers
 	if ( $device->getdevicetype =~ /MediaServer/ ) {
@@ -47,6 +62,8 @@
 		if ( $event eq 'add' ) {
 
 			$log->info("Adding new media server: $menuName");
+			
+			$devices{ $device->getudn } = $device;
 		
 			addDeviceMenus( $device, $menuName );
 			
@@ -55,6 +72,8 @@
 			Slim::Utils::Timers::setTimer( $device, time() + 60, \&checkServerHealth );
 		}
 		elsif ( $event eq 'remove' ) {
+			delete $devices{ $device->getudn };
+			
 			removeDeviceMenus( $device, $menuName );
 			
 			Slim::Utils::Timers::killTimers( $device, \&checkServerHealth );
@@ -80,8 +99,6 @@
 	my $callback = shift;
 	
 	push @{$registeredCallbacks}, $callback;
-
-	my $log = logger('network.upnp');
 	
 	if ($log->is_debug) {
 

Modified: trunk/server/Slim/Web/Settings/Server/Network.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Network.pm?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Network.pm (original)
+++ trunk/server/Slim/Web/Settings/Server/Network.pm Fri Jun  8 13:15:39 2007
@@ -25,7 +25,7 @@
 }
 
 sub prefs {
-	my @prefs = qw(webproxy httpport bufferSecs remotestreamtimeout maxWMArate);
+	my @prefs = qw(webproxy httpport bufferSecs remotestreamtimeout maxWMArate noupnp);
 
 	# Bug 2724 - only show the mDNS settings if we have a binary for it.
 	if (Slim::Utils::Misc::findbin('mDNSResponderPosix')) {
@@ -61,6 +61,16 @@
 		}
 		# warning for invalid value created by base class
 	}
+	
+	if ( defined $paramRef->{'noupnp'} && $paramRef->{'noupnp'} ne $prefs->get('noupnp') ) {
+		# Shut down all UPnP activity
+		Slim::Utils::UPnPMediaServer::shutdown();
+		
+		# Start it up again if the user enabled it
+		if ( !$paramRef->{'noupnp'} ) {
+			Slim::Utils::UPnPMediaServer::init();
+		}
+	}
 
 	return $class->SUPER::handler($client, $paramRef, $pageSetup);
 }

Modified: trunk/server/slimserver.pl
URL: http://svn.slimdevices.com/trunk/server/slimserver.pl?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/slimserver.pl (original)
+++ trunk/server/slimserver.pl Fri Jun  8 13:15:39 2007
@@ -337,7 +337,7 @@
 	$log->info("Cache init...");
 	Slim::Utils::Cache->init();
 
-	if (!$noupnp) {
+	unless ( $noupnp || $prefs->get('noupnp') ) {
 		$log->info("UPnP init...");
 		Slim::Utils::UPnPMediaServer::init();
 	}

Modified: trunk/server/strings.txt
URL: http://svn.slimdevices.com/trunk/server/strings.txt?rev=12221&r1=12220&r2=12221&view=diff
==============================================================================
--- trunk/server/strings.txt (original)
+++ trunk/server/strings.txt Fri Jun  8 13:15:39 2007
@@ -3351,6 +3351,18 @@
 	IT	Per eseguire lo streaming di alcuni flussi WMA sono disponibili diverse velocità in bit. Per impostazione predefinita in SlimServer viene utilizzato il flusso con la velocità in bit più elevata, ma se si dispone di una connessione a Internet lenta, è possibile impostare qui un valore più basso per limitare la velocità massima selezionabile per questi flussi con velocità molteplici.
 	NL	Sommige WMA-streams hebben meerdere bitsnelheden voor streaming. SlimServer selecteert standaard de hoogste bitsnelheid die voor de stream beschikbaar is. Als je een langzamere internetverbinding hebt, kun je een lagere waarde instellen om de maximumsnelheid die gekozen kan worden, te beperken.
 
+SETUP_NOUPNP
+	EN	UPnP Client
+
+SETUP_NOUPNP_DESC
+	EN	Should SlimServer look for other UPnP media servers on your network?
+
+SETUP_UPNP_ENABLE
+	EN	Enabled, look for other UPnP media servers.
+
+SETUP_UPNP_DISABLE
+	EN	Disabled, do not look for other UPnP media servers.
+
 SETUP_MAXBITRATE
 	DE	Bitraten-Beschränkung
 	EN	Bitrate Limiting



More information about the checkins mailing list