X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FBase.pm;h=d8a4e988b50ec500f23719752ea38ab7af063f84;hb=0f99e523db38c4fec0abdbdf18f8173d44587a94;hp=5aa8eaea2c0b57a69167b9fc7a6c0721605ed27c;hpb=2044d5ff60e639a2eafbeed3a70224564e94c84c;p=videosite.git diff --git a/videosite/Base.pm b/videosite/Base.pm index 5aa8eae..d8a4e98 100644 --- a/videosite/Base.pm +++ b/videosite/Base.pm @@ -4,11 +4,11 @@ package Base; use strict; -use Irssi; +use Data::Dumper; sub new { my $class = shift; - my $self = {'_DEBUG' => 0}; + my $self = {'_DEBUG' => 0, '_OUT' => sub {print shift}}; bless($self, $class); @@ -19,9 +19,11 @@ sub new { sub error { my $self = shift; - my @data = @_; + my $t; - Irssi::print(sprintf(shift(@_), @_)); + $t = sprintf(shift(@_), @_); + $t =~ s/%/%%/g; + $self->{'_OUT'}($t); } sub debug { @@ -37,6 +39,8 @@ sub mergeconfig { my $c = shift; my $o; + return $self->{'_CONFIG'} unless defined($c); + foreach $o (keys(%{$c->{'option'}})) { if (exists($self->{'_CONFIG'}->{'option'}->{$o})) { $self->{'_CONFIG'}->{'option'}->{$o}->{'content'} = $c->{'option'}->{$o}->{'content'}; @@ -50,8 +54,7 @@ sub _prepare_parameters { my $self = shift; my $p; - $self->{'_CONFIG'} = { 'module' => $self->{'NAME'}, - 'option' => {}}; + $self->{'_CONFIG'} = {'option' => {'enabled' => {'content' => '1'}}}; foreach $p (keys(%{$self->{'_PARAMS'}})) { $self->{'_CONFIG'}->{'option'}->{$p}->{'content'} = $self->{'_PARAMS'}->{$p}->[0]; @@ -61,8 +64,12 @@ sub _prepare_parameters { sub _getval { my $self = shift; my $key = shift; + my $val; - return $self->{'_CONFIG'}->{'option'}->{$key}->{'content'} + $val = $self->{'_CONFIG'}->{'option'}->{$key}->{'content'}; + $self->debug('Returning %s=%s', $key, $val); + + return $val; } sub setval { @@ -77,6 +84,13 @@ sub setval { } } +sub setio { + my $self = shift; + my $io = shift; + + $self->{'_OUT'} = $io; +} + sub getconfstr { my $self = shift; my $s = 'Options for ' . $self->{'NAME'} . ":\n"; @@ -87,7 +101,7 @@ sub getconfstr { $p = $self->{'_CONFIG'}->{'option'}->{$k}->{'content'}; $p =~ s/%/%%/g; $s .= sprintf(" %s: %s", $k, $p); - if ($self->{'_CONFIG'}->{'option'}->{$k}->{'content'} == $self->{'_PARAMS'}->{$k}->[0]) { + if ($self->{'_CONFIG'}->{'option'}->{$k}->{'content'} eq $self->{'_PARAMS'}->{$k}->[0]) { $s .= " (default)\n"; } else { $s .= "\n";