[Slim-Checkins] r11748 - in /trunk/server/Slim: Plugin/CLI/ Plugin/DateTime/ Plugin/Favorites/ Plugin/Podcast/ Plugin/RSSNews/ Plugin/RadioIO/ Plugin/RadioIO/HTML/EN/plugins/RadioIO/settings/ Plugin/RadioTime/ Plugin/RandomPlay/ Plugin/Rescan/ Plugin/Rescan/HTML/EN/plugins/Rescan/settings/ Plugin/xPL/ Utils/ Utils/Prefs/
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Wed Apr 11 15:03:49 PDT 2007
Author: adrian
Date: Wed Apr 11 15:03:49 2007
New Revision: 11748
URL: http://svn.slimdevices.com?rev=11748&view=rev
Log:
Bug: N/A
Description: move all plugin preferences to plugin.* namespaces and
save these in a separate folder.
Migrate RadioIO and Rescan to new preference scheme.
Modified:
trunk/server/Slim/Plugin/CLI/Plugin.pm
trunk/server/Slim/Plugin/CLI/Settings.pm
trunk/server/Slim/Plugin/DateTime/Plugin.pm
trunk/server/Slim/Plugin/DateTime/Settings.pm
trunk/server/Slim/Plugin/Favorites/Plugin.pm
trunk/server/Slim/Plugin/Favorites/Settings.pm
trunk/server/Slim/Plugin/Podcast/Plugin.pm
trunk/server/Slim/Plugin/Podcast/Settings.pm
trunk/server/Slim/Plugin/RSSNews/Plugin.pm
trunk/server/Slim/Plugin/RSSNews/Settings.pm
trunk/server/Slim/Plugin/RadioIO/HTML/EN/plugins/RadioIO/settings/basic.html
trunk/server/Slim/Plugin/RadioIO/Plugin.pm
trunk/server/Slim/Plugin/RadioIO/Settings.pm
trunk/server/Slim/Plugin/RadioTime/Plugin.pm
trunk/server/Slim/Plugin/RadioTime/Settings.pm
trunk/server/Slim/Plugin/RandomPlay/Plugin.pm
trunk/server/Slim/Plugin/Rescan/HTML/EN/plugins/Rescan/settings/basic.html
trunk/server/Slim/Plugin/Rescan/Plugin.pm
trunk/server/Slim/Plugin/Rescan/Settings.pm
trunk/server/Slim/Plugin/xPL/Plugin.pm
trunk/server/Slim/Plugin/xPL/Settings.pm
trunk/server/Slim/Utils/Prefs.pm
trunk/server/Slim/Utils/Prefs/Namespace.pm
Modified: trunk/server/Slim/Plugin/CLI/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/CLI/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/CLI/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/CLI/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -60,7 +60,7 @@
'description' => 'PLUGIN_CLI',
});
-my $prefs = preferences('cli');
+my $prefs = preferences('plugin.cli');
################################################################################
# PLUGIN CODE
Modified: trunk/server/Slim/Plugin/CLI/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/CLI/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/CLI/Settings.pm (original)
+++ trunk/server/Slim/Plugin/CLI/Settings.pm Wed Apr 11 15:03:49 2007
@@ -10,7 +10,7 @@
use Slim::Utils::Prefs;
-my $prefs = preferences('cli');
+my $prefs = preferences('plugin.cli');
$prefs->migrate(1, sub {
$prefs->set('cliport', Slim::Utils::Prefs::OldPrefs->get('cliport') || 9090); 1;
Modified: trunk/server/Slim/Plugin/DateTime/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/DateTime/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/DateTime/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/DateTime/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -12,7 +12,7 @@
use Slim::Plugin::DateTime::Settings;
-my $prefs = preferences('datetime');
+my $prefs = preferences('plugin.datetime');
sub getDisplayName {
return 'PLUGIN_SCREENSAVER_DATETIME';
Modified: trunk/server/Slim/Plugin/DateTime/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/DateTime/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/DateTime/Settings.pm (original)
+++ trunk/server/Slim/Plugin/DateTime/Settings.pm Wed Apr 11 15:03:49 2007
@@ -10,7 +10,7 @@
use Slim::Utils::Prefs;
-my $prefs = preferences('datetime');
+my $prefs = preferences('plugin.datetime');
$prefs->migrate(1, sub {
$prefs->set('timeformat', Slim::Utils::Prefs::OldPrefs->get('screensaverTimeFormat') || '');
Modified: trunk/server/Slim/Plugin/Favorites/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Favorites/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Favorites/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Favorites/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -34,7 +34,7 @@
my $log = logger('favorites');
-my $prefs = preferences('favorites');
+my $prefs = preferences('plugin.favorites');
sub initPlugin {
my $class = shift;
Modified: trunk/server/Slim/Plugin/Favorites/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Favorites/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Favorites/Settings.pm (original)
+++ trunk/server/Slim/Plugin/Favorites/Settings.pm Wed Apr 11 15:03:49 2007
@@ -10,7 +10,7 @@
use Slim::Utils::Prefs;
-my $prefs = preferences('favorites');
+my $prefs = preferences('plugin.favorites');
sub name {
return 'FAVORITES';
Modified: trunk/server/Slim/Plugin/Podcast/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Podcast/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Podcast/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Podcast/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -27,7 +27,7 @@
'description' => getDisplayName(),
});
-my $prefs = preferences('podcast');
+my $prefs = preferences('plugin.podcast');
use Slim::Plugin::Podcast::Settings;
Modified: trunk/server/Slim/Plugin/Podcast/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Podcast/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Podcast/Settings.pm (original)
+++ trunk/server/Slim/Plugin/Podcast/Settings.pm Wed Apr 11 15:03:49 2007
@@ -12,7 +12,7 @@
use Slim::Utils::Prefs;
my $log = logger('plugin.podcast');
-my $prefs = preferences('podcast');
+my $prefs = preferences('plugin.podcast');
use constant FEED_VERSION => 2; # bump this number when changing the defaults below
Modified: trunk/server/Slim/Plugin/RSSNews/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RSSNews/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RSSNews/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/RSSNews/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -34,7 +34,7 @@
use Slim::Plugin::RSSNews::Settings;
-my $prefs = preferences('rssnews');
+my $prefs = preferences('plugin.rssnews');
# $refresh_sec is the minimum time in seconds between refreshes of the ticker from the RSS.
# Please do not lower this value. It prevents excessive queries to the RSS.
Modified: trunk/server/Slim/Plugin/RSSNews/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RSSNews/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RSSNews/Settings.pm (original)
+++ trunk/server/Slim/Plugin/RSSNews/Settings.pm Wed Apr 11 15:03:49 2007
@@ -12,7 +12,7 @@
use Slim::Utils::Prefs;
my $log = logger('plugin.rssnews');
-my $prefs = preferences('rssnews');
+my $prefs = preferences('plugin.rssnews');
use constant FEED_VERSION => 2; # bump this number when changing the defaults below
Modified: trunk/server/Slim/Plugin/RadioIO/HTML/EN/plugins/RadioIO/settings/basic.html
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RadioIO/HTML/EN/plugins/RadioIO/settings/basic.html?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RadioIO/HTML/EN/plugins/RadioIO/settings/basic.html (original)
+++ trunk/server/Slim/Plugin/RadioIO/HTML/EN/plugins/RadioIO/settings/basic.html Wed Apr 11 15:03:49 2007
@@ -4,14 +4,14 @@
<div class="prefHead">[% "SETUP_PLUGIN_RADIOIO_USERNAME" | string | upper %]</div>
<div class="prefDesc">[% "SETUP_PLUGIN_RADIOIO_USERNAME_DESC" | string %]</div>
- <input type="text" class="stdedit" name="plugin_radioio_username" id="plugin_radioio_username" value="[% prefs.plugin_radioio_username %]" size="40">
+ <input type="text" class="stdedit" name="username" value="[% prefs.username %]" size="40">
</div>
<div class="settingSection">
<div class="prefHead">[% "SETUP_PLUGIN_RADIOIO_PASSWORD" | string | upper %]</div>
<div class="prefDesc">[% "SETUP_PLUGIN_RADIOIO_PASSWORD_DESC" | string %]</div>
- <input type="password" class="stdedit" name="plugin_radioio_password" id="plugin_radioio_password" value="[% prefs.plugin_radioio_password %]" size="40">
+ <input type="password" class="stdedit" name="password" value="[% prefs.password %]" size="40">
</div>
Modified: trunk/server/Slim/Plugin/RadioIO/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RadioIO/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RadioIO/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/RadioIO/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -25,8 +25,11 @@
use Slim::Player::ProtocolHandlers;
use Slim::Utils::Strings qw( string );
use Slim::Web::XMLBrowser;
+use Slim::Utils::Prefs;
use Slim::Plugin::RadioIO::ProtocolHandler;
+
+my $prefs = preferences('plugin.radioio');
my $FEED = 'http://www.radioio.com/opml/channelsLOGIN.php?device=Squeezebox&speed=high';
my $cli_next;
@@ -86,16 +89,8 @@
sub radioIOURL {
my $client = shift;
- my ($username, $password);
-
- if ( $ENV{SLIM_SERVICE} ) {
- $username = $client->prefGet('plugin_radioio_username', undef, 1);
- $password = $client->prefGet('plugin_radioio_password', undef, 1);
- }
- else {
- $username = Slim::Utils::Prefs::get('plugin_radioio_username');
- $password = Slim::Utils::Prefs::get('plugin_radioio_password');
- }
+ my $username = $prefs->get('username');
+ my $password = $prefs->get('password');
my $url = $FEED;
Modified: trunk/server/Slim/Plugin/RadioIO/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RadioIO/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RadioIO/Settings.pm (original)
+++ trunk/server/Slim/Plugin/RadioIO/Settings.pm Wed Apr 11 15:03:49 2007
@@ -8,44 +8,42 @@
use strict;
use base qw(Slim::Web::Settings);
+use Slim::Utils::Prefs;
+
+my $prefs = preferences('plugin.radioio');
+
+$prefs->migrate(1, sub {
+ $prefs->set('username', Slim::Utils::Prefs::OldPrefs->get('plugin_radioio_username'));
+ $prefs->set('password', Slim::Utils::Prefs::OldPrefs->get('plugin_radioio_password'));
+ 1;
+});
+
sub name {
- return 'PLUGIN_RADIOIO_MODULE_NAME';
+ return 'PLUGIN_RADIOIO_MODULE_NAME';
}
sub page {
- return 'plugins/RadioIO/settings/basic.html';
+ return 'plugins/RadioIO/settings/basic.html';
+}
+
+sub prefs {
+ return ($prefs, qw(username password));
}
sub handler {
- my ($class, $client, $params) = @_;
+ my ($class, $client, $params) = @_;
- my @prefs = qw(
- plugin_radioio_username
- plugin_radioio_password
- );
+ if ($params->{'saveSettings'}) {
- for my $pref (@prefs) {
+ if ($params->{'password'}) {
- if ($params->{'saveSettings'}) {
+ $params->{'password'} = MIME::Base64::encode_base64($params->{'password'});
- if ($pref eq 'plugin_radioio_password') {
+ chomp($params->{'password'});
+ }
+ }
- $params->{$pref} = MIME::Base64::encode_base64($params->{$pref});
- chomp($params->{$pref});
- }
-
- Slim::Utils::Prefs::set($pref, $params->{$pref});
- }
-
- # Do we want to display the password?
- if ($pref eq 'plugin_radioio_password') {
- next;
- }
-
- $params->{'prefs'}->{$pref} = Slim::Utils::Prefs::get($pref);
- }
-
- return $class->SUPER::handler($client, $params);
+ return $class->SUPER::handler($client, $params);
}
1;
Modified: trunk/server/Slim/Plugin/RadioTime/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RadioTime/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RadioTime/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/RadioTime/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -34,7 +34,7 @@
'description' => getDisplayName(),
});
-my $prefs = preferences('radiotime');
+my $prefs = preferences('plugin.radiotime');
sub initPlugin {
my $class = shift;
Modified: trunk/server/Slim/Plugin/RadioTime/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RadioTime/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RadioTime/Settings.pm (original)
+++ trunk/server/Slim/Plugin/RadioTime/Settings.pm Wed Apr 11 15:03:49 2007
@@ -10,7 +10,7 @@
use Slim::Utils::Prefs;
-my $prefs = preferences('radiotime');
+my $prefs = preferences('plugin.radiotime');
$prefs->migrate(1, sub {
$prefs->set('username', Slim::Utils::Prefs::OldPrefs->get('plugin_radiotime_username')); 1;
Modified: trunk/server/Slim/Plugin/RandomPlay/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RandomPlay/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RandomPlay/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/RandomPlay/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -43,7 +43,7 @@
'description' => getDisplayName(),
});
-my $prefs = preferences('randomplay');
+my $prefs = preferences('plugin.randomplay');
$prefs->migrate(1, sub {
$prefs->set('newtracks', Slim::Utils::Prefs::OldPrefs->get('plugin_random_number_of_tracks') || 10 );
Modified: trunk/server/Slim/Plugin/Rescan/HTML/EN/plugins/Rescan/settings/basic.html
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Rescan/HTML/EN/plugins/Rescan/settings/basic.html?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Rescan/HTML/EN/plugins/Rescan/settings/basic.html (original)
+++ trunk/server/Slim/Plugin/Rescan/HTML/EN/plugins/Rescan/settings/basic.html Wed Apr 11 15:03:49 2007
@@ -7,33 +7,33 @@
<table border="0" cellspacing="7" cellpaddding="7">
<tr>
- <td><label for="rescan-scheduled">[% "PLUGIN_RESCAN_TIMER_NAME" | string %]</label></td>
+ <td><label for="scheduled">[% "PLUGIN_RESCAN_TIMER_NAME" | string %]</label></td>
<td>
- <select name="rescan-scheduled">
+ <select name="scheduled">
- <option value="1" [% IF prefs.rescanScheduled %]selected[% END %]>[% "ON" | string %]</option>
- <option value="0" [% IF NOT prefs.rescanScheduled %]selected[% END %]>[% "OFF" | string %]</option>
+ <option value="1" [% IF prefs.scheduled %]selected[% END %]>[% "ON" | string %]</option>
+ <option value="0" [% IF NOT prefs.scheduled %]selected[% END %]>[% "OFF" | string %]</option>
</select>
</td>
</tr>
<tr>
- <td><label for="rescan-time">[% "PLUGIN_RESCAN_TIMER_SET" | string %]</label></td>
+ <td><label for="time">[% "PLUGIN_RESCAN_TIMER_SET" | string %]</label></td>
<td>
- <input type="text" class="stdedit" name="rescan-time" id="rescan-time" value="[% prefs.rescanTime %]" size="10" />
+ <input type="text" class="stdedit" name="time" value="[% prefs.time %]" size="10" />
</td>
</tr>
<tr>
- <td><label for="rescan-type">[% "PLUGIN_RESCAN_TIMER_TYPE" | string %]</label></td>
+ <td><label for="type">[% "PLUGIN_RESCAN_TIMER_TYPE" | string %]</label></td>
<td>
- <select name="rescan-type">
+ <select name="type">
- <option value="1rescan" [% IF prefs.rescanType == "1rescan" %]selected[% END %]>[% "SETUP_STANDARDRESCAN" | string %]</option>
- <option value="2wipedb" [% IF prefs.rescanType == "2wipedb" %]selected[% END %]>[% "SETUP_WIPEDB" | string %]</option>
- <option value="3playlist" [% IF prefs.rescanType == "3playlist" %]selected[% END %]>[% "SETUP_PLAYLISTRESCAN" | string %]</option>
+ <option value="1rescan" [% IF prefs.type == "1rescan" %]selected[% END %]>[% "SETUP_STANDARDRESCAN" | string %]</option>
+ <option value="2wipedb" [% IF prefs.type == "2wipedb" %]selected[% END %]>[% "SETUP_WIPEDB" | string %]</option>
+ <option value="3playlist" [% IF prefs.type == "3playlist" %]selected[% END %]>[% "SETUP_PLAYLISTRESCAN" | string %]</option>
</select>
</td>
Modified: trunk/server/Slim/Plugin/Rescan/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Rescan/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Rescan/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Rescan/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -22,6 +22,9 @@
use Slim::Control::Request;
use Slim::Utils::Log;
+use Slim::Utils::Prefs;
+
+my $prefs = preferences('plugin.rescan');
our $interval = 1; # check every x seconds
our @browseMenuChoices;
@@ -83,12 +86,6 @@
'PLUGIN_RESCAN_PRESS_PLAY',
);
- # get previous alarm time or set a default
- if (!defined Slim::Utils::Prefs::get("rescan-time")) {
-
- Slim::Utils::Prefs::set("rescan-time", 9 * 60 * 60 );
- }
-
if ( Slim::Music::Import->stillScanning ) {
Slim::Buttons::Common::pushMode($client, 'scanProgress');
@@ -110,10 +107,11 @@
if($_[1] =~ /PLUGIN_RESCAN_TIMER_O/) {
- return (undef, Slim::Buttons::Common::checkBoxOverlay( $client, Slim::Utils::Prefs::get("rescan-scheduled")));
+ return (undef, Slim::Buttons::Common::checkBoxOverlay( $client, $prefs->get('scheduled')));
+
} elsif ($_[1] ne 'PLUGIN_RESCAN_PRESS_PLAY') {
- return (undef, $_[0]->symbols('rightarrow'))
+ return (undef, $_[0]->symbols('rightarrow'))
}
},
@@ -122,7 +120,7 @@
my $client = shift;
my $value = shift;
- if (Slim::Utils::Prefs::get("rescan-scheduled") && $value eq 'PLUGIN_RESCAN_TIMER_OFF') {
+ if ($prefs->get('scheduled') && $value eq 'PLUGIN_RESCAN_TIMER_OFF') {
return $client->string('PLUGIN_RESCAN_TIMER_ON');
}
@@ -297,13 +295,13 @@
my $valueref = $client->modeParam('valueRef');
if ($$valueref eq 'PLUGIN_RESCAN_TIMER_SET') {
- my $value = Slim::Utils::Prefs::get("rescan-time");
+ my $value = $prefs->get('time');
my %params = (
'header' => $client->string('PLUGIN_RESCAN_TIMER_SET'),
'valueRef' => \$value,
'cursorPos' => 1,
- 'pref' => 'rescan-time',
+ 'pref' => 'time',
'callback' => \&settingsExitHandler
);
@@ -311,20 +309,21 @@
} elsif ($$valueref eq 'PLUGIN_RESCAN_TIMER_OFF') {
- Slim::Utils::Prefs::set("rescan-scheduled", 1);
+ $prefs->set('scheduled', 1);
$$valueref = 'PLUGIN_RESCAN_TIMER_ON';
setTimer($client);
$client->update;
} elsif ($$valueref eq 'PLUGIN_RESCAN_TIMER_ON') {
- Slim::Utils::Prefs::set("rescan-scheduled", 0);
+ $prefs->set('scheduled', 0);
$$valueref = 'PLUGIN_RESCAN_TIMER_OFF';
setTimer($client);
$client->update;
} elsif ($$valueref eq 'PLUGIN_RESCAN_TIMER_TYPE') {
- my $value = Slim::Utils::Prefs::get("rescan-type");
+
+ my $value = $prefs->get('type');
my %params = (
'listRef' => [
@@ -341,11 +340,11 @@
value => '3playlist',
},
],
- 'onPlay' => sub { Slim::Utils::Prefs::set("rescan-type",$_[1]->{'value'}); },
- 'onAdd' => sub { Slim::Utils::Prefs::set("rescan-type",$_[1]->{'value'}); },
- 'onRight' => sub { Slim::Utils::Prefs::set("rescan-type",$_[1]->{'value'}); },
+ 'onPlay' => sub { $prefs->set('type', $_[1]->{'value'}); },
+ 'onAdd' => sub { $prefs->set('type', $_[1]->{'value'}); },
+ 'onRight' => sub { $prefs->set('type', $_[1]->{'value'}); },
'header' => '{PLUGIN_RESCAN_TIMER_TYPE}{count}',
- 'pref' => sub { return Slim::Utils::Prefs::get("rescan-type"); },
+ 'pref' => sub { return $prefs->get('type'); },
'valueRef' => \$value,
);
@@ -366,7 +365,7 @@
if ($exittype eq 'LEFT') {
- Slim::Utils::Prefs::set($client->modeParam('pref'),${$client->modeParam('valueRef')});
+ $prefs->set($client->modeParam('pref'), ${$client->modeParam('valueRef')});
Slim::Buttons::Common::popModeRight($client);
@@ -403,9 +402,9 @@
$interval = 1;
}
- if (Slim::Utils::Prefs::get("rescan-scheduled")) {
-
- my $scantime = Slim::Utils::Prefs::get("rescan-time");
+ if ($prefs->get('scheduled')) {
+
+ my $scantime = $prefs->get('time');
if ($scantime && $time == $scantime) {
@@ -426,7 +425,7 @@
my $client = shift;
my $rescanType = ['rescan'];
- my $rescanPref = Slim::Utils::Prefs::get('rescan-type') || '';
+ my $rescanPref = $prefs->get('type') || '';
if ($rescanPref eq '2wipedb') {
Modified: trunk/server/Slim/Plugin/Rescan/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Rescan/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Rescan/Settings.pm (original)
+++ trunk/server/Slim/Plugin/Rescan/Settings.pm Wed Apr 11 15:03:49 2007
@@ -8,55 +8,40 @@
use strict;
use base qw(Slim::Web::Settings);
+use Slim::Utils::Prefs;
use Slim::Utils::DateTime;
+my $prefs = preferences('plugin.rescan');
+
+$prefs->migrate(1, sub {
+ $prefs->set('time', Slim::Utils::Prefs::OldPrefs->get('rescan-time') || 9 * 60 * 60 );
+ $prefs->set('scheduled', Slim::Utils::Prefs::OldPrefs->get('rescan-scheduled') || 0 );
+ $prefs->set('type', Slim::Utils::Prefs::OldPrefs->get('rescan-type') || '1rescan' );
+ 1;
+});
+
sub name {
- return 'PLUGIN_RESCAN_MUSIC_LIBRARY';
+ return 'PLUGIN_RESCAN_MUSIC_LIBRARY';
}
sub page {
- return 'plugins/Rescan/settings/basic.html';
+ return 'plugins/Rescan/settings/basic.html';
+}
+
+sub prefs {
+ return ($prefs, qw(scheduled type) );
}
sub handler {
- my ($class, $client, $params) = @_;
+ my ($class, $client, $params) = @_;
- my @prefs = qw(
- rescan-scheduled
- rescan-time
- rescan-type
- );
+ if ($params->{'saveSettings'} && $params->{'time'}) {
+ $prefs->set('time', Slim::Utils::DateTime::prettyTimeToSecs($params->{'time'}));
+ }
- for my $pref (@prefs) {
+ $params->{'prefs'}->{'time'} = Slim::Utils::DateTime::secsToPrettyTime($prefs->get('time'));
- if ($params->{'saveSettings'}) {
-
- if ($pref eq 'rescan-time') {
-
- $params->{$pref} = Slim::Utils::DateTime::prettyTimeToSecs($params->{$pref});
- }
-
- Slim::Utils::Prefs::set($pref, $params->{$pref});
- }
-
- $params->{'prefs'}->{$pref} = Slim::Utils::Prefs::get($pref);
-
- if ($pref eq 'rescan-time') {
-
- $params->{'prefs'}->{$pref} = Slim::Utils::DateTime::secsToPrettyTime(
- $params->{'prefs'}->{$pref}
- );
- }
-
- # Hack prefs - Template Toolkit doesn't like the dashes.
- my $value = delete $params->{'prefs'}->{$pref};
-
- $pref =~ s/-(\w)/\u$1/;
-
- $params->{'prefs'}->{$pref} = $value;
- }
-
- return $class->SUPER::handler($client, $params);
+ return $class->SUPER::handler($client, $params);
}
1;
Modified: trunk/server/Slim/Plugin/xPL/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/xPL/Plugin.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/xPL/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/xPL/Plugin.pm Wed Apr 11 15:03:49 2007
@@ -41,7 +41,7 @@
'description' => getDisplayName(),
});
-my $prefs = preferences('xpl');
+my $prefs = preferences('plugin.xpl');
################################################################################
# PLUGIN CODE
Modified: trunk/server/Slim/Plugin/xPL/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/xPL/Settings.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/xPL/Settings.pm (original)
+++ trunk/server/Slim/Plugin/xPL/Settings.pm Wed Apr 11 15:03:49 2007
@@ -10,7 +10,7 @@
use Slim::Utils::Prefs;
-my $prefs = preferences('xpl');
+my $prefs = preferences('plugin.xpl');
$prefs->migrate(1, sub {
$prefs->set('interval', Slim::Utils::Prefs::OldPrefs->get('xplinterval') || 5);
Modified: trunk/server/Slim/Utils/Prefs.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Prefs.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Prefs.pm (original)
+++ trunk/server/Slim/Utils/Prefs.pm Wed Apr 11 15:03:49 2007
@@ -1245,7 +1245,7 @@
use Slim::Utils::Pres;
-my $prefs = preferences('demo');
+my $prefs = preferences('plugin.demo');
$prefs->set('pref1', 1); or $prefs->pref1(1);
@@ -1275,6 +1275,8 @@
Supports both global and client preferences within a namespace.
This implementation stores preferences in YAML files with one YAML file per namespace.
+Namespaces of the form 'dir.name' are saved as filename 'name.prefs' in sub directory 'dir'.
+Preferences for plugins are expected to be stored in namespaces prefixed by 'plugin.'
=head2 Each preference may be associated with:
@@ -1286,6 +1288,67 @@
=item migration functions to update preferences to a new version number
(each namespace has a global and per client version number)
+
+=head1 METHODS
+
+=cut
+
+use Slim::Utils::Prefs::Namespace;
+use Slim::Utils::Prefs::OldPrefs;
+
+use Exporter::Lite;
+
+our @EXPORT = qw(preferences);
+
+my $path = Slim::Utils::OSDetect::dirsFor('prefs');
+
+my $prefs = preferences('server');
+
+my %namespaces;
+
+=head2 preferences( $namespace )
+
+Returns a prefs object for the namespace $namespace.
+
+It is usual to prefix plugin namespaces with "plugin.", e.g. preferences('plugin.demo').
+
+=cut
+
+sub preferences {
+ my $namespace = shift;
+
+ return $namespaces{$namespace} ||= Slim::Utils::Prefs::Namespace->new($namespace, $path);
+}
+
+=head2 namespaces( )
+
+Returns an array of all active preference namespaces.
+
+=cut
+
+sub namespaces {
+ return [ keys %namespaces ];
+}
+
+sub init_new {
+ $prefs->migrate(1, sub {
+ unless (-d $path) {
+ mkdir $path;
+ }
+
+ unless (-d $path) {
+ logError("can't create new preferences directory at $path");
+ }
+
+ 0;
+ });
+}
+
+sub writeAll {
+ for my $n (values %namespaces) {
+ $n->savenow;
+ }
+}
=head2 SEE ALSO
@@ -1296,49 +1359,6 @@
=cut
-use Slim::Utils::Prefs::Namespace;
-use Slim::Utils::Prefs::OldPrefs;
-
-use Exporter::Lite;
-
-our @EXPORT = qw(preferences);
-
-my $path = Slim::Utils::OSDetect::dirsFor('prefs');
-
-my $prefs = preferences('server');
-
-my %namespaces;
-
-sub preferences {
- my $namespace = shift;
-
- return $namespaces{$namespace} ||= Slim::Utils::Prefs::Namespace->new($namespace, $path);
-}
-
-sub init_new {
- $prefs->migrate(1, sub {
- unless (-d $path) {
- mkdir $path;
- }
-
- unless (-d $path) {
- logError("can't create new preferences directory at $path");
- }
-
- 0;
- });
-}
-
-sub namespaces {
- return [ keys %namespaces ];
-}
-
-sub writeAll {
- for my $n (values %namespaces) {
- $n->savenow;
- }
-}
-
1;
__END__
Modified: trunk/server/Slim/Utils/Prefs/Namespace.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Prefs/Namespace.pm?rev=11748&r1=11747&r2=11748&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Prefs/Namespace.pm (original)
+++ trunk/server/Slim/Utils/Prefs/Namespace.pm Wed Apr 11 15:03:49 2007
@@ -49,9 +49,20 @@
my $namespace = shift;
my $path = shift;
+ my $filename;
+
+ # split namespace into dir and filename if appropriate
+ if ($namespace =~ /(.*)\.(.*)/) {
+ $path = catdir($path, $1);
+ $filename = catdir($path, "$2.prefs");
+ mkdir $path unless -d $path;
+ } else {
+ $filename = catdir($path, "$namespace.prefs");
+ }
+
my $class = bless {
'namespace' => $namespace,
- 'file' => catdir($path, "$namespace.prefs"),
+ 'file' => $filename,
'clients' => {},
'validators'=> {},
'validparam'=> {},
More information about the checkins
mailing list