[Slim-Checkins] r11416 - in /trunk/server/Slim: Buttons/BrowseDB.pm Buttons/Common.pm Buttons/RemoteTrackInfo.pm Buttons/TrackInfo.pm Plugin/Favorites/OpmlFavorites.pm Utils/Favorites.pm
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Mon Feb 12 13:14:31 PST 2007
Author: adrian
Date: Mon Feb 12 13:14:31 2007
New Revision: 11416
URL: http://svn.slimdevices.com?rev=11416&view=rev
Log:
Bug: N/A
Description: change favorites api to allow for per client opml files if required
Modified:
trunk/server/Slim/Buttons/BrowseDB.pm
trunk/server/Slim/Buttons/Common.pm
trunk/server/Slim/Buttons/RemoteTrackInfo.pm
trunk/server/Slim/Buttons/TrackInfo.pm
trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm
trunk/server/Slim/Utils/Favorites.pm
Modified: trunk/server/Slim/Buttons/BrowseDB.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/BrowseDB.pm?rev=11416&r1=11415&r2=11416&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/BrowseDB.pm (original)
+++ trunk/server/Slim/Buttons/BrowseDB.pm Mon Feb 12 13:14:31 2007
@@ -393,7 +393,7 @@
} elsif ($currentItem eq 'FAVORITE') {
- my $favorites = Slim::Utils::Favorites->new;
+ my $favorites = Slim::Utils::Favorites->new($client);
my $index = $client->modeParam('favorite');
my $track = Slim::Schema->find('Track', $client->modeParam('findCriteria')->{'playlist.id'});
@@ -410,7 +410,7 @@
if (!$index) {
- $index = $favorites->clientAdd($client, $track, $track->title);
+ $index = $favorites->add($track, $track->title);
$client->showBriefly( {
'line' => [ $client->string('FAVORITES_ADDING'), $track->title ]
@@ -420,7 +420,7 @@
} else {
- $favorites->deleteByClientAndId($client, $index);
+ $favorites->deleteIndex($index);
$client->showBriefly( {
'line' => [ $client->string('FAVORITES_DELETING'), $track->title ]
@@ -799,7 +799,7 @@
if (blessed($track) && $track->can('id')) {
- my $fav = Slim::Utils::Favorites->new->findByClientAndURL($client, $track);
+ my $fav = Slim::Utils::Favorites->new($client)->findUrl($track);
$client->modeParam('favorite', $fav ? $fav->{'index'} : undef);
Modified: trunk/server/Slim/Buttons/Common.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Common.pm?rev=11416&r1=11415&r2=11416&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Common.pm (original)
+++ trunk/server/Slim/Buttons/Common.pm Mon Feb 12 13:14:31 2007
@@ -812,7 +812,7 @@
}
if ($url && $title) {
- Slim::Utils::Favorites->new->clientAdd($client, $url, $title);
+ Slim::Utils::Favorites->new($client)->add($url, $title);
$client->showBriefly($client->string('FAVORITES_ADDING'), $title);
# if all of that fails, send the debug with a best guess helper for tracing back
Modified: trunk/server/Slim/Buttons/RemoteTrackInfo.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/RemoteTrackInfo.pm?rev=11416&r1=11415&r2=11416&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/RemoteTrackInfo.pm (original)
+++ trunk/server/Slim/Buttons/RemoteTrackInfo.pm Mon Feb 12 13:14:31 2007
@@ -66,7 +66,7 @@
if (Slim::Utils::Favorites->enabled && (Slim::Music::Info::isSong($url) || Slim::Music::Info::isPlaylist($url)) ) {
- $fav = Slim::Utils::Favorites->new->findByClientAndURL($client, $url);
+ $fav = Slim::Utils::Favorites->new($client)->findUrl($url);
unshift @list, {
value => $url,
@@ -83,17 +83,17 @@
onRight => sub {
my $client = shift;
- my $favorites = Slim::Utils::Favorites->new || return;
+ my $favorites = Slim::Utils::Favorites->new($client) || return;
my $index = $client->modeParam('favorite');
if ($index) {
- $favorites->deleteByClientAndId($client, $index);
+ $favorites->deleteIndex($index);
$client->modeParam('favorite', undef);
$client->showBriefly( {
'line' => [ $client->string('FAVORITES_DELETING'), $client->modeParam('title') ]
});
} else {
- $index = $favorites->clientAdd($client, $url, $title);
+ $index = $favorites->add($url, $title);
$client->modeParam('favorite', $index);
$client->showBriefly( {
'line' => [ $client->string('FAVORITES_ADDING'), $client->modeParam('title') ]
Modified: trunk/server/Slim/Buttons/TrackInfo.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/TrackInfo.pm?rev=11416&r1=11415&r2=11416&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/TrackInfo.pm (original)
+++ trunk/server/Slim/Buttons/TrackInfo.pm Mon Feb 12 13:14:31 2007
@@ -338,8 +338,7 @@
if (Slim::Music::Info::isURL($track->url) && Slim::Utils::Favorites->enabled) {
- my $favorites = Slim::Utils::Favorites->new;
- my $fav = $favorites->findByClientAndURL($client, $track->url);
+ my $fav = Slim::Utils::Favorites->new($client)->findUrl($track->url);
$client->modeParam( 'favorite', $fav ? $fav->{'index'} : undef );
@@ -459,12 +458,12 @@
} elsif ($curType eq 'FAVORITE') {
- my $favorites = Slim::Utils::Favorites->new;
+ my $favorites = Slim::Utils::Favorites->new($client);
my $favIndex = $client->modeParam('favorite');
if (!defined $favIndex) {
- $favIndex = $favorites->clientAdd($client, track($client), $track->title || $track->url);
+ $favIndex = $favorites->add(track($client), $track->title || $track->url);
$client->showBriefly( {
'line' => [ $client->string('FAVORITES_ADDING'), $track->title || $track->url ]
@@ -474,7 +473,7 @@
} else {
- $favorites->deleteByClientAndId($client, $favIndex);
+ $favorites->deleteIndex($favIndex);
$client->showBriefly( {
'line' => [ $client->string('FAVORITES_DELETING'), $track->title || $track->url ]
Modified: trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm?rev=11416&r1=11415&r2=11416&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm (original)
+++ trunk/server/Slim/Plugin/Favorites/OpmlFavorites.pm Mon Feb 12 13:14:31 2007
@@ -21,7 +21,8 @@
sub new {
return $favs if $favs;
- my $class = shift;
+ my $class = shift;
+ my $client = shift; # ignored for this version as favorites are shared by all clients
$favs = $class->SUPER::new;
@@ -135,9 +136,8 @@
return undef, undef, undef;
}
-sub clientAdd {
- my $class = shift;
- my $client = shift;
+sub add {
+ my $class = shift;
my $url = shift;
my $title = shift;
@@ -152,10 +152,10 @@
$url =~ s/\?sessionid.+//i; # Bug 3362, ignore sessionID's within URLs (Live365)
- $log->info(sprintf("%s url: %s title: %s", $client->id, $url, $title));
+ $log->info(sprintf("url: %s title: %s", $url, $title));
# if its already a favorite, don't add it again
- if (my $fav = $class->findByClientAndURL($client, $url)) {
+ if (my $fav = $class->findUrl($url)) {
return $fav->{'num'};
}
@@ -171,9 +171,8 @@
return scalar @{$class->toplevel} - 1;
}
-sub findByClientAndURL {
- my $class = shift;
- my $client = shift;
+sub findUrl {
+ my $class = shift;
my $url = shift;
$url =~ s/\?sessionid.+//i; # Bug 3362, ignore sessionID's within URLs (Live365)
@@ -194,9 +193,8 @@
return undef;
}
-sub deleteByClientAndURL {
- my $class = shift;
- my $client = shift;
+sub deleteUrl {
+ my $class = shift;
my $url = shift;
if (blessed($url) && $url->can('url')) {
@@ -207,7 +205,7 @@
if ($class->{'urlindex'}->{ $url }) {
- $class->deleteByClientAndId($client, $class->{'urlindex'}->{ $url }->{'ind'});
+ $class->deleteIndex($class->{'urlindex'}->{ $url }->{'ind'});
} else {
@@ -215,9 +213,8 @@
}
}
-sub deleteByClientAndId {
- my $class = shift;
- my $client = shift;
+sub deleteIndex {
+ my $class = shift;
my $index = shift;
my @ind = split(/\./, $index);
Modified: trunk/server/Slim/Utils/Favorites.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Favorites.pm?rev=11416&r1=11415&r2=11416&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Favorites.pm (original)
+++ trunk/server/Slim/Utils/Favorites.pm Mon Feb 12 13:14:31 2007
@@ -44,10 +44,10 @@
# Favorites classes should contain the following methods
#
-# sub new ( $class ) - contructor
-# sub clientAdd ( $class, $client, $url, $title ) - add $url with $title to favorites
-# sub findByClientAndURL ( $class, $client, $url ) - returns index or undef for $url from favorites
-# sub deleteByClientAndURL( $class, $client, $url ) - deletes $url from favorites
-# sub deleteByClientAndId ( $class, $client, $index ) - deletes favorite with index $index
+# sub new ( $class, $client ) - contructor
+# sub add ( $class, $url, $title ) - add $url with $title to favorites
+# sub findUrl ( $class, $url ) - returns favorite hash or undef for $url from favorites
+# sub deleteUrl ( $class, $url ) - deletes $url from favorites
+# sub deleteIndex ( $class, $index ) - deletes favorite with index $index
__END__
More information about the checkins
mailing list