[Slim-Checkins] r10628 - in /trunk: platforms/debian/ server/ server/CPAN/Devel/ server/CPAN/Module/ server/CPAN/Module/Pluggable/ server/Slim/Web/ server/Slim/Web/Settings/ server/Slim/Web/Settings/Player/ server/Slim/Web/Settings/Server/

dsully at svn.slimdevices.com dsully at svn.slimdevices.com
Wed Nov 8 13:06:11 PST 2006


Author: dsully
Date: Wed Nov  8 13:06:11 2006
New Revision: 10628

URL: http://svn.slimdevices.com?rev=10628&view=rev
Log:
Bug: N/A
Description: Setup rework:

* Break the setup handlers that KDF has created into separate modules.

* Each setup handler subclasses Slim::Web::Settings which provides base functionality.

* Don't load any of the web setup code if --nosetup is passed.

Added:
    trunk/server/CPAN/Devel/
    trunk/server/CPAN/Devel/InnerPackage.pm   (with props)
    trunk/server/CPAN/Module/
    trunk/server/CPAN/Module/Pluggable/
    trunk/server/CPAN/Module/Pluggable.pm   (with props)
    trunk/server/CPAN/Module/Pluggable/Object.pm   (with props)
    trunk/server/Slim/Web/Settings/
    trunk/server/Slim/Web/Settings.pm   (with props)
    trunk/server/Slim/Web/Settings/Player/
    trunk/server/Slim/Web/Settings/Server/
    trunk/server/Slim/Web/Settings/Server/Basic.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/Behavior.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/Debugging.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/FileTypes.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/Network.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/Performance.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/Security.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/TextFormatting.pm   (with props)
    trunk/server/Slim/Web/Settings/Server/UserInterface.pm   (with props)
Modified:
    trunk/platforms/debian/control
    trunk/server/Slim/Web/HTTP.pm
    trunk/server/Slim/Web/Pages.pm
    trunk/server/Slim/Web/Setup.pm
    trunk/server/slimserver.pl

Modified: trunk/platforms/debian/control
URL: http://svn.slimdevices.com/trunk/platforms/debian/control?rev=10628&r1=10627&r2=10628&view=diff
==============================================================================
--- trunk/platforms/debian/control (original)
+++ trunk/platforms/debian/control Wed Nov  8 13:06:11 2006
@@ -23,7 +23,7 @@
  libtie-cache-lru-expires-perl (>= 0.54-1), libxml-parser-perl, libfile-find-rule-perl,
  libdata-vstring-perl, libalgorithm-c3-perl, libclass-c3-perl, libproc-background-perl,
  libdbix-class-perl, libclass-inspector-perl, libxml-writer-perl, libxml-xspf-perl,
- liblog-log4perl-perl, libexporter-lite-perl,
+ liblog-log4perl-perl, libexporter-lite-perl, libmodule-pluggable-perl,
  libdata-dump-perl, libmpeg-audio-frame-perl, libnet-upnp-perl, libxml-simple-perl (>= 2.15-1),
  libdbix-migration-perl, libyaml-syck-perl (>= 0.41-1), mysql-server-4.1 | mysql-server-5.0,
  libmysqlclient14-dev | libmysqlclient15-dev, mysql-client-4.1 | mysql-client-5.0,

Added: trunk/server/CPAN/Devel/InnerPackage.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Devel/InnerPackage.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/CPAN/Devel/InnerPackage.pm (added)
+++ trunk/server/CPAN/Devel/InnerPackage.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,103 @@
+package Devel::InnerPackage;
+
+use strict;
+use base qw(Exporter);
+use vars qw($VERSION @EXPORT_OK);
+
+use Class::Inspector;
+
+
+$VERSION = '0.3';
+ at EXPORT_OK = qw(list_packages);
+
+=pod
+
+=head1 NAME
+
+
+Devel::InnerPackage - find all the inner packages of a package
+
+=head1 SYNOPSIS
+
+    use Foo::Bar;
+    use Devel::innerPackage qw(list_packages);
+
+    my @inner_packages = list_packages('Foo::Bar');
+
+
+=head1 DESCRIPTION
+
+
+Given a file like this
+
+
+    package Foo::Bar;
+
+    sub foo {}
+
+
+    package Foo::Bar::Quux;
+
+    sub quux {}
+
+    package Foo::Bar::Quirka;
+
+    sub quirka {}
+
+    1;
+
+then
+
+    list_packages('Foo::Bar');
+
+will return
+
+    Foo::Bar::Quux
+    Foo::Bar::Quirka
+
+=head1 METHODS
+
+=head2 list_packages <package name>
+
+Return a list of all inner packages of that package.
+
+=cut
+
+sub list_packages {
+            my $pack = shift; $pack .= "::" unless $pack =~ m!::$!;
+
+            no strict 'refs';
+            my @packs;
+            my @stuff = grep !/^(main|)::$/, keys %{$pack};
+            for my $cand (grep /::$/, @stuff)
+            {
+                $cand =~ s!::$!!;
+                my @children = list_packages($pack.$cand);
+    
+                push @packs, "$pack$cand" unless $cand =~ /^::/ || !Class::Inspector->loaded($pack.$cand); # or @children;
+                push @packs, @children;
+            }
+            return grep {$_ !~ /::::ISA::CACHE/} @packs;
+}
+
+=head1 AUTHOR
+
+Simon Wistow <simon at thegestalt.org>
+
+=head1 COPYING
+
+Copyright, 2005 Simon Wistow
+
+Distributed under the same terms as Perl itself.
+
+=head1 BUGS
+
+None known.
+
+=cut 
+
+
+
+
+
+1;

Propchange: trunk/server/CPAN/Devel/InnerPackage.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/CPAN/Devel/InnerPackage.pm
------------------------------------------------------------------------------
    svn:executable = *

