This file is indexed.

/usr/share/perl5/POE/Component/Client/MPD/Playlist.pm is in libpoe-component-client-mpd-perl 1.100430-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# 
# This file is part of POE-Component-Client-MPD
# 
# This software is copyright (c) 2007 by Jerome Quelin.
# 
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
# 
use 5.010;
use strict;
use warnings;

package POE::Component::Client::MPD::Playlist;
our $VERSION = '1.100430';
# ABSTRACT: module handling playlist commands

use Moose;
use MooseX::Has::Sugar;
use POE;
use Readonly;

use POE::Component::Client::MPD::Message;


# -- attributes

has mpd => ( ro, required, weak_ref, );# isa=>'POE::Component::Client::MPD' );


# -- Playlist: retrieving information


sub _do_as_items {
    my ($self, $msg) = @_;

    $msg->_set_commands ( [ 'playlistinfo' ] );
    $msg->_set_cooking  ( 'as_items' );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_items_changed_since {
    my ($self, $msg) = @_;
    my $plid = $msg->params->[0];

    $msg->_set_commands ( [ "plchanges $plid" ] );
    $msg->_set_cooking  ( 'as_items' );
    $self->mpd->_send_to_mpd( $msg );
}


# -- Playlist: adding / removing songs



sub _do_add {
    my ($self, $msg) = @_;

    my $args   = $msg->params;
    my @pathes = @$args;         # args of the poe event
    my @commands = (             # build the commands
        'command_list_begin',
        map( qq{add "$_"}, @pathes ),
        'command_list_end',
    );
    $msg->_set_commands ( \@commands );
    $msg->_set_cooking  ( 'raw' );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_delete {
    my ($self, $msg) = @_;

    my $args    = $msg->params;
    my @numbers = @$args;
    my @commands = (              # build the commands
        'command_list_begin',
        map( qq{delete $_}, reverse sort {$a<=>$b} @numbers ),
        'command_list_end',
    );
    $msg->_set_commands ( \@commands );
    $msg->_set_cooking  ( 'raw' );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_deleteid {
    my ($self, $msg) = @_;

    my $args    = $msg->params;
    my @songids = @$args;
    my @commands = (              # build the commands
        'command_list_begin',
        map( qq{deleteid $_}, @songids ),
        'command_list_end',
    );
    $msg->_set_commands ( \@commands );
    $msg->_set_cooking  ( 'raw' );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_clear {
    my ($self, $msg) = @_;

    $msg->_set_commands ( [ 'clear' ] );
    $msg->_set_cooking  ( 'raw' );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_crop {
    my ($self, $msg) = @_;

    if ( not defined $msg->_data ) {
        # no status yet - fire an event
        $msg->_set_post( 'pl.crop' );
        $self->mpd->_dispatch('status', $msg);
        return;
    }

    # now we know what to remove
    my $cur = $msg->_data->song;
    my $len = $msg->_data->playlistlength - 1;
    my @commands = (
        'command_list_begin',
        map( { $_ != $cur ? "delete $_" : '' } reverse 0..$len ),
        'command_list_end'
    );

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( \@commands );
    $self->mpd->_send_to_mpd( $msg );
}


# -- Playlist: changing playlist order



sub _do_shuffle {
    my ($self, $msg) = @_;

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ 'shuffle' ] );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_swap {
    my ($self, $msg) = @_;
    my ($from, $to) = @{ $msg->params }[0,1];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ "swap $from $to" ] );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_swapid {
    my ($self, $msg) = @_;
    my ($from, $to) = @{ $msg->params }[0,1];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ "swapid $from $to" ] );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_move {
    my ($self, $msg) = @_;
    my ($song, $pos) = @{ $msg->params }[0,1];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ "move $song $pos" ] );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_moveid {
    my ($self, $msg) = @_;
    my ($songid, $pos) = @{ $msg->params }[0,1];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ "moveid $songid $pos" ] );
    $self->mpd->_send_to_mpd( $msg );
}


# -- Playlist: managing playlists



sub _do_load {
    my ($self, $msg) = @_;
    my $playlist = $msg->params->[0];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ qq{load "$playlist"} ] );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_save {
    my ($self, $msg) = @_;
    my $playlist = $msg->params->[0];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ qq{save "$playlist"} ] );
    $self->mpd->_send_to_mpd( $msg );
}



sub _do_rm {
    my ($self, $msg) = @_;
    my $playlist = $msg->params->[0];

    $msg->_set_cooking  ( 'raw' );
    $msg->_set_commands ( [ qq{rm "$playlist"} ] );
    $self->mpd->_send_to_mpd( $msg );
}


no Moose;
__PACKAGE__->meta->make_immutable;
1;


=pod

=head1 NAME

POE::Component::Client::MPD::Playlist - module handling playlist commands

=head1 VERSION

version 1.100430

=head1 DESCRIPTION

L<POE::Component::Client::MPD::Playlist> is responsible for handling
general purpose commands. They are in a dedicated module to achieve
easier code maintenance.

To achieve those commands, send the corresponding event to the POCOCM
session you created: it will be responsible for dispatching the event
where it is needed. Under no circumstance should you call directly subs
or methods from this module directly.

Read L<POCOCM|POE::Component::Client::MPD>'s pod to learn how to deal
with answers from those commands.

Following is a list of playlist-related events accepted by POCOCM.

=head1 RETRIEVING INFORMATION

=head2 pl.as_items( )

Return an array of L<Audio::MPD::Common::Item::Song>s, one for each of
the songs in the current playlist.

=head2 pl.items_changed_since( $plversion )

Return a list with all the songs (as L<Audio::MPD::Common::Item::Song>
objects) added to the playlist since playlist C<$plversion>.

=head1 ADDING / REMOVING SONGS

=head2 pl.add( $path, $path, ... )

Add the songs identified by C<$path> (relative to MPD's music directory)
to the current playlist.

=head2 pl.delete( $number, $number, ... )

Remove song C<$number> (starting from 0) from the current playlist.

=head2 pl.deleteid( $songid, $songid, ... )

Remove the specified C<$songid> (as assigned by mpd when inserted in
playlist) from the current playlist.

=head2 pl.clear( )

Remove all the songs from the current playlist.

=head2 pl.crop( )

Remove all of the songs from the current playlist *except* the current one.

=head1 CHANGING PLAYLIST ORDER

=head2 pl.shuffle( )

Shuffle the current playlist.

=head2 pl.swap( $song1, $song2 )

Swap positions of song number C<$song1> and C<$song2> in the current
playlist.

=head2 pl.swapid( $songid1, $songid2 )

Swap positions of song id C<$songid1> and C<$songid2> in the current
playlist.

=head2 pl.move( $song, $newpos )

Move song number C<$song> to the position C<$newpos>.

=head2 pl.moveid( $songid, $newpos )

Move song id C<$songid> to the position C<$newpos>.

=head1 MANAGING PLAYLISTS

=head2 pl.load( $playlist )

Load list of songs from specified C<$playlist> file.

=head2 pl.save( $playlist )

Save the current playlist to a file called C<$playlist> in MPD's
playlist directory.

=head2 pl.rm( $playlist )

Delete playlist named C<$playlist> from MPD's playlist directory.

=head1 AUTHOR

  Jerome Quelin

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2007 by Jerome Quelin.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut


__END__