My current hurdle is the $client variable I see everywhere. I've created menus for brutefirdrc in the web ui and ipeng already and am trying to add functionality to them. When my version of the plugin gets to
sub setMode {
my $class = shift;
my $client = shift;
my $method = shift;
# Handle requests to exit this mode/plugin by going back to where
+the user was before they came
# here. If you don't this, pressing LEFT will just put you straig
+ht back to where you already
# are! (try commenting out the following if statement)
if ($method eq 'pop') {
# Pop the current mode off the mode stack and restore the prev
+ious one
Slim::Buttons::Common::popMode($client);
return;
}
if (isBlindTest($client)) {
Slim::Buttons::Common::pushMode($client, $modeBlindTest);
} else {
pushMainMenuMode($client);
}
}
It breaks. When I use the normal menu already in the plugin the setmode function has this in it's variables.
$class = Plugins::BrutefirDrc::Plugin
$client = Slim::Player::SoftSqueeze=ARRAY(0xdaad6f8)
$method = push
When I run through the chain of functions from my menu all those variables are blank. I've tried to duplicate the chain of events in the plugin in my menu as close as possible to the original menu but I guess I've missed something. I believe this chunk of code is what I am missing but I don't know how to duplicate it for my menus.
my $valueref = $client->modeParam('valueRef');
if ($$valueref eq 'PLUGIN_BRUTEFIR_DRC_CHANGE_FILTER') {
my $baseDir = getFilterDir();
my $currentDir = getCurrentFilterDir($client);
$currentDir =~ s/$baseDir//;
my @dirs = File::Spec->splitdir($currentDir);
$currentDir = $baseDir;
# push all directories on the path to current selected fil
+ters dir as mode to make left pop them each out
foreach my $dir (@dirs) {
if ($dir) {
Slim::Buttons::Common::pushMode($client, $modeFilt
+erSelection, { folder => $currentDir });
$currentDir = File::Spec->catdir($currentDir, $dir
+);
}
}
Slim::Buttons::Common::pushModeLeft($client, $modeFilterSe
+lection, { folder => getCurrentFilterDir($client) });
}
That's from the brutefirdrcMainMenu function. I'm pretty sure the Slim::Buttons stuff is where it falls apart because I have no idea what that really does or how to duplicate it.
This is the menu entry I made that's supposed to do all that.
sub filterMenu {
my ($client, $callback, $args) = @_;
my $baseDir = getFilterDir();
my $currentDir = getCurrentFilterDir($client);
$currentDir =~ s/$baseDir//;
my @dirs = File::Spec->splitdir($currentDir);
$currentDir = $baseDir;
my $folder = $currentDir;
my @filters;
my %filters = getFiltersList($folder);
my @choices = sort keys %filters;
my @choicev = map $filters{$_}, @choices;
my $filter = $filters{getCurrentFilter($client)} eq getCurrentFilt
+erPath($client) ? getCurrentFilter($client) : '';
opendir DIR, $currentDir or die "cannot open dir $currentDir: $!";
my @file= readdir DIR;
closedir DIR;
my $items;
$items = [{
{ name => 'Select a Filter',
url => \&filterMenu,
},{
name => $filter,
url => \&filterMenu,
}
}];
for my $file (@file) {
push @$items,
{
name => $file,
url => sub { my ($client, $cb, $params) = @_; },
nextWindow => 'refresh',
};
}
$callback->({
items => $items
});
}
Any ideas how to make this work.
Thanks,
Bronston |