Propchange: trunk/server/CPAN/Devel/InnerPackage.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/CPAN/Devel/InnerPackage.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/CPAN/Module/Pluggable.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Module/Pluggable.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/CPAN/Module/Pluggable.pm (added)
+++ trunk/server/CPAN/Module/Pluggable.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,346 @@
+package Module::Pluggable;
+
+use strict;
+use vars qw($VERSION);
+use Module::Pluggable::Object;
+
+# ObQuote:
+# Bob Porter: Looks like you've been missing a lot of work lately. 
+# Peter Gibbons: I wouldn't say I've been missing it, Bob! 
+
+
+$VERSION = '3.1';
+
+sub import {
+    my $class        = shift;
+    my %opts         = @_;
+
+    my ($pkg, $file) = caller; 
+    # the default name for the method is 'plugins'
+    my $sub          = $opts{'sub_name'}  || 'plugins';
+    # get our package 
+    my ($package)    = $opts{'package'} || $pkg;
+    $opts{filename}  = $file;
+    $opts{package}   = $package;
+
+
+    my $finder       = Module::Pluggable::Object->new(%opts);
+    my $subroutine   = sub { my $self = shift; return $finder->plugins(@_) };
+
+    my $searchsub = sub {
+              my $self = shift;
+              my ($action, at paths) = @_;
+
+              $finder->{'search_path'} = ["${package}::Plugin"] if ($action eq 'add'  and not   $finder->{'search_path'} );
+              push @{$finder->{'search_path'}}, @paths      if ($action eq 'add');
+              $finder->{'search_path'}       = \@paths      if ($action eq 'new');
+              return $finder->{'search_path'};
+    };
+
+
+    my $onlysub = sub {
+        my ($self, $only) = @_;
+
+        if (defined $only) {
+            $finder->{'only'} = $only;
+        };
+        
+        return $finder->{'only'};
+    };
+
+    my $exceptsub = sub {
+        my ($self, $except) = @_;
+
+        if (defined $except) {
+            $finder->{'except'} = $except;
+        };
+        
+        return $finder->{'except'};
+    };
+
+
+    no strict 'refs';
+    no warnings 'redefine';
+    *{"$package\::$sub"}    = $subroutine;
+    *{"$package\::search_path"} = $searchsub;
+    *{"$package\::only"}        = $onlysub;
+    *{"$package\::except"}      = $exceptsub;
+
+}
+
+1;
+
+=pod
+
+=head1 NAME
+
+Module::Pluggable - automatically give your module the ability to have plugins
+
+=head1 SYNOPSIS
+
+
+Simple use Module::Pluggable -
+
+    package MyClass;
+    use Module::Pluggable;
+    
+
+and then later ...
+
+    use MyClass;
+    my $mc = MyClass->new();
+    # returns the names of all plugins installed under MyClass::Plugin::*
+    my @plugins = $mc->plugins(); 
+
+=head1 EXAMPLE
+
+Why would you want to do this? Say you have something that wants to pass an
+object to a number of different plugins in turn. For example you may 
+want to extract meta-data from every email you get sent and do something
+with it. Plugins make sense here because then you can keep adding new 
+meta data parsers and all the logic and docs for each one will be 
+self contained and new handlers are easy to add without changing the 
+core code. For that, you might do something like ...
+
+    package Email::Examiner;
+
+    use strict;
+    use Email::Simple;
+    use Module::Pluggable require => 1;
+
+    sub handle_email {
+        my $self  = shift;
+        my $email = shift;
+
+        foreach my $plugin ($self->plugins) {
+            $plugin->examine($email);
+        }
+
+        return 1;
+    }
+
+
+
+.. and all the plugins will get a chance in turn to look at it.
+
+This can be trivally extended so that plugins could save the email
+somewhere and then no other plugin should try and do that. 
+Simply have it so that the C<examine> method returns C<1> if 
+it has saved the email somewhere. You might also wnat to be paranoid
+and check to see if the plugin has an C<examine> method.
+
+        foreach my $plugin ($self->plugins) {
+            next unless $plugin->can('examine');
+            last if     $plugin->examine($email);
+        }
+
+
+And so on. The sky's the limit.
+
+
+=head1 DESCRIPTION
+
+Provides a simple but, hopefully, extensible way of having 'plugins' for 
+your module. Obviously this isn't going to be the be all and end all of
+solutions but it works for me.
+
+Essentially all it does is export a method into your namespace that 
+looks through a search path for .pm files and turn those into class names. 
+
+Optionally it instantiates those classes for you.
+
+=head1 ADVANCED USAGE
+
+    
+Alternatively, if you don't want to use 'plugins' as the method ...
+    
+    package MyClass;
+    use Module::Pluggable sub_name => 'foo';
+
+
+and then later ...
+
+    my @plugins = $mc->foo();
+
+
+Or if you want to look in another namespace
+
+    package MyClass;
+    use Module::Pluggable search_path => ['Acme::MyClass::Plugin', 'MyClass::Extend'];
+
+or directory 
+
+    use Module::Pluggable search_dirs => ['mylibs/Foo'];
+
+
+Or if you want to instantiate each plugin rather than just return the name
+
+    package MyClass;
+    use Module::Pluggable instantiate => 'new';
+
+and then
+
+    # whatever is passed to 'plugins' will be passed 
+    # to 'new' for each plugin 
+    my @plugins = $mc->plugins(@options); 
+
+
+alternatively you can just require the module without instantiating it
+
+    package MyClass;
+    use Module::Pluggable require => 1;
+
+since requiring automatically searches inner packages, which may not be desirable, you can turn this off
+
+
+    package MyClass;
+    use Module::Pluggable require => 1, inner => 0;
+
+
+You can limit the plugins loaded using the except option, either as a string,
+array ref or regex
+
+    package MyClass;
+    use Module::Pluggable except => 'MyClass::Plugin::Foo';
+
+or
+
+    package MyClass;
+    use Module::Pluggable except => ['MyClass::Plugin::Foo', 'MyClass::Plugin::Bar'];
+
+or
+
+    package MyClass;
+    use Module::Pluggable except => qr/^MyClass::Plugin::(Foo|Bar)$/;
+
+
+and similarly for only which will only load plugins which match.
+
+Remember you can use the module more than once
+
+    package MyClass;
+    use Module::Pluggable search_path => 'MyClass::Filters' sub_name => 'filters';
+    use Module::Pluggable search_path => 'MyClass::Plugins' sub_name => 'plugins';
+
+and then later ...
+
+    my @filters = $self->filters;
+    my @plugins = $self->plugins;
+
+=head1 INNER PACKAGES
+
+If you have, for example, a file B<lib/Something/Plugin/Foo.pm> that
+contains package definitions for both C<Something::Plugin::Foo> and 
+C<Something::Plugin::Bar> then as long as you either have either 
+the B<require> or B<instantiate> option set then we'll also find 
+C<Something::Plugin::Bar>. Nifty!
+
+=head1 OPTIONS
+
+You can pass a hash of options when importing this module.
+
+The options can be ...
+
+=head2 sub_name
+
+The name of the subroutine to create in your namespace. 
+
+By default this is 'plugins'
+
+=head2 search_path
+
+An array ref of namespaces to look in. 
+
+=head2 search_dirs 
+
+An array ref of directorys to look in before @INC.
+
+=head2 instantiate
+
+Call this method on the class. In general this will probably be 'new'
+but it can be whatever you want. Whatever arguments are passed to 'plugins' 
+will be passed to the method.
+
+The default is 'undef' i.e just return the class name.
+
+=head2 require
+
+Just require the class, don't instantiate (overrides 'instantiate');
+
+=head2 inner
+
+If set to 0 will B<not> search inner packages. 
+If set to 1 will override C<require>.
+
+=head2 only
+
+Takes a string, array ref or regex describing the names of the only plugins to 
+return. Whilst this may seem perverse ... well, it is. But it also 
+makes sense. Trust me.
+
+=head2 except
+
+Similar to C<only> it takes a description of plugins to exclude 
+from returning. This is slightly less perverse.
+
+=head2 package
+
+This is for use by extension modules which build on C<Module::Pluggable>:
+passing a C<package> option allows you to place the plugin method in a
+different package other than your own.
+
+=head2 file_regex
+
+By default C<Module::Pluggable> only looks for I<.pm> files.
+
+By supplying a new C<file_regex> then you can change this behaviour e.g
+
+    file_regex => qr/\.plugin$/
+
+
+
+=head1 METHODs
+
+=head2 search_path
+
+The method C<search_path> is exported into you namespace as well. 
+You can call that at any time to change or replace the 
+search_path.
+
+    $self->search_path( add => "New::Path" ); # add
+    $self->search_path( new => "New::Path" ); # replace
+
+
+
+=head1 FUTURE PLANS
+
+This does everything I need and I can't really think of any other 
+features I want to add. Famous last words of course
+
+Recently tried fixed to find inner packages and to make it 
+'just work' with PAR but there are still some issues.
+
+
+However suggestions (and patches) are welcome.
+
+=head1 AUTHOR
+
+Simon Wistow <simon at thegestalt.org>
+
+=head1 COPYING
+
+Copyright, 2006 Simon Wistow
+
+Distributed under the same terms as Perl itself.
+
+=head1 BUGS
+
+None known.
+
+=head1 SEE ALSO
+
+L<File::Spec>, L<File::Find>, L<File::Basename>, L<Class::Factory::Util>, L<Module::Pluggable::Ordered>
+
+=cut 
+
+

Propchange: trunk/server/CPAN/Module/Pluggable.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/CPAN/Module/Pluggable.pm
------------------------------------------------------------------------------
    svn:executable = *

