[Slim-Checkins] r12488 - in /trunk/server: Slim/Control/Queries.pm Slim/Control/Request.pm Slim/Plugin/Jive/Plugin.pm strings.txt
fred at svn.slimdevices.com
fred at svn.slimdevices.com
Sun Aug 5 08:15:28 PDT 2007
Author: fred
Date: Sun Aug 5 08:15:27 2007
New Revision: 12488
URL: http://svn.slimdevices.com?rev=12488&view=rev
Log:
Bug: N/A
Description: Add a "play all songs" to album track listings for Jive
Modified:
trunk/server/Slim/Control/Queries.pm
trunk/server/Slim/Control/Request.pm
trunk/server/Slim/Plugin/Jive/Plugin.pm
trunk/server/strings.txt
Modified: trunk/server/Slim/Control/Queries.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Control/Queries.pm?rev=12488&r1=12487&r2=12488&view=diff
==============================================================================
--- trunk/server/Slim/Control/Queries.pm (original)
+++ trunk/server/Slim/Control/Queries.pm Sun Aug 5 08:15:27 2007
@@ -238,6 +238,7 @@
'cmd' => [$actioncmd],
'params' => {
'menu' => $nextMenu,
+ 'menu_all' => '1',
'sort' => 'tracknum',
},
'itemsParams' => 'params',
@@ -263,6 +264,8 @@
'titleStyle' => "album",
}
};
+
+ # adapt actions to SS preference
if (!$prefs->get('noGenreFilter') && defined $genreID) {
$base->{'actions'}->{'go'}->{'params'}->{'genre_id'} = $genreID;
$base->{'actions'}->{'play'}->{'params'}->{'genre_id'} = $genreID;
@@ -287,7 +290,10 @@
$request->addResult('offset', $start) if $menuMode;
for my $eachitem ($rs->slice($start, $end)) {
+
+ # Jive result formatting
if ($menuMode) {
+
# we want the text to be album\nartist
my @artists = $eachitem->artists();
my $artist = $artists[0]->name();
@@ -310,6 +316,8 @@
$request->addResultLoop($loopname, $cnt, 'icon-id', $iconId);
}
}
+
+ # "raw" result formatting (for CLI or JSON RPC)
else {
$request->addResultLoop($loopname, $cnt, 'id', $eachitem->id);
$tags =~ /l/ && $request->addResultLoop($loopname, $cnt, 'album', $eachitem->title);
@@ -324,6 +332,7 @@
$request->addResultLoopIfValueDefined($loopname, $cnt, 'artist', $artists[0]->name());
}
}
+
$cnt++;
}
}
@@ -3080,10 +3089,13 @@
my $contributorID = $request->getParam('artist_id');
my $albumID = $request->getParam('album_id');
my $year = $request->getParam('year');
+
my $menu = $request->getParam('menu');
+ my $insert = $request->getParam('menu_all');
# menu/jive mgmt
my $menuMode = defined $menu;
+ my $insertAll = $menuMode && defined $insert;
if ($request->paramNotOneOfIfDefined($sort, ['title', 'tracknum'])) {
$request->setStatusBadParams();
@@ -3193,6 +3205,9 @@
}
};
$request->addResult('base', $base);
+
+ # correct count if we insert "Play all songs"
+ $count++ if $insertAll;
}
if (Slim::Music::Import->stillScanning) {
@@ -3211,10 +3226,68 @@
my $cnt = 0;
$request->addResult('offset', $start) if $menuMode;
+ # first PLAY ALL item
+ if ($insertAll) {
+
+ # insert first item if needed
+ if ($start == 0) {
+ $request->addResultLoop($loopname, $cnt, 'text', Slim::Utils::Strings::string('JIVE_PLAY_ALL_SONGS'));
+
+ # get all our params
+ my $params = $request->getParamsCopy();
+ my $paramsAdd = {};
+ my $paramsGoPlay = {};
+ # remove keys starting with _ (internal or positional) and make copies
+ while (my ($key, $val) = each %{$params}) {
+ if ($key =~ /^_/ || $key eq 'menu' || $key eq 'menu_all') {
+ next;
+ }
+ $paramsAdd->{$key} = $val;
+ $paramsGoPlay->{$key} = $val;
+ }
+
+ $paramsAdd->{'cmd'} = 'add';
+ $paramsGoPlay->{'cmd'} = 'load';
+
+ # override the actions, babe!
+ my $actions = {
+ 'do' => {
+ 'player' => 0,
+ 'cmd' => ['playlistcontrol'],
+ 'params' => $paramsGoPlay,
+ },
+ 'play' => {
+ 'player' => 0,
+ 'cmd' => ['playlistcontrol'],
+ 'params' => $paramsGoPlay,
+ },
+ 'add' => {
+ 'player' => 0,
+ 'cmd' => ['playlistcontrol'],
+ 'params' => $paramsAdd,
+ },
+ };
+ $request->addResultLoop($loopname, $cnt, 'actions', $actions);
+ $cnt++;
+ }
+
+ # correct db slice!
+ else {
+ # we are not adding our item but it is counted in $start
+ # (a query for tracks 1 10 needs to start at db 0! -- and go to db 9 (instead of 10))
+ # (a query for tracks 0 10 ALSO needs to start at db 0! -- and go to db 8 (instead of 9))
+ $start--;
+ }
+ # always fix $end
+ $end--;
+ }
+
for my $item ($rs->slice($start, $end)) {
+ # jive formatting
if ($menuMode) {
+
my $text = Slim::Music::TitleFormatter::infoFormat($item, $format, 'TITLE');
$request->addResultLoop($loopname, $cnt, 'text', $text);
my $id = $item->id();
@@ -3223,10 +3296,10 @@
'track_id' => $id,
};
$request->addResultLoop($loopname, $cnt, 'params', $params);
-
-
+
+
# open a window with icon etc...
-
+
my $text2 = $item->title;
my $album;
my $albumObj = $item->album();
@@ -3236,30 +3309,30 @@
$iconId = $albumObj->artwork();
}
$text2 = $text2 . "\n" . (defined($album)?$album:"");
-
+
my $artist;
if(defined(my $artistObj = $item->artist())) {
$artist = $artistObj->name();
}
$text2 = $text2 . "\n" . (defined($artist)?$artist:"");
-
- #$request->addResultLoop($loop, 0, 'text', $text);
+
my $window = {
'text' => $text2,
};
-
+
if (defined($iconId)) {
$iconId += 0;
$window->{'icon-id'} = $iconId;
- #$request->addResultLoop($loop, 0, 'icon-id', $iconId);
}
$request->addResultLoop($loopname, $cnt, 'window', $window);
-
- }
+ }
+
+ # regular formatting
else {
_addSong($request, $loopname, $cnt, $item, $tags);
}
+
$cnt++;
# give peace a chance...
Modified: trunk/server/Slim/Control/Request.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Control/Request.pm?rev=12488&r1=12487&r2=12488&view=diff
==============================================================================
--- trunk/server/Slim/Control/Request.pm (original)
+++ trunk/server/Slim/Control/Request.pm Sun Aug 5 08:15:27 2007
@@ -895,11 +895,7 @@
my @request = @{$self->{'_request'}};
$copy->{'_request'} = \@request;
- tie (my %paramHash, "Tie::IxHash");
- while (my ($key, $val) = each %{$self->{'_params'}}) {
- $paramHash{$key} = $val;
- }
- $copy->{'_params'} = \%paramHash;
+ $copy->{'_params'} = $self->getParamsCopy();
$self->validate();
@@ -1280,6 +1276,17 @@
delete ${$self->{'_params'}}{$key};
}
+# returns a copy of all parameters
+sub getParamsCopy {
+ my $self = shift;
+
+ tie (my %paramHash, "Tie::IxHash");
+ while (my ($key, $val) = each %{$self->{'_params'}}) {
+ $paramHash{$key} = $val;
+ }
+ return \%paramHash;
+}
+
################################################################################
# Result mgmt
################################################################################
@@ -1595,7 +1602,7 @@
$log->debug('Enter');
- if ($log->is_debug) {
+ if ($log->is_info) {
$self->dump("Request");
}
@@ -1760,7 +1767,7 @@
my $self = shift || return;
my $specific = shift; # specific target of notify if we have a single known target
- $log->info(sprintf("Notifying %s", $self->getRequestString()));
+ $log->debug(sprintf("Notifying %s", $self->getRequestString()));
for my $listener ($specific || keys %listeners) {
Modified: trunk/server/Slim/Plugin/Jive/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Jive/Plugin.pm?rev=12488&r1=12487&r2=12488&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Jive/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Jive/Plugin.pm Sun Aug 5 08:15:27 2007
@@ -879,9 +879,9 @@
},
},
},
-# 'window' => {
-# 'text' => Slim::Utils::Strings::string('SEARCHFOR_ARTISTS'),
-# },
+ 'window' => {
+ 'text' => Slim::Utils::Strings::string('SEARCHFOR_PLAYLISTS'),
+ },
},
],
},
Modified: trunk/server/strings.txt
URL: http://svn.slimdevices.com/trunk/server/strings.txt?rev=12488&r1=12487&r2=12488&view=diff
==============================================================================
--- trunk/server/strings.txt (original)
+++ trunk/server/strings.txt Sun Aug 5 08:15:27 2007
@@ -13784,3 +13784,9 @@
PERSIST_DEBUG_SETTINGS
DE Fehlerbehebungs-Einstellungen beim nächsten Serverstart beibehalten
EN Save debugging settings for use at next server restart
+
+JIVE_PLAY_ALL_SONGS
+ EN Play all songs
+
+SEARCHFOR_PLAYLISTS
+ EN Search for playlists
More information about the checkins
mailing list