| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # Author: Murat Uenalan (muenalan@cpan.org) | 
| 2 |  |  |  |  |  |  | # | 
| 3 |  |  |  |  |  |  | # Copyright (c) 2002 Murat Uenalan. All rights reserved. | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # Note: This program is free software; you can redistribute | 
| 6 |  |  |  |  |  |  | # | 
| 7 |  |  |  |  |  |  | # it and/or modify it under the same terms as Perl itself. | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 5906 | use 5.006; use warnings; use strict; | 
|  | 1 |  |  | 1 |  | 4 |  | 
|  | 1 |  |  | 1 |  | 42 |  | 
|  | 1 |  |  |  |  | 6 |  | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 29 |  | 
|  | 1 |  |  |  |  | 6 |  | 
|  | 1 |  |  |  |  | 13 |  | 
|  | 1 |  |  |  |  | 44 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | package Winamp::Control; | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 1 |  |  | 1 |  | 925 | use Class::Maker; | 
|  | 1 |  |  |  |  | 10533 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1 |  |  | 1 |  | 802 | use LWP::Simple; | 
|  | 1 |  |  |  |  | 96528 |  | 
|  | 1 |  |  |  |  | 10 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 1 |  |  | 1 |  | 462 | use URI; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 1 |  |  | 1 |  | 5 | use vars qw($AUTOLOAD $VERSION); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 383 |  | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | our $VERSION = '0.2.1'; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | Class::Maker::class | 
| 24 |  |  |  |  |  |  | { | 
| 25 |  |  |  |  |  |  | public => | 
| 26 |  |  |  |  |  |  | { | 
| 27 |  |  |  |  |  |  | string => [qw(host passwd)], | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | integer => [qw(port)], | 
| 30 |  |  |  |  |  |  | }, | 
| 31 |  |  |  |  |  |  | }; | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub _preinit | 
| 34 |  |  |  |  |  |  | { | 
| 35 | 1 |  |  | 1 |  | 1777 | my $this = shift; | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 1 |  |  |  |  | 7 | $this->host( 'localhost' ); | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 1 |  |  |  |  | 19 | $this->port( 4800 ); | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | sub AUTOLOAD : method | 
| 43 |  |  |  |  |  |  | { | 
| 44 | 1 |  | 50 | 1 |  | 86 | my $this = shift || return undef; | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 1 |  |  |  |  | 2 | my @args; | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 1 | 50 |  |  |  | 4 | @args = ( p => $this->passwd ) if defined $this->passwd; | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 1 |  |  |  |  | 8 | push @args, @_; | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 1 |  |  |  |  | 3 | my $func = $AUTOLOAD; | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 1 |  |  |  |  | 6 | $func =~ s/.*:://; | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 1 | 50 |  |  |  | 5 | return if $func eq 'DESTROY'; | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 1 |  |  |  |  | 10 | my $uri = URI->new; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 1 |  |  |  |  | 6640 | $uri->scheme( 'http' ); | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 1 |  |  |  |  | 7839 | $uri->host( $this->host ); | 
| 63 |  |  |  |  |  |  |  | 
| 64 | 1 |  |  |  |  | 124 | $uri->port( $this->port ); | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 1 |  |  |  |  | 51 | $uri->path( $func ); | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 1 |  |  |  |  | 46 | $uri->query_form( @args ); | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | #$uri->userinfo( 'user:pw' ); | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 1 | 50 |  |  |  | 19 | warn $uri->as_string, "\n" if $main::opts{debug}; | 
| 73 |  |  |  |  |  |  |  | 
| 74 | 1 |  |  |  |  | 10 | my $result = get( $uri->as_string ); | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 1 | 50 |  |  |  | 68455 | return undef unless $result; | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 0 |  |  |  |  |  | my @array = (); | 
| 79 |  |  |  |  |  |  |  | 
| 80 | 0 |  |  |  |  |  | @array = split( ' ', $result );
 | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 0 | 0 |  |  |  |  | return wantarray ? @array : $array[0]; | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | 1; | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | __END__ |