Propchange: trunk/server/CPAN/Module/Pluggable.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/CPAN/Module/Pluggable.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/CPAN/Module/Pluggable/Object.pm
URL: http://svn.slimdevices.com/trunk/server/CPAN/Module/Pluggable/Object.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/CPAN/Module/Pluggable/Object.pm (added)
+++ trunk/server/CPAN/Module/Pluggable/Object.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,285 @@
+package Module::Pluggable::Object;
+
+use strict;
+use File::Find ();
+use File::Basename;
+use File::Spec::Functions qw(splitdir catdir abs2rel);
+use Carp qw(croak carp);
+use Devel::InnerPackage;
+use Data::Dumper;
+
+sub new {
+    my $class = shift;
+    my %opts  = @_;
+
+    return bless \%opts, $class;
+
+}
+
+
+sub plugins {
+        my $self = shift;
+
+        # override 'require'
+        $self->{'require'} = 1 if $self->{'inner'};
+
+        my $filename   = $self->{'filename'};
+        my $pkg        = $self->{'package'};
+
+        # automatically turn a scalar search path or namespace into a arrayref
+        for (qw(search_path search_dirs)) {
+            $self->{$_} = [ $self->{$_} ] if exists $self->{$_} && !ref($self->{$_});
+        }
+
+
+
+
+        # default search path is '<Module>::<Name>::Plugin'
+        $self->{'search_path'} = ["${pkg}::Plugin"] unless $self->{'search_path'}; 
+
+
+        #my %opts = %$self;
+
+
+        # check to see if we're running under test
+        my @SEARCHDIR = exists $INC{"blib.pm"} && $filename =~ m!(^|/)blib/! ? grep {/blib/} @INC : @INC;
+
+        # add any search_dir params
+        unshift @SEARCHDIR, @{$self->{'search_dirs'}} if defined $self->{'search_dirs'};
+
+
+        my @plugins = $self->search_directories(@SEARCHDIR);
+
+        # push @plugins, map { print STDERR "$_\n"; $_->require } list_packages($_) for (@{$self->{'search_path'}});
+        
+        # return blank unless we've found anything
+        return () unless @plugins;
+
+
+        # exceptions
+        my %only;   
+        my %except; 
+        my $only;
+        my $except;
+
+        if (defined $self->{'only'}) {
+            if (ref($self->{'only'}) eq 'ARRAY') {
+                %only   = map { $_ => 1 } @{$self->{'only'}};
+            } elsif (ref($self->{'only'}) eq 'Regexp') {
+                $only = $self->{'only'}
+            } elsif (ref($self->{'only'}) eq '') {
+                $only{$self->{'only'}} = 1;
+            }
+        }
+        
+
+        if (defined $self->{'except'}) {
+            if (ref($self->{'except'}) eq 'ARRAY') {
+                %except   = map { $_ => 1 } @{$self->{'except'}};
+            } elsif (ref($self->{'except'}) eq 'Regexp') {
+                $except = $self->{'except'}
+            } elsif (ref($self->{'except'}) eq '') {
+                $except{$self->{'except'}} = 1;
+            }
+        }
+
+
+        # remove duplicates
+        # probably not necessary but hey ho
+        my %plugins;
+        for(@plugins) {
+            next if (keys %only   && !$only{$_}     );
+            next unless (!defined $only || m!$only! );
+
+            next if (keys %except &&  $except{$_}   );
+            next if (defined $except &&  m!$except! );
+            $plugins{$_} = 1;
+        }
+
+        # are we instantiating or requring?
+        if (defined $self->{'instantiate'}) {
+            my $method = $self->{'instantiate'};
+            return map { ($_->can($method)) ? $_->$method(@_) : () } keys %plugins;
+        } else { 
+            # no? just return the names
+            return keys %plugins;
+        }
+
+
+}
+
+sub search_directories {
+    my $self      = shift;
+    my @SEARCHDIR = @_;
+
+    my @plugins;
+    # go through our @INC
+    foreach my $dir (@SEARCHDIR) {
+        push @plugins, $self->search_paths($dir);
+    }
+
+    return @plugins;
+}
+
+
+sub search_paths {
+    my $self = shift;
+    my $dir  = shift;
+    my @plugins;
+
+    my $file_regex = $self->{'file_regex'} || qr/\.pm$/;
+
+
+    # and each directory in our search path
+    foreach my $searchpath (@{$self->{'search_path'}}) {
+        # create the search directory in a cross platform goodness way
+        my $sp = catdir($dir, (split /::/, $searchpath));
+
+        # if it doesn't exist or it's not a dir then skip it
+        next unless ( -e $sp && -d _ ); # Use the cached stat the second time
+
+        my @files = $self->find_files($sp);
+
+        # foreach one we've found 
+        foreach my $file (@files) {
+            # untaint the file; accept .pm only
+            next unless ($file) = ($file =~ /(.*$file_regex)$/); 
+            # parse the file to get the name
+            my ($name, $directory) = fileparse($file, $file_regex);
+
+            $directory = abs2rel($directory, $sp);
+            # then create the class name in a cross platform way
+            $directory =~ s/^[a-z]://i if($^O =~ /MSWin32|dos/);       # remove volume
+            if ($directory) {
+                ($directory) = ($directory =~ /(.*)/);
+            } else {
+                $directory = "";
+            }
+            my $plugin = join "::", splitdir catdir($searchpath, $directory, $name);
+
+            next unless $plugin =~ m!(?:[a-z\d]+)[a-z\d]!i;
+
+            my $err = eval { $self->handle_finding_plugin($plugin) };
+            carp "Couldn't require $plugin : $err" if $err;
+             
+            push @plugins, $plugin;
+        }
+
+        # now add stuff that may have been in package
+        # NOTE we should probably use all the stuff we've been given already
+        # but then we can't unload it :(
+        push @plugins, $self->handle_innerpackages($searchpath) unless (exists $self->{inner} && !$self->{inner});
+    } # foreach $searchpath
+
+    return @plugins;
+}
+
+sub handle_finding_plugin {
+    my $self   = shift;
+    my $plugin = shift;
+
+    return unless (defined $self->{'instantiate'} || $self->{'require'}); 
+    $self->_require($plugin);
+}
+
+sub find_files {
+    my $self         = shift;
+    my $search_path  = shift;
+    my $file_regex   = $self->{'file_regex'} || qr/\.pm$/;
+
+
+    # find all the .pm files in it
+    # this isn't perfect and won't find multiple plugins per file
+    #my $cwd = Cwd::getcwd;
+    my @files = ();
+    { # for the benefit of perl 5.6.1's Find, localize topic
+        local $_;
+        File::Find::find( { no_chdir => 1, 
+                           wanted => sub { 
+                             # Inlined from File::Find::Rule C< name => '*.pm' >
+                             return unless $File::Find::name =~ /$file_regex/;
+                             (my $path = $File::Find::name) =~ s#^\\./##;
+                             push @files, $path;
+                           }
+                      }, $search_path );
+    }
+    #chdir $cwd;
+    return @files;
+
+}
+
+sub handle_innerpackages {
+    my $self = shift;
+    my $path = shift;
+    my @plugins;
+
+
+    foreach my $plugin (Devel::InnerPackage::list_packages($path)) {
+        my $err = eval { $self->handle_finding_plugin($plugin) };
+        #next if $err;
+        #next unless $INC{$plugin};
+        push @plugins, $plugin;
+    }
+    return @plugins;
+
+}
+
+
+sub _require {
+    my $self = shift;
+    my $pack = shift;
+    eval "CORE::require $pack";
+    return $@;
+}
+
+
+1;
+
+=pod
+
+=head1 NAME
+
+Module::Pluggable::Object - automatically give your module the ability to have plugins
+
+=head1 SYNOPSIS
+
+
+Simple use Module::Pluggable -
+
+    package MyClass;
+    use Module::Pluggable::Object;
+    
+    my $finder = Module::Pluggable::Object->new(%opts);
+    print "My plugins are: ".join(", ", $finder->plugins)."\n";
+
+=head1 DESCRIPTION
+
+Provides a simple but, hopefully, extensible way of having 'plugins' for 
+your module. Obviously this isn't going to be the be all and end all of
+solutions but it works for me.
+
+Essentially all it does is export a method into your namespace that 
+looks through a search path for .pm files and turn those into class names. 
+
+Optionally it instantiates those classes for you.
+
+=head1 AUTHOR
+
+Simon Wistow <simon at thegestalt.org>
+
+=head1 COPYING
+
+Copyright, 2006 Simon Wistow
+
+Distributed under the same terms as Perl itself.
+
+=head1 BUGS
+
+None known.
+
+=head1 SEE ALSO
+
+L<Module::Pluggable>
+
+=cut 
+

Propchange: trunk/server/CPAN/Module/Pluggable/Object.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/CPAN/Module/Pluggable/Object.pm
------------------------------------------------------------------------------
    svn:executable = *

Propchange: trunk/server/CPAN/Module/Pluggable/Object.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/CPAN/Module/Pluggable/Object.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/server/Slim/Web/HTTP.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/HTTP.pm?rev=10628&r1=10627&r2=10628&view=diff
==============================================================================
--- trunk/server/Slim/Web/HTTP.pm (original)
+++ trunk/server/Slim/Web/HTTP.pm Wed Nov  8 13:06:11 2006
@@ -548,6 +548,7 @@
 				}
 			}
 		}
+
 		# process the commands
 		processURL($httpClient, $response, $params);
 
@@ -813,18 +814,21 @@
 		$response->header('Cache-Control' => sprintf('max-age=%d, public', 3600));
 	}
 
