PDA

View Full Version : newbie: Plugin Help



Justin Eltoft
2005-01-11, 21:53
I'm trying to learn how to write a plugin, and so I first read the information
from the http://myserver:9000/html/docs/plugins.html help page included in the
slimserver. This was informative, but then when I decided to start looking at
example plugins, I ran into my first question.

I opened up Rescan.pm as included in the standard distro and saw this code near
the top:

#get previous alarm time or set a default
my $time = Slim::Utils::Prefs::get($client, "rescan-time");
if (!defined($time)) { Slim::Utils::Prefs::get($client, "rescan-time",
9 * 60 * 60 ); }

I guess I consider myself an intermediate PERL programmer. I don't see though
how the last statement here is working to set a default value. If I open up
the package Slim::Utils::Prefs, and look at the "get" subroutine, it doesn't
take 3 arguments.

Any help would be great. My other quick question is, is the help page I
already read on writing plugins the best out there? Is there anything else? I
will of course read other example plugins for help, but figured I'd ask in case
I was missing some great document.

Many Thanks,
Justin

kdf
2005-01-11, 22:54
Quoting Justin Eltoft <jeltoft (AT) wi (DOT) rr.com>:

> #get previous alarm time or set a default
> my $time = Slim::Utils::Prefs::get($client, "rescan-time");
> if (!defined($time)) { Slim::Utils::Prefs::get($client, "rescan-time",
> 9 * 60 * 60 ); }
>
> I guess I consider myself an intermediate PERL programmer. I don't see
> though
> how the last statement here is working to set a default value. If I open up
> the package Slim::Utils::Prefs, and look at the "get" subroutine, it doesn't
> take 3 arguments.

it doesn't. but Slim::Utils::Prefs::set does. Thanks for the bug report! :))

> Any help would be great. My other quick question is, is the help page I
> already read on writing plugins the best out there? Is there anything else?

that's pretty much it.

Justin Eltoft
2005-01-11, 23:22
Thanks for the reply! Two more quick questions.

1. Where is the define for "rightarrow" coming from in this statement from the
lines() subroutine:

return ($line1, $line2, undef, Slim::Display::Display::symbol('rightarrow'));

I don't see it in Slim::Display

2. Is it always that if you define line1 and line2 but use one of the two
largest "size" settings, that line 1 doesn't show up? That's what I see anyway
when I play around with the "rescan.pm" stuff and have the second most largest
font "size" setting.

Thanks again!

Justin

kdf
2005-01-12, 00:01
Quoting Justin Eltoft <jeltoft (AT) wi (DOT) rr.com>:

>
> Thanks for the reply! Two more quick questions.
>
> 1. Where is the define for "rightarrow" coming from in this statement from
> the
> lines() subroutine:
>
> return ($line1, $line2, undef, Slim::Display::Display::symbol('rightarrow'));
>
> I don't see it in Slim::Display

depending on the player, it refers to SqueezeboxG.pm %fontSymbols, or
Hardware::VFD %symbolmap.

its a bit abstracted, but that's basically it. for older players, it refers to
an internal character code. the squeezeboxG, it refers to an index in the
bitmapped fonts in the Graphics directory.

> 2. Is it always that if you define line1 and line2 but use one of the two
> largest "size" settings, that line 1 doesn't show up? That's what I see
> anyway
> when I play around with the "rescan.pm" stuff and have the second most
> largest
> font "size" setting.

generally, yes. you can test $client->linesPerScreen() to know whether the
slient is set for large or small fonts and create your lines accordingly.

Slim Devices also offers a developers mailing list. This is probably a better
place to continue asking questions directly related to the code.

-kdf