-	if ($contentType =~ /text/) {
+	if ($contentType =~ /text/ && $path !~ /memoryusage/) {
+
 		$params->{'params'} = {};
+
 		filltemplatefile('include.html', $params);
 
 		while (my ($key,$value) = each %{$params->{'params'}}) {
+
 			$params->{$key} = $value;
 		}
 
 		delete $params->{'params'};
 	}
 
-	if (ref($pageFunctions{$path}) eq 'CODE') {
+	if (my $classOrCode = $pageFunctions{$path}) {
 
 		# if we match one of the page functions as defined above,
 		# execute that, and hand it a callback to send the data.
@@ -849,13 +853,26 @@
 
 		$::perfmon && (my $startTime = Time::HiRes::time());
 
-		$body = &{$pageFunctions{$path}}(
-			$client,
-			$params,
-			\&prepareResponseForSending,
-			$httpClient,
-			$response,
-		);
+		if (ref($classOrCode) eq 'CODE') {
+
+			$body = &{$classOrCode}(
+				$client,
+				$params,
+				\&prepareResponseForSending,
+				$httpClient,
+				$response,
+			);
+
+		} elsif ($classOrCode->can('handler')) {
+
+			$body = $classOrCode->handler(
+				$client,
+				$params,
+				\&prepareResponseForSending,
+				$httpClient,
+				$response,
+			);
+		}
 		
 		$::perfmon && $startTime && $pageBuild->log(Time::HiRes::time() - $startTime) &&
 			msg(sprintf("    Page: %s\n", $path || '/'), undef, 1);

Modified: trunk/server/Slim/Web/Pages.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Pages.pm?rev=10628&r1=10627&r2=10628&view=diff
==============================================================================
--- trunk/server/Slim/Web/Pages.pm (original)
+++ trunk/server/Slim/Web/Pages.pm Wed Nov  8 13:06:11 2006
@@ -81,18 +81,35 @@
 sub addPageLinks {
 	my ($class, $category, $links, $noquery) = @_;
 
-	return if (ref($links) ne 'HASH');
+	if (ref($links) ne 'HASH') {
+		return;
+	}
 
 	while (my ($title, $path) = each %$links) {
+
 		if (defined($path)) {
-			$additionalLinks{$category}->{$title} = $path . 
-				($noquery ? '' : (($path =~ /\?/) ? '&' : '?' )); #'
+
+			my $separator = '';
+
+			if (!$noquery) {
+
+				if ($path =~ /\?/) {
+					$separator = '&';
+				} else {
+					$separator = '?';
+				}
+			}
+
+			$additionalLinks{$category}->{$title} = $path . $separator;
+
 		} else {
+
 			delete($additionalLinks{$category}->{$title});
 		}
 	}
 
 	if (not keys %{$additionalLinks{$category}}) {
+
 		delete($additionalLinks{$category});
 	}
 }

Added: trunk/server/Slim/Web/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings.pm (added)
+++ trunk/server/Slim/Web/Settings.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,57 @@
+package Slim::Web::Settings;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+# This is a base class for all the server settings pages.
+
+use strict;
+
+use Slim::Utils::Log;
+use Slim::Web::HTTP;
+use Slim::Web::Pages;
+
+sub new {
+	my $class = shift;
+
+	if ($class->can('page') && $class->can('handler')) {
+
+		Slim::Web::HTTP::addPageFunction($class->page, $class);
+	}
+
+	if ($class->can('page') && $class->can('name')) {
+
+		Slim::Web::Pages->addPageLinks('setup', { $class->name => $class->page });
+	}
+}
+
+sub name {
+	my $class = shift;
+
+	return '';
+}
+
+sub page {
+	my $class = shift;
+
+	return '';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	$paramRef->{'page'} = $class->name;
+
+        # Needed to generate the drop down settings chooser list.
+        $paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
+
+	return Slim::Web::HTTP::filltemplatefile($class->page, $paramRef);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/Basic.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Basic.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Basic.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/Basic.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,43 @@
+package Slim::Web::Settings::Server::Basic;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+sub name {
+	return 'BASIC_SERVER_SETTINGS';
+}
+
+sub page {
+	return 'settings/basic.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	# itunes, musicmagic & moodlogic here?
+	my @prefs = qw(language audiodir playlistdir rescantype rescan);
+
+	for my $pref (@prefs) {
+
+		# If this is a settings update
+		if ($paramRef->{'submit'}) {
+
+			Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+		}
+
+		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+	}
+
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/Basic.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/Basic.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/Basic.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/Behavior.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Behavior.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Behavior.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/Behavior.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,74 @@
+package Slim::Web::Settings::Server::Behavior;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+sub name {
+	return 'BEHAVIOR_SETTINGS';
+}
+
+sub page {
+	return 'settings/behavior.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	my @prefs = qw(
+		displaytexttimeout
+		checkVersion
+		noGenreFilter
+		playtrackalbum
+		searchSubString
+		ignoredarticles
+		splitList
+		browseagelimit
+		groupdiscs
+		persistPlaylists
+		reshuffleOnRepeat
+		saveShuffled
+		composerInArtists
+		conductorInArtists
+		bandInArtists
+		variousArtistAutoIdentification
+		useBandAsAlbumArtist
+		variousArtistsString
+	);
+
+	my %scanOn = map { $_ => 1 } qw(splitList ignoredarticles groupDiscs);
+
+	for my $pref (@prefs) {
+
+		# If this is a settings update
+		if ($paramRef->{'submit'}) {
+
+			if (exists $scanOn{$pref} && $paramRef->{$pref} ne Slim::Utils::Prefs::get($pref)) {
+
+				logWarning("$pref changed - starting wipe scan");
+
+				Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+
+				Slim::Control::Request::executeRequest($client, ['wipecache']);
+
+			} else {
+
+				Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+			}
+		}
+
+		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+	}
+	
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/Behavior.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/Behavior.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/Behavior.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/Debugging.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Debugging.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Debugging.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/Debugging.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,71 @@
+package Slim::Web::Settings::Server::Debugging;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+use Slim::Utils::Log;
+use Slim::Utils::Strings qw(string);
+
+sub name {
+	return 'DEBUGGING_SETTINGS';
+}
+
+sub page {
+	return 'settings/debugging.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	# If this is a settings update
+	if ($paramRef->{'submit'}) {
+
+		my $categories = Slim::Utils::Log->allCategories;
+
+		for my $category (keys %{$categories}) {
+
+			Slim::Utils::Log->setLogLevelForCategory(
+				$category, $paramRef->{$category}
+			);
+		}
+
+		# $paramRef might have the overwriteCustomConfig flag.
+		Slim::Utils::Log->reInit($paramRef);
+	}
+
+	# Pull in the dynamic debugging levels.
+	my $debugCategories = Slim::Utils::Log->allCategories;
+	my @validLogLevels  = Slim::Utils::Log->validLevels;
+	my @categories      = (); 
+
+	for my $debugCategory (sort keys %{$debugCategories}) {
+
+		my $string = Slim::Utils::Log->descriptionForCategory($debugCategory);
+
+		push @categories, {
+			'label'   => string($string),
+			'name'    => $debugCategory,
+			'current' => $debugCategories->{$debugCategory},
+		};
+	}
+
+	#$paramRef->{'categories'} = [ sort { $a->{'label'} cmp $b->{'label'} } @categories ];
+	$paramRef->{'categories'} = \@categories;
+	$paramRef->{'logLevels'}  = \@validLogLevels;
+
+	$paramRef->{'debugServerLog'}  = Slim::Utils::Log->serverLogFile;
+	$paramRef->{'debugScannerLog'} = Slim::Utils::Log->scannerLogFile;
+
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/Debugging.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/Debugging.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/Debugging.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/FileTypes.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/FileTypes.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/FileTypes.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/FileTypes.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,112 @@
+package Slim::Web::Settings::Server::FileTypes;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+use Slim::Player::TranscodingHelper;
+use Slim::Utils::Prefs;
+use Slim::Utils::Strings qw(string);
+
+sub name {
+	return 'FORMATS_SETTINGS';
+}
+
+sub page {
+	return 'settings/filetypes.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	# If this is a settings update
+	if ($paramRef->{'submit'}) {
+
+		Slim::Utils::Prefs::set('disabledextensionsaudio',    $paramRef->{'disabledextensionsaudio'});
+		Slim::Utils::Prefs::set('disabledextensionsplaylist', $paramRef->{'disabledextensionsplaylist'});
+
+		my %disabledformats = map { $_ => 1 } Slim::Utils::Prefs::getArray('disabledformats');
+
+		Slim::Utils::Prefs::delete('disabledformats');
+
+		my $formatslistref = Slim::Player::TranscodingHelper::Conversions();
+
+		foreach my $profile (sort {$a cmp $b} (grep {$_ !~ /transcode/} (keys %{$formatslistref}))) {
+			
+			# If the conversion pref is enabled confirm that 
+			# it's allowed to be checked.
+			if ($paramRef->{$profile} ne 'DISABLED' && $disabledformats{$profile}) {
+
+				if (!Slim::Player::TranscodingHelper::checkBin($profile)) {
+
+					$paramRef->{'warning'} .= 
+						string('SETUP_FORMATSLIST_MISSING_BINARY') . " $@ " . string('FOR') ." $profile<br>";
+
+					Slim::Utils::Prefs::push('disabledformats', $profile);
+				}
+
+			} elsif ($paramRef->{$profile} eq 'DISABLED') {
+
+				Slim::Utils::Prefs::push('disabledformats', $profile);
+			}
+		}
+	}
+
+	my %disabledformats = map { $_ => 1 } Slim::Utils::Prefs::getArray('disabledformats');
+	my $formatslistref  = Slim::Player::TranscodingHelper::Conversions();
+	my @formats         = (); 
+
+	for my $profile (sort { $a cmp $b } (grep { $_ !~ /transcode/ } (keys %{$formatslistref}))) {
+
+		my @profileitems = split('-', $profile);
+		my @binaries     = ('DISABLED');
+		
+		# TODO: expand this to handle multiple command lines, but use binary case for now
+		my $enabled = Slim::Player::TranscodingHelper::checkBin($profile) ? 1 : 0;
+		
+		# build setup string from commandTable
+		my $cmdline = $formatslistref->{$profile};
+		my $binstring;
+
+		$cmdline =~ 
+			s{^\[(.*?)\](.*?\|?\[(.*?)\].*?)?}
+			{
+				$binstring = $1;
+				$binstring .= "/".$3 if defined $3;
+			}iegsx;
+
+		if (defined $binstring && $binstring ne '-') {
+
+			push @binaries, $binstring;
+
+		} else {
+
+			push @binaries, 'NATIVE';
+		}
+
+		push @formats, {
+			'profile'  => $profile,
+			'input'    => $profileitems[0],
+			'output'   => $profileitems[1],
+			'binaries' => \@binaries,
+			'enabled'  => $enabled,
+		};
+	}
+	
+	$paramRef->{'formats'} = \@formats;
+
+	$paramRef->{'disabledextensionsaudio'}  = Slim::Utils::Prefs::get('disabledextensionsaudio');
+	$paramRef->{'disabledextensionsplaylist'} = Slim::Utils::Prefs::get('disabledextensionsplaylist');
+
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/FileTypes.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/FileTypes.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/FileTypes.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/Network.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Network.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Network.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/Network.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,136 @@
+package Slim::Web::Settings::Server::Network;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+use Slim::Utils::Misc;
+use Slim::Utils::Prefs;
+use Slim::Utils::Strings qw(string);
+
+sub name {
+	return 'NETWORK_SETTINGS';
+}
+
+sub page {
+	return 'settings/networking.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	my @prefs = qw(
+		webproxy
+		httpport
+		bufferSecs
+		remotestreamtimeout
+		maxWMArate
+		tcpReadMaximum
+		tcpWriteMaximum
+		udpChunkSize
+	);
+
+	my $homeURL = Slim::Utils::Prefs::homeURL();
+
+	# Bug 2724 - only show the mDNS settings if we have a binary for it.
+	if (Slim::Utils::Misc::findbin('mDNSResponderPosix')) {
+
+		push @prefs, 'mDNSname';
+	}
+
+	# If this is a settings update
+	if ($paramRef->{'submit'}) {
+
+		$paramRef->{'warning'} = "";
+
+		if ($paramRef->{'httpport'} ne Slim::Utils::Prefs::get('httpport')) {
+		
+			if ($paramRef->{'httpport'} < 1025)  { $paramRef->{'httpport'}  = 1025 };
+			if ($paramRef->{'httpport'} > 65535) { $paramRef->{'httpport'} = 65535 };
+		
+			Slim::Utils::Prefs::set('httpport', $paramRef->{'httpport'});
+
+			$paramRef->{'warning'} .= join('',
+				string("SETUP_HTTPPORT_OK"),
+				'<blockquote><a target="_top" href="',
+				$homeURL,
+				'">',
+				$homeURL,
+				"</a></blockquote><br>"
+			);
+		}
+
+		for my $pref (@prefs) {
+
+			if ($pref =~ /^tcp/ || $pref eq 'validate') {
+
+				if ($paramRef->{$pref} < 1) {
+
+					$paramRef->{$pref} = 1
+				}
+			}
+
+			if ($pref eq 'bufferSecs') {
+
+				if ($paramRef->{'bufferSecs'} > 30) {
+
+					$paramRef->{'bufferSecs'} = 30
+				}
+
+				if ($paramRef->{'bufferSecs'} < 3) {
+
+					$paramRef->{'bufferSecs'} = 3
+				}
+			}
+
+			if ($pref eq 'udpChunkSize') {
+
+				if ($paramRef->{'udpChunkSize'} < 1) {
+
+					$paramRef->{'udpChunkSize'} = 1
+				}
+
+				if ($paramRef->{'udpChunkSize'} > 4096) {
+
+					$paramRef->{'udpChunkSize'} = 4096
+				}
+			}
+
+			if ($paramRef->{$pref}) {
+
+				Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+			}
+		}
+	}
+
+	for my $pref (@prefs) {
+
+		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+	}
+
+	$paramRef->{'HomeURL'} = $homeURL;
+
+	$paramRef->{'wmaoptions'} =  {
+		'9999' => string('NO_LIMIT'),
+		'320'  => '320 ' . string('KBPS'),
+		'256'  => '256 ' . string('KBPS'),
+		'192'  => '192 ' . string('KBPS'),
+		'160'  => '160 ' . string('KBPS'),
+		'128'  => '128 ' . string('KBPS'),
+		'96'   => '96 ' . string('KBPS'),
+		'64'   => '64 ' . string('KBPS'),
+		'32'   => '32 ' . string('KBPS'),
+	};
+	
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/Network.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/Network.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/Network.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/Performance.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Performance.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Performance.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/Performance.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,52 @@
+package Slim::Web::Settings::Server::Performance;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+sub name {
+	return 'PERFORMANCE_SETTINGS';
+}
+
+sub page {
+	return 'settings/performance.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	my @prefs = qw(disableStatistics itemsPerPass prefsWriteDelay serverPriority scannerPriority);
+
+	$paramRef->{'options'} = {
+		''   => 'SETUP_PRIORITY_CURRENT',
+		map { $_ => {
+			-16 => 'SETUP_PRIORITY_HIGH',
+			 -6 => 'SETUP_PRIORITY_ABOVE_NORMAL',
+			  0 => 'SETUP_PRIORITY_NORMAL',
+			  5 => 'SETUP_PRIORITY_BELOW_NORMAL',
+			  15 => 'SETUP_PRIORITY_LOW'
+			}->{$_} } (-20 .. 20)
+	};
+
+	for my $pref (@prefs) {
+
+		if ($paramRef->{'submit'}) {
+
+			Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+		}
+
+		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+	}
+
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/Performance.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/Performance.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/Performance.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/Security.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/Security.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/Security.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/Security.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,41 @@
+package Slim::Web::Settings::Server::Security;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+sub name {
+	return 'SECURITY_SETTINGS';
+}
+
+sub page {
+	return 'settings/security.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	my @prefs = qw(filterHosts allowedHosts csrfProtectionLevel authorize username password);
+
+	for my $pref (@prefs) {
+
+		if ($paramRef->{'submit'}) {
+
+			Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+		}
+
+		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+	}
+
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/Security.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/Security.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/Security.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/TextFormatting.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/TextFormatting.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/TextFormatting.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/TextFormatting.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,102 @@
+package Slim::Web::Settings::Server::TextFormatting;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+sub name {
+	return 'FORMATTING_SETTINGS';
+}
+
+sub page {
+	return 'settings/formatting.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	my @prefs = qw(
+		guessFileFormats
+		titleFormat
+		titleFormatWeb
+		longdateFormat
+		shortdateFormat
+		timeFormat
+		showArtist
+		showYear
+	);
+
+	# If this is a settings update
+	if ($paramRef->{'submit'}) {
+
+		for my $pref (@prefs) {
+
+			if ($pref eq 'titleFormat' || $pref eq 'guessFileFormats') {
+
+				Slim::Utils::Prefs::delete($pref);
+
+				my $i = 0;
+
+				while ($paramRef->{$pref.$i}) {
+
+					if (!$paramRef->{$pref.$i}) {
+						last;
+					}
+
+					Slim::Utils::Prefs::push($pref,$paramRef->{$pref.$i});
+
+					$i++;
+				}
+				
+			} else {
+
+				if ($paramRef->{'titleformatWeb'} ne Slim::Utils::Prefs::get('titleFormatWeb')) {
+	
+					for my $client (Slim::Player::Client::clients()) {
+
+						$client->currentPlaylistChangeTime(time);
+					}
+				}
+	
+				Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+			}
+			
+		}
+	}
+
+	for my $pref (@prefs) {
+
+		if ($pref eq 'guessFileFormats') {
+
+			$paramRef->{$pref} = [Slim::Utils::Prefs::getArray($pref)];
+
+			push @{$paramRef->{$pref}},"";
+
+		} elsif ($pref eq 'titleFormat') {
+
+			$paramRef->{$pref} = [Slim::Utils::Prefs::getArray($pref)];
+
+			push @{$paramRef->{$pref}},"";
+
+		} else {
+
+			$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+		}
+	}
+	
+	$paramRef->{'longdateoptions'}  = Slim::Utils::DateTime::longDateFormats();
+	$paramRef->{'shortdateoptions'} = Slim::Utils::DateTime::shortDateFormats();
+	$paramRef->{'timeoptions'}      = Slim::Utils::DateTime::timeFormats();
+	
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/TextFormatting.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/TextFormatting.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/TextFormatting.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/server/Slim/Web/Settings/Server/UserInterface.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Settings/Server/UserInterface.pm?rev=10628&view=auto
==============================================================================
--- trunk/server/Slim/Web/Settings/Server/UserInterface.pm (added)
+++ trunk/server/Slim/Web/Settings/Server/UserInterface.pm Wed Nov  8 13:06:11 2006
@@ -1,0 +1,108 @@
+package Slim::Web::Settings::Server::UserInterface;
+
+# $Id$
+
+# SlimServer Copyright (c) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+use Slim::Player::Client;
+use Slim::Utils::Prefs;
+use Slim::Utils::Strings qw(string);
+use Slim::Utils::Validate;
+use Slim::Web::Setup;
+
+sub name {
+	return 'INTERFACE_SETTINGS';
+}
+
+sub page {
+	return 'settings/interface.html';
+}
+
+sub handler {
+	my ($class, $client, $paramRef, $pageSetup) = @_;
+
+	my @prefs = qw(skin itemsPerPage refreshRate coverArt artfolder thumbSize);
+
+	# If this is a settings update
+	if ($paramRef->{'submit'}) {
+
+		$paramRef->{'warning'} = "";
+
+		for my $pref (@prefs) {
+
+			if ($pref eq 'itemsPerPage') {
+
+				if ($paramRef->{'itemsPerPage'} < 1) {
+
+					$paramRef->{'itemsPerPage'} = 1;
+				}
+			}
+			
+			if ($pref eq 'refreshRate') {
+
+				if ($paramRef->{'refreshRate'} < 2) {
+
+					$paramRef->{'refreshRate'} = 2;
+				}
+			}
+
+			if ($pref eq 'thumbSize') {
+
+				if ($paramRef->{'thumbSize'} < 25)  {
+
+					$paramRef->{'thumbSize'} = 25;
+				}
+
+				if ($paramRef->{'thumbSize'} > 250) {
+
+					$paramRef->{'thumbSize'} = 250;
+				}
+			}
+
+			if ($paramRef->{'skin'} ne Slim::Utils::Prefs::get('skin')) {
+
+				$paramRef->{'warning'} .= join(' ', string("SETUP_SKIN_OK"), string("HIT_RELOAD"));
+
+				for my $client (Slim::Player::Client::clients()) {
+
+					$client->currentPlaylistChangeTime(time);
+				}
+			}
+
+			if ($pref eq 'artfolder' && $paramRef->{'artfolder'} ne Slim::Utils::Prefs::get('artfolder')) {
+
+				my ($validDir, $errMsg) = Slim::Utils::Validate::isDir($paramRef->{'artfolder'});
+
+				if (!$validDir && $paramRef->{'artfolder'} ne "") {
+
+					$paramRef->{'warning'} .= sprintf(string("SETUP_BAD_DIRECTORY"), $paramRef->{'artfolder'});
+
+					delete $paramRef->{'artfolder'};
+				}
+			}
+
+			if (exists $paramRef->{$pref}) {
+
+				Slim::Utils::Prefs::set($pref, $paramRef->{$pref});
+			}
+		}
+	}
+
+	for my $pref (@prefs) {
+		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
+	}
+	
+	$paramRef->{'skinoptions'} = { Slim::Web::Setup::skins(1) };
+	
+	return $class->SUPER::handler($client, $paramRef, $pageSetup);
+}
+
+1;
+
+__END__

Propchange: trunk/server/Slim/Web/Settings/Server/UserInterface.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/server/Slim/Web/Settings/Server/UserInterface.pm
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy

Propchange: trunk/server/Slim/Web/Settings/Server/UserInterface.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/server/Slim/Web/Setup.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/Setup.pm?rev=10628&r1=10627&r2=10628&view=diff
==============================================================================
--- trunk/server/Slim/Web/Setup.pm (original)
+++ trunk/server/Slim/Web/Setup.pm Wed Nov  8 13:06:11 2006
@@ -11,6 +11,7 @@
 
 use File::Spec::Functions qw(:ALL);
 use HTTP::Status;
+use Module::Pluggable require => '1', search_path => ['Slim::Web::Settings'];
 
 use Slim::Player::TranscodingHelper;
 use Slim::Utils::Log;
@@ -1560,557 +1561,14 @@
 }
 
 sub initSetup {
+
 	initSetupConfig();
 	fillAlarmOptions();
 
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/debugging\.(?:htm|xml)/,   \&Slim::Web::Setup::handleDebugSettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/filetypes\.(?:htm|xml)/,   \&Slim::Web::Setup::handleFileTypeSettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/performance\.(?:htm|xml)/, \&Slim::Web::Setup::handlePerformanceSettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/behavior\.(?:htm|xml)/,    \&Slim::Web::Setup::handleBehaviorSettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/security\.(?:htm|xml)/,    \&Slim::Web::Setup::handleSecuritySettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/networking\.(?:htm|xml)/,  \&Slim::Web::Setup::handleNetworkingSettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/formatting\.(?:htm|xml)/,  \&Slim::Web::Setup::handleFormattingSettings);
-	Slim::Web::HTTP::addPageFunction(qr/^settings\/interface\.(?:htm|xml)/,   \&Slim::Web::Setup::handleInterfaceSettings);
-	#Slim::Web::HTTP::addPageFunction(qr/^settings\/basic\.(?:htm|xml)/,       \&Slim::Web::Setup::handleBasicServerSettings);
-
-	Slim::Web::Pages->addPageLinks('setup', { "DEBUGGING_SETTINGS"   => 'settings/debugging.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "FORMATS_SETTINGS"     => 'settings/filetypes.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "PERFORMANCE_SETTINGS" => 'settings/performance.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "BEHAVIOR_SETTINGS"    => 'settings/behavior.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "SECURITY_SETTINGS"    => 'settings/security.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "NETWORK_SETTINGS"     => 'settings/networking.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "FORMATTING_SETTINGS"  => 'settings/formatting.html' });
-	Slim::Web::Pages->addPageLinks('setup', { "INTERFACE_SETTINGS"   => 'settings/interface.html' });
-#	Slim::Web::Pages->addPageLinks('setup', { "BASIC_SERVER_SETTINGS" => 'settings/setupbasicserver.html' });
-}
-
-sub handleFileTypeSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		Slim::Utils::Prefs::set('disabledextensionsaudio',    $paramRef->{'disabledextensionsaudio'});
-		Slim::Utils::Prefs::set('disabledextensionsplaylist', $paramRef->{'disabledextensionsplaylist'});
-
-		my %disabledformats = map {$_ => 1} Slim::Utils::Prefs::getArray('disabledformats');
-
-		Slim::Utils::Prefs::delete('disabledformats');
-
-		my $formatslistref = Slim::Player::TranscodingHelper::Conversions();
-
-		foreach my $profile (sort {$a cmp $b} (grep {$_ !~ /transcode/} (keys %{$formatslistref}))) {
-			
-			# If the conversion pref is enabled confirm that 
-			# it's allowed to be checked.
-			if ($paramRef->{"$profile"} ne 'DISABLED' && $disabledformats{$profile}) {
-
-				if (!Slim::Player::TranscodingHelper::checkBin($profile)) {
-
-					$paramRef->{'warning'} .= 
-						string('SETUP_FORMATSLIST_MISSING_BINARY') . " $@ ".string('FOR')." $profile<br>";
-
-					Slim::Utils::Prefs::push('disabledformats',$profile);
-				}
-
-			} elsif ($paramRef->{"$profile"} eq 'DISABLED') {
-
-				Slim::Utils::Prefs::push('disabledformats',$profile);
-			}
-		}
-	}
-
-	my %disabledformats = map {$_ => 1} Slim::Utils::Prefs::getArray('disabledformats');
-	my $formatslistref  = Slim::Player::TranscodingHelper::Conversions();
-	my @formats         = (); 
-
-	foreach my $profile (sort {$a cmp $b} (grep {$_ !~ /transcode/} (keys %{$formatslistref}))) {
-
-		my @profileitems = split('-', $profile);
-		my @binaries = 'DISABLED';
-		
-		# TODO: expand this to handle multiple command lines, but use binary case for now
-		my $enabled = Slim::Player::TranscodingHelper::checkBin($profile) ? 1 : 0;
-		
-		# build setup string from commandTable
-		my $cmdline = $formatslistref->{$profile};
-		my $binstring;
-		$cmdline =~ s{
-				^\[(.*?)\](.*?\|?\[(.*?)\].*?)?
-			}{
-				$binstring = $1;
-				if (defined $3) {$binstring .= "/".$3;}
-			}iegsx;
-		push @binaries, (defined $binstring && $binstring ne '-' ? $binstring : 'NATIVE');
-		
-		push @formats, {
-			'profile'  => $profile,
-			'input'    => $profileitems[0],
-			'output'   => $profileitems[1],
-			'binaries' => \@binaries,
-			'enabled'  => $enabled,
-		};
-	}
-	
-	$paramRef->{'formats'} = \@formats;
-	$paramRef->{'page'}       = 'FORMATS_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	$paramRef->{'disabledextensionsaudio'}  = Slim::Utils::Prefs::get('disabledextensionsaudio');
-	$paramRef->{'disabledextensionsplaylist'} = Slim::Utils::Prefs::get('disabledextensionsplaylist');
-
-	return Slim::Web::HTTP::filltemplatefile('settings\filetypes.html', $paramRef);
-}
-
-sub handleDebugSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		my $categories = Slim::Utils::Log->allCategories;
-
-		for my $category (keys %{$categories}) {
-
-			Slim::Utils::Log->setLogLevelForCategory(
-				$category, $paramRef->{$category}
-			);
-		}
-
-		# $paramRef might have the overwriteCustomConfig flag.
-		Slim::Utils::Log->reInit($paramRef);
-	}
-
-	# Pull in the dynamic debugging levels.
-	my $debugCategories = Slim::Utils::Log->allCategories;
-	my @validLogLevels  = Slim::Utils::Log->validLevels;
-	my @categories      = (); 
-
-	for my $debugCategory (sort keys %{$debugCategories}) {
-
-		my $string = Slim::Utils::Log->descriptionForCategory($debugCategory);
-
-		push @categories, {
-			'label'   => string($string),
-			'name'    => $debugCategory,
-			'current' => $debugCategories->{$debugCategory},
-		};
-	}
-
-	$paramRef->{'page'}       = 'DEBUGGING_SETTINGS';
-	#$paramRef->{'categories'} = [ sort { $a->{'label'} cmp $b->{'label'} } @categories ];
-	$paramRef->{'categories'} = \@categories;
-	$paramRef->{'logLevels'}  = \@validLogLevels;
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	$paramRef->{'debugServerLog'}  = Slim::Utils::Log->serverLogFile;
-	$paramRef->{'debugScannerLog'} = Slim::Utils::Log->scannerLogFile;
-
-	return Slim::Web::HTTP::filltemplatefile('settings\debugging.html', $paramRef);
-}
-
-sub handlePerformanceSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					disableStatistics
-					itemsPerPass
-					prefsWriteDelay
-					serverPriority
-					scannerPriority
-				);
-
-	# Add forking performance options for non-Windows
-	if ( $^O !~ /Win32/ ) {
-
-		push @prefs,
-			'forkedWeb',
-			'forkedStreaming';
-		
-		$paramRef->{'forkingPrefs'} = 1;
-	}
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		for my $pref (@prefs) {
-			Slim::Utils::Prefs::set($pref,    $paramRef->{$pref}) if $paramRef->{$pref};
-		}
-	}
-
-	$paramRef->{'options'} = {
-		''   => 'SETUP_PRIORITY_CURRENT',
-		map {$_ => {
-			-16 => 'SETUP_PRIORITY_HIGH',
-			-6 => 'SETUP_PRIORITY_ABOVE_NORMAL',
-			0 => 'SETUP_PRIORITY_NORMAL',
-			5 => 'SETUP_PRIORITY_BELOW_NORMAL',
-			15 => 'SETUP_PRIORITY_LOW'
-			}->{$_} } (-20 .. 20)
-	};
-
-	$paramRef->{'page'}       = 'PERFORMANCE_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-	}
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/performance.html', $paramRef);
-}
-
-sub handleBasicServerSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					language
-					audiodir
-					playlistdir
-					rescantype
-					rescan
-				);
-				#itunes?
-				#musicmagic?
-				#moodlogic?
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		for my $pref (@prefs) {
-
-			Slim::Utils::Prefs::set($pref,    $paramRef->{$pref});
-		}
-	}
-
-	$paramRef->{'page'}       = 'BASIC_SERVER_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-	}
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/basic.html', $paramRef);
-}
-
-sub handleNetworkingSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					webproxy
-					httpport
-					bufferSecs
-					remotestreamtimeout
-					maxWMArate
-					tcpReadMaximum
-					tcpWriteMaximum
-					udpChunkSize
-				);
-
-	# Bug 2724 - only show the mDNS settings if we have a binary for it.
-	if (Slim::Utils::Misc::findbin('mDNSResponderPosix')) {
-
-		push @prefs, 'mDNSname';
-	}
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		$paramRef->{'warning'} = "";
-
-		if ($paramRef->{'httpport'} ne Slim::Utils::Prefs::get('httpport')) {
-		
-			if ($paramRef->{'httpport'} < 1025)  { $paramRef->{'httpport'}  = 1025 };
-			if ($paramRef->{'httpport'} > 65535) { $paramRef->{'httpport'} = 65535 };
-		
-			Slim::Utils::Prefs::set('httpport', $paramRef->{'httpport'});
-
-			$paramRef->{'warning'} .= string("SETUP_HTTPPORT_OK").'<blockquote><a target="_top" href="'.Slim::Utils::Prefs::homeURL().'">'
-								. Slim::Utils::Prefs::homeURL()."</a></blockquote><br>";
-		}
-
-		for my $pref (@prefs) {
-
-			if ($pref =~ /^tcp/ || $pref eq 'validate') {
-				if ($paramRef->{$pref} < 1) {$paramRef->{$pref} = 1};
-			};
-			
-			if ($pref eq 'bufferSecs') {
-				if ($paramRef->{'bufferSecs'} > 30) {$paramRef->{'bufferSecs'} = 30};
-				if ($paramRef->{'bufferSecs'} < 3) {$paramRef->{'bufferSecs'} = 3};
-			};
-
-			if ($pref eq 'udpChunkSize') {
-				if ($paramRef->{'udpChunkSize'} < 1) {$paramRef->{'udpChunkSize'} = 1};
-				if ($paramRef->{'udpChunkSize'} > 4096) {$paramRef->{'udpChunkSize'} = 4096};
-			};
-
-			Slim::Utils::Prefs::set($pref,    $paramRef->{$pref}) if $paramRef->{$pref};
-
-		}
-	}
-
-	$paramRef->{'page'}       = 'NETWORK_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-	}
-	
-	$paramRef->{'HomeURL'} = Slim::Utils::Prefs::homeURL();
-	
-	$paramRef->{'wmaoptions'} =  {
-								'9999' => string('NO_LIMIT'),
-								'320'  => '320 ' . string('KBPS'),
-								'256'  => '256 ' . string('KBPS'),
-								'192'  => '192 ' . string('KBPS'),
-								'160'  => '160 ' . string('KBPS'),
-								'128'  => '128 ' . string('KBPS'),
-								'96'   => '96 ' . string('KBPS'),
-								'64'   => '64 ' . string('KBPS'),
-								'32'   => '32 ' . string('KBPS'),
-							};
-	
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/networking.html', $paramRef);
-}
-
-sub handleSecuritySettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					filterHosts
-					allowedHosts
-					csrfProtectionLevel
-					authorize
-					username
-					password
-				);
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		for my $pref (@prefs) {
-
-			Slim::Utils::Prefs::set($pref,    $paramRef->{$pref});
-		}
-	}
-
-	$paramRef->{'page'}       = 'SECURITY_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-	}
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/security.html', $paramRef);
-}
-
-sub handleFormattingSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					guessFileFormats
-					titleFormat
-					titleFormatWeb
-					longdateFormat
-					shortdateFormat
-					timeFormat
-					showArtist
-					showYear
-				);
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		for my $pref (@prefs) {
-
-			if ($pref eq 'titleFormat' || $pref eq 'guessFileFormats') {
-			
-				Slim::Utils::Prefs::delete($pref);
-				my $i = 0;
-				
-				while ($paramRef->{$pref.$i}) {
-					last if (!$paramRef->{$pref.$i});
-					Slim::Utils::Prefs::push($pref,$paramRef->{$pref.$i});
-					$i++;
-				}
-				
-			} else {
-				if ($paramRef->{'titleformatWeb'} ne Slim::Utils::Prefs::get('titleFormatWeb')) {
-	
-					for my $client (Slim::Player::Client::clients()) {
-						$client->currentPlaylistChangeTime(time());
-					}
-				}
-	
-				Slim::Utils::Prefs::set($pref,    $paramRef->{$pref});
-			}
-			
-		}
-	}
-
-	$paramRef->{'page'}       = 'FORMATTING_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		if ($pref eq 'guessFileFormats') {
-			$paramRef->{$pref} = [Slim::Utils::Prefs::getArray($pref)];
-			push @{$paramRef->{$pref}},"";
-
-		} elsif ($pref eq 'titleFormat') {
-			$paramRef->{$pref} = [Slim::Utils::Prefs::getArray($pref)];
-			push @{$paramRef->{$pref}},"";
-
-		} else {
-			$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-		}
-	}
-	
-	$paramRef->{'longdateoptions'}  = Slim::Utils::DateTime::longDateFormats;
-	$paramRef->{'shortdateoptions'} = Slim::Utils::DateTime::shortDateFormats;
-	$paramRef->{'timeoptions'}      = Slim::Utils::DateTime::timeFormats;
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/formatting.html', $paramRef);
-}
-
-sub handleInterfaceSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					skin
-					itemsPerPage
-					refreshRate
-					coverArt
-					artfolder
-					thumbSize
-				);
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		$paramRef->{'warning'} = "";
-
-		for my $pref (@prefs) {
-
-			if ($pref eq 'itemsPerPage') {
-				if ($paramRef->{'bufferSecs'} < 1) {$paramRef->{'bufferSecs'} = 1};
-			};
-			
-			if ($pref eq 'refreshRate') {
-				if ($paramRef->{'bufferSecs'} < 2) {$paramRef->{'bufferSecs'} = 2};
-			};
-
-			if ($pref eq 'thumbSize') {
-				if ($paramRef->{'udpChunkSize'} < 25) {$paramRef->{'udpChunkSize'} = 25};
-				if ($paramRef->{'udpChunkSize'} > 250) {$paramRef->{'udpChunkSize'} = 250};
-			};
-			
-			if ($paramRef->{'skin'} ne Slim::Utils::Prefs::get('skin')) {
-				$paramRef->{'warning'} .= string("SETUP_SKIN_OK")." ".string("HIT_RELOAD");
-
-				for my $client (Slim::Player::Client::clients()) {
-					$client->currentPlaylistChangeTime(time());
-				}
-			}
-
-			if ($pref eq 'artfolder' && $paramRef->{'artfolder'} ne Slim::Utils::Prefs::get('artfolder')) {
-				
-				my ($validDir, $errMsg) = Slim::Utils::Validate::isDir($paramRef->{'artfolder'});
-				
-				if (!$validDir && $paramRef->{'artfolder'} ne "") {
-					$paramRef->{'warning'} .= sprintf(string("SETUP_BAD_DIRECTORY"),$paramRef->{'artfolder'});
-
-					delete $paramRef->{'artfolder'};
-				}
-			}
-
-			Slim::Utils::Prefs::set($pref,    $paramRef->{$pref}) if exists $paramRef->{$pref};
-		}
-	}
-
-	$paramRef->{'page'}       = 'INTERFACE_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-	}
-	
-	$paramRef->{'skinoptions'} = {skins(1)};
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/interface.html', $paramRef);
-}
-
-sub handleBehaviorSettings {
-	my ($client, $paramRef, $pageSetup) = @_;
-
-	my @prefs = qw(
-					displaytexttimeout
-					checkVersion
-					noGenreFilter
-					playtrackalbum
-					searchSubString
-					ignoredarticles
-					splitList
-					browseagelimit
-					groupdiscs
-					persistPlaylists
-					reshuffleOnRepeat
-					saveShuffled
-					composerInArtists
-					conductorInArtists
-					bandInArtists
-					variousArtistAutoIdentification
-					useBandAsAlbumArtist
-					variousArtistsString
-				);
-
-	my %scanOn = map {$_ => 1} qw(splitList ignoredarticles groupDiscs);
-
-	# If this is a settings update
-	if ($paramRef->{'submit'}) {
-
-		for my $pref (@prefs) {
-
-			if (exists $scanOn{$pref} && $paramRef->{$pref} ne Slim::Utils::Prefs::get($pref)) {
-
-				logWarning("$pref changed - starting wipe scan");
-
-				Slim::Utils::Prefs::set($pref,    $paramRef->{$pref});
-
-				Slim::Control::Request::executeRequest($client, ['wipecache']);
-			} else {
-
-				Slim::Utils::Prefs::set($pref,    $paramRef->{$pref});
-			}
-		}
-	}
-
-	$paramRef->{'page'}       = 'BEHAVIOR_SETTINGS';
-
-	# Needed to generate the drop down settings chooser list.
-	$paramRef->{'additionalLinks'} = \%Slim::Web::Pages::additionalLinks;
-
-	for my $pref (@prefs) {
-		$paramRef->{$pref} = Slim::Utils::Prefs::get($pref);
-	}
-	
-	return Slim::Web::HTTP::filltemplatefile('settings/behavior.html', $paramRef);
+	for my $plugin (Slim::Web::Setup->plugins) {
+
+		$plugin->new;
+	}
 }
 
 sub getSetupOptions {

Modified: trunk/server/slimserver.pl
URL: http://svn.slimdevices.com/trunk/server/slimserver.pl?rev=10628&r1=10627&r2=10628&view=diff
==============================================================================
--- trunk/server/slimserver.pl (original)
+++ trunk/server/slimserver.pl Wed Nov  8 13:06:11 2006
@@ -296,9 +296,6 @@
 	$log->info("SlimServer strings init...");
 	Slim::Utils::Strings::init();
 
-	$log->info("SlimServer Setup init...");
-	Slim::Web::Setup::initSetup();
-
 	# initialize all player UI subsystems
 	$log->info("SlimServer setting language...");
 	Slim::Utils::Strings::setLanguage(Slim::Utils::Prefs::get("language"));
@@ -381,6 +378,12 @@
 
 	$log->info("SlimServer HTTP init...");
 	Slim::Web::HTTP::init();
+
+	if (!$nosetup) {
+
+		$log->info("SlimServer Web Settings init...");
+		Slim::Web::Setup::initSetup();
+	}
 
 	# otherwise, get ready to loop
 	$lastlooptime = Time::HiRes::time();



More information about the checkins mailing list