diff options
| author | Andreas Brachold <vdr07@deltab.de> | 2007-12-16 14:37:56 +0000 |
|---|---|---|
| committer | Andreas Brachold <vdr07@deltab.de> | 2007-12-16 14:37:56 +0000 |
| commit | e74bdb7184b4e72ae58c5175464ef6a3db96aff7 (patch) | |
| tree | 48b6c98ce3b2c5fd55a94f038c354b7f7e5bc42b /lib | |
| parent | 26868547aed93bdba91157faa30db80db06573ba (diff) | |
| download | xxv-e74bdb7184b4e72ae58c5175464ef6a3db96aff7.tar.gz xxv-e74bdb7184b4e72ae58c5175464ef6a3db96aff7.tar.bz2 | |
* VTX: Embedded vtx-font inside module, drop graphics from VTXPATH
* HTTPD: remove binary from url as parameter, now defined at cmdobj, inside modul header
* EPG: rename VPS to PDC, Programme Delivery Control
* tools: add con_err,con_msg to dump message on console and log file
* RECORDS: Show message after editing recording
* MUSIC: remove proxy from playlist building, use proxy only to playing files
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Tools.pm | 43 | ||||
| -rw-r--r-- | lib/XXV/MODULES/AUTOTIMER.pm | 6 | ||||
| -rw-r--r-- | lib/XXV/MODULES/CHANNELS.pm | 21 | ||||
| -rw-r--r-- | lib/XXV/MODULES/CONFIG.pm | 38 | ||||
| -rw-r--r-- | lib/XXV/MODULES/EPG.pm | 54 | ||||
| -rw-r--r-- | lib/XXV/MODULES/GRAB.pm | 1 | ||||
| -rw-r--r-- | lib/XXV/MODULES/HTTPD.pm | 29 | ||||
| -rw-r--r-- | lib/XXV/MODULES/MEDIALIB.pm | 1 | ||||
| -rw-r--r-- | lib/XXV/MODULES/MUSIC.pm | 8 | ||||
| -rw-r--r-- | lib/XXV/MODULES/RECORDS.pm | 162 | ||||
| -rw-r--r-- | lib/XXV/MODULES/REPORT.pm | 3 | ||||
| -rw-r--r-- | lib/XXV/MODULES/STREAM.pm | 6 | ||||
| -rw-r--r-- | lib/XXV/MODULES/TIMERS.pm | 7 | ||||
| -rw-r--r-- | lib/XXV/MODULES/VTX.pm | 171 | ||||
| -rw-r--r-- | lib/XXV/OUTPUT/Console.pm | 9 |
15 files changed, 373 insertions, 186 deletions
diff --git a/lib/Tools.pm b/lib/Tools.pm index aac926f..7d89a31 100644 --- a/lib/Tools.pm +++ b/lib/Tools.pm @@ -24,7 +24,8 @@ our $DBH = {}; @EXPORT = qw(&datum &stackTrace &lg &event &debug &error &panic &rep2str &dumper &getFromSocket &fields &load_file &save_file &tableUpdated &buildsearch &deleteDir &getip &convert &int &entities &reentities &bench &fmttime - &getDataByTable &getDataById &getDataBySearch &getDataByFields &touch &url); + &getDataByTable &getDataById &getDataBySearch &getDataByFields &touch &url + &con_err &con_msg); # ------------------ @@ -169,6 +170,46 @@ sub panic { } # ------------------ +sub con_err { +# ------------------ + my $console = shift; + my $msg = shift; + + if(ref $msg eq 'ARRAY') { + $msg = join('\n', @$msg); + } + + &_msg(501,$msg, 2); + + if(ref $console) { + $console->{call} = 'message'; #reset default widget, avoid own widget + $console->err($msg); + } + + return undef; +} + +# ------------------ +sub con_msg { +# ------------------ + my $console = shift; + my $msg = shift; + + if(ref $msg eq 'ARRAY') { + $msg = join('\n', @$msg); + } + + &_msg(250,$msg, 4); + + if(ref $console) { + $console->{call} = 'message'; #reset default widget, avoid own widget + $console->msg($msg); + } + + return undef; +} + +# ------------------ sub getFromSocket { # ------------------ my $sock = shift or return undef; diff --git a/lib/XXV/MODULES/AUTOTIMER.pm b/lib/XXV/MODULES/AUTOTIMER.pm index 1187160..349b7b2 100644 --- a/lib/XXV/MODULES/AUTOTIMER.pm +++ b/lib/XXV/MODULES/AUTOTIMER.pm @@ -821,7 +821,7 @@ You can also fine tune your search : 'VPS' => { typ => 'confirm', def => $epg->{VPS} || 'n', - msg => gettext('Activate VPS for new timers'), + msg => gettext('Use PDC time to control created timer'), }, 'prevminutes' => { typ => 'integer', @@ -1088,7 +1088,7 @@ sub list { my $sth = $obj->{dbh}->prepare($sql); $sth->execute(@{$term}) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -1432,7 +1432,7 @@ sub suggest { |; my $sth = $obj->{dbh}->prepare($sql); $sth->execute('%'.$search.'%') - or return error "Couldn't execute query: $sth->errstr."; + or return con_err($console, sprintf("Couldn't execute query: '%s'",$sth->errstr)); my $result = $sth->fetchall_arrayref(); $console->table($result) if(ref $console && $result); diff --git a/lib/XXV/MODULES/CHANNELS.pm b/lib/XXV/MODULES/CHANNELS.pm index 95d180f..be8020b 100644 --- a/lib/XXV/MODULES/CHANNELS.pm +++ b/lib/XXV/MODULES/CHANNELS.pm @@ -348,7 +348,7 @@ sub readData { my $console = shift; my $file = $obj->{file} || return error ('No Channels File'); - return panic ("Couldn't find channels.conf as file $file!") if( ! -e $file); + return con_err($console, sprintf(gettext("Couldn't find channels.conf as file '%s'!"),$file)) if( ! -e $file); # only if file modification from last read time my $mtime = (stat($file)->mtime); @@ -358,7 +358,7 @@ sub readData { $obj->{dbh}->do('DELETE FROM CHANNELS'); $obj->{dbh}->do('DELETE FROM CHANNELGROUPS'); - my $fh = IO::File->new("< $file") or return error("Couldn't open file $file $!"); + my $fh = IO::File->new("< $file") or return con_err($console, sprintf(gettext("Couldn't open file '%s'! : %s"),$file,$!)); my $c = 0; my $nPos = 1; my $grp = 0; @@ -393,8 +393,7 @@ sub readData { # Remember the maximum Channelposition $obj->{LastChannel} = $obj->_LastChannel; - $console->message(sprintf(gettext("Write %d channels into database."), $c)) - if(ref $console); + con_msg($console, sprintf(gettext("Write %d channels into database."), $c)); # sort list with CA numerical my %CA; @@ -459,7 +458,7 @@ where my $sth = $obj->{dbh}->prepare($sql); $sth->execute('%'.$id.'%') - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -645,7 +644,7 @@ sub editChannel { my $sth = $self->{dbh}->prepare('SELECT SQL_CACHE POS, Name, Frequency, Parameters, Source, Srate, VPID, APID, TPID, CA, SID, NID, TID, RID from CHANNELS where Id = ?'); $sth->execute($cid) - or return $console->err(sprintf(gettext("Channel '%s' does not exist in the database!"),$cid)); + or return con_err($console, sprintf(gettext("Channel '%s' does not exist in the database!"),$cid)); $defaultData = $sth->fetchrow_hashref(); } elsif (ref $data eq 'HASH') { $defaultData = $data; @@ -874,7 +873,7 @@ sub editChannel { $data->{Name}, $error ); - $console->err($erg); + con_err($console, $erg); } sleep(1); $self->readData($watcher,$console); @@ -932,7 +931,7 @@ sub deleteChannel { my $self = shift || return error('No object defined!'); my $watcher = shift; my $console = shift; - my $channelid = shift || return $console->err(gettext("No channel defined for deletion! Please use cdelete 'pos'!")); + my $channelid = shift || return con_err($console, gettext("No channel defined for deletion! Please use cdelete 'pos'!")); my $answer = shift || 0; my @channels = reverse sort{ $a <=> $b } split(/[^0-9]/, $channelid); @@ -940,12 +939,12 @@ sub deleteChannel { my $sql = sprintf('SELECT SQL_CACHE Id,POS,Name from CHANNELS where POS in (%s)', join(',' => ('?') x @channels)); my $sth = $self->{dbh}->prepare($sql); $sth->execute(@channels) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $data = $sth->fetchall_hashref('POS'); foreach my $pos (@channels) { unless(exists $data->{$pos}) { - $console->err(sprintf(gettext("Channel '%s' does not exist in the database!"), $pos)); + con_err($console, sprintf(gettext("Channel '%s' does not exist in the database!"), $pos)); next; } @@ -979,7 +978,7 @@ sub deleteChannel { $console->redirect({url => '?cmd=clist', wait => 1}) if(ref $console and $console->typ eq 'HTML'); } else { - $console->err(gettext("No channel defined for deletion!")); + con_err($console, gettext("No channel defined for deletion!")); } return 1; diff --git a/lib/XXV/MODULES/CONFIG.pm b/lib/XXV/MODULES/CONFIG.pm index 88cb4ba..0662748 100644 --- a/lib/XXV/MODULES/CONFIG.pm +++ b/lib/XXV/MODULES/CONFIG.pm @@ -144,12 +144,12 @@ sub edit { $sector = uc($sector) unless($sector eq 'General'); my $cfg = $obj->{config}->{$sector} - or return $console->err(sprintf(gettext("Sorry, but section %s does not exist in the configuration!"),$sector)); + or return con_err($console, sprintf(gettext("Sorry, but section %s does not exist in the configuration!"),$sector)); my $mod = main::getModule($sector); my $prefs = $mod->{MOD}->{Preferences} - or return $console->err(sprintf(gettext("Sorry, but the settings in module: %s do not exist!"),$sector)); + or return con_err($console, sprintf(gettext("Sorry, but the settings in module: %s do not exist!"),$sector)); my $questions = []; foreach my $name (sort { lc($a) cmp lc($b) } keys(%{$prefs})) { @@ -180,12 +180,7 @@ sub edit { $obj->reconfigure(); $obj->write(); - debug sprintf('Config Section "%s" is changed and saved%s', - $sector, - ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" ) - ); - - $console->message(sprintf(gettext("Section: '%s' saving ... please wait."), $sector)); + con_msg($console, sprintf(gettext("Section: '%s' saving ... please wait."), $sector)); $console->redirect({url => sprintf('?cmd=configedit&data=%s',$sector), wait => 1}) if($console->typ eq 'HTML'); } @@ -202,9 +197,8 @@ sub write { my $configfile = main::getUsrConfigFile; $obj->{config}->write( $configfile ) - or return error( sprintf ("Couldn't write '%s': %s", $configfile , $! )); - $console->message(sprintf gettext("Configuration written to '%s'."), $configfile) - if(ref $console); + or return con_err($console, sprintf ("Couldn't write '%s': %s", $configfile , $! )); + con_msg($console, sprintf(gettext("Configuration written to '%s'."), $configfile)); $console->redirect({url => '?cmd=configedit', wait => 2}) if(ref $console and $console->typ eq 'HTML'); @@ -218,15 +212,15 @@ sub get { my $console = shift; my $modname = shift || 0; - return $console->err(gettext('Need a name of the module to display the configuration!')) - unless($modname and ref $console); + return con_err($console, gettext('Need a name of the module to display the configuration!')) + unless($modname); $modname = uc($modname) unless($modname eq 'General'); my $cfg = $obj->{config}->{$modname}; - $console->err(sprintf(gettext("Sorry, but section %s does not exist in the configuration!"),$modname)) - if(! $cfg and ref $console); + con_err($console, sprintf(gettext("Sorry, but section %s does not exist in the configuration!"),$modname)) + if(! $cfg); if(ref $console) { return $console->table($cfg); @@ -260,19 +254,14 @@ sub reconfigure { if(ref $check eq 'CODE') { my ($ok, $err) = &$check($mod->{$parameter}); unless($ok || not $err) { - my $message = sprintf("Config -> %s -> %s: %s %s", $moduleName, $parameter, $mod->{$parameter}, $err); - if(ref $console) { - $console->err($message); - } else { - error $message; - } + my $message = sprintf("Config -> %s -> %s: %s %s", $moduleName, $parameter, $mod->{$parameter}, $err); + con_err($console, $message); } } } } else { - $console->err(sprintf(gettext("Couldn't find %s in %s!"), $parameter, $moduleName)) - if(ref $console); + con_err($console, sprintf(gettext("Couldn't find %s in %s!"), $parameter, $moduleName)); } } } @@ -280,8 +269,7 @@ sub reconfigure { $obj->menu( $watcher, $console ) if(ref $console and $console->{TYP} eq 'HTML'); - $console->message(gettext('Edit successful!')) - if(ref $console); + con_msg($console, gettext('Edit successful!')); } # ------------------ diff --git a/lib/XXV/MODULES/EPG.pm b/lib/XXV/MODULES/EPG.pm index 1d64765..867527f 100644 --- a/lib/XXV/MODULES/EPG.pm +++ b/lib/XXV/MODULES/EPG.pm @@ -303,7 +303,7 @@ sub startReadEpgData { if(ref $console) { $console->start() if(ref $waiter); - $console->message(sprintf(gettext("%d events in database updated."), $updated)); + con_msg($console, sprintf(gettext("%d events in database updated."), $updated)); $console->redirect({url => '?cmd=now', wait => 1}) if($console->typ eq 'HTML'); @@ -646,20 +646,21 @@ sub search { DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration), '%H:%i') as Stop, UNIX_TIMESTAMP(e.starttime) as Day, e.description, - IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS + IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __PDC from EPG as e, CHANNELS as c where e.channel_id = c.Id AND ( $search->{query} ) + AND (FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration) > NOW()) order by starttime |; my $fields = fields($obj->{dbh}, $sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute(@{$search->{term}}) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -685,10 +686,10 @@ sub program { my $cid; if($channel =~ /^\d+$/sig) { $cid = $mod->PosToChannel($channel) - or return $console->err(sprintf(gettext("This channel '%s' does not exist in the database!"),$channel)); + or return con_err($console, sprintf(gettext("This channel '%s' does not exist in the database!"),$channel)); } else { $cid = $mod->NameToChannel($channel) - or return $console->err(sprintf(gettext("This channel '%s' does not exist in the database!"),$channel)); + or return con_err($console, sprintf(gettext("This channel '%s' does not exist in the database!"),$channel)); } my $sql = qq| @@ -702,19 +703,20 @@ SELECT SQL_CACHE e.description as __Description, e.video as __Video, e.audio as __Audio, - IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS + IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __PDC from EPG as e, CHANNELS as c where - e.channel_id = c.Id and - e.channel_id = ? + e.channel_id = c.Id + AND (FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration) > NOW()) + AND e.channel_id = ? order by starttime |; my $fields = fields($obj->{dbh}, $sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute($cid) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -736,8 +738,7 @@ sub display { my $eventid = shift; unless($eventid) { - $console->{call} = 'message'; #reset default widget, avoid own widget - $console->err(gettext("No ID defined to display this program! Please use display 'eid'!")); + con_err($console, gettext("No ID defined to display this program! Please use display 'eid'!")); return; } @@ -777,7 +778,7 @@ SELECT SQL_CACHE (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/duration*100 as \'$f{'Percent'}\', e.video as __Video, e.audio as __Audio, - IF(e.vpstime!=0,$vps,'') as __VPS + IF(e.vpstime!=0,$vps,'') as __PDC from $table as e,CHANNELS as c where @@ -787,7 +788,7 @@ where $fields = fields($obj->{dbh}, $sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute($eventid) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); $erg = $sth->fetchall_arrayref(); last @@ -795,8 +796,7 @@ where } if(scalar @{$erg} == 0 ) { - $console->{call} = 'message'; #reset default widget, avoid own widget - $console->err(sprintf(gettext("Event '%d' does not exist in the database!"),$eventid)); + con_err($console, sprintf(gettext("Event '%d' does not exist in the database!"),$eventid)); return; } @@ -834,14 +834,14 @@ INSERT INTO NEXTEPG select MIN(e.starttime) as nexttime FROM EPG as e, CHANNELS as c WHERE e.channel_id = c.Id -AND UNIX_TIMESTAMP(e.starttime) > UNIX_TIMESTAMP(NOW()) +AND e.starttime > NOW() AND c.GRP = ? GROUP BY c.Id |; my $sthtemp = $obj->{dbh}->prepare($sqltemp); $sthtemp->execute($cgrp) - or return error sprintf("Couldn't execute query: %s.",$sthtemp->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sthtemp->errstr)); my %f = ( 'Service' => gettext('Service'), @@ -863,7 +863,7 @@ SELECT SQL_CACHE DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as \'$f{'Stop'}\', e.description as __Description, 999 as __Percent, - IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS + IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __PDC FROM EPG as e, CHANNELS as c, NEXTEPG as n, CHANNELGROUPS as g WHERE @@ -877,7 +877,7 @@ ORDER BY my $fields = fields($obj->{dbh}, $sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute($cgrp) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -938,7 +938,7 @@ SELECT SQL_CACHE DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as \'$f{'Stop'}\', e.description as __Description, (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as \'$f{'Percent'}\', - IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS + IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __PDC FROM EPG as e, CHANNELS as c, CHANNELGROUPS as g WHERE @@ -953,7 +953,7 @@ ORDER BY my $fields = fields($obj->{dbh}, $sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute($zeit, $cgrp) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -976,7 +976,7 @@ sub NowOnChannel { my $obj = shift || return error('No object defined!'); my $watcher = shift || return error('No watcher defined!'); my $console = shift || return error('No console defined!'); - my $channel = shift || $obj->_actualChannel || return error('No channel defined!'); + my $channel = shift || $obj->_actualChannel || return con_err($console, gettext('No channel defined!')); my $zeit = time; my $sql = @@ -993,7 +993,7 @@ SELECT SQL_CACHE DATE_FORMAT(e.starttime, "%H:%i") as StartTime, (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as __Percent, e.description as Description, - IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS + IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __PDC FROM EPG as e, CHANNELS as c WHERE @@ -1008,7 +1008,7 @@ LIMIT 1 #dumper($sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute($zeit, $channel) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchrow_hashref(); if(ref $console) { @@ -1093,7 +1093,7 @@ ORDER BY my $fields = fields($obj->{dbh}, $sql); my $sth = $obj->{dbh}->prepare($sql); $sth->execute($zeitvon,$zeitbis,$zeitvon,$zeitbis,$zeitvon,$zeitbis,$cgrp) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); my $data = {}; @@ -1122,7 +1122,7 @@ sub checkOnTimer { my $obj = shift || return error('No object defined!'); my $watcher = shift || return error('No watcher defined!'); my $console = shift || return error('No console defined!'); - my $eid = shift || return error('No id defined!'); + my $eid = shift || return con_err($console, gettext('No event id defined!')); my $tim = main::getModule('TIMERS'); my $sql = qq| @@ -1141,7 +1141,7 @@ WHERE my $sth = $obj->{dbh}->prepare($sql); $sth->execute($eid) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $data = $sth->fetchrow_hashref(); my $erg = $tim->checkOverlapping($data) || ['ok']; my $tmod = main::getModule('TIMERS'); diff --git a/lib/XXV/MODULES/GRAB.pm b/lib/XXV/MODULES/GRAB.pm index aa84fff..26f89bb 100644 --- a/lib/XXV/MODULES/GRAB.pm +++ b/lib/XXV/MODULES/GRAB.pm @@ -81,6 +81,7 @@ sub module { callback => sub{ $obj->display(@_) }, Level => 'user', DenyClass => 'remote', + binary => 'nocache' }, }, }; diff --git a/lib/XXV/MODULES/HTTPD.pm b/lib/XXV/MODULES/HTTPD.pm index 19a04c0..1c96df7 100644 --- a/lib/XXV/MODULES/HTTPD.pm +++ b/lib/XXV/MODULES/HTTPD.pm @@ -299,22 +299,6 @@ sub communicator } else { $obj->ModulNotLoaded($console,'RECORDS'); } - } elsif($request =~ /coverimages\//) { - my $musicMod = main::getModule('MUSIC'); - if($musicMod) { - $request =~ s/.*coverimages\//$musicMod->{coverimages}\//; - $console->datei($request, $typ); - } else { - $obj->ModulNotLoaded($console,'MUSIC'); - } - } elsif($request =~ /vtximages\//) { - my $vtxMod = main::getModule('VTX'); - if($vtxMod) { - $request =~ s/.*vtximages\//$obj->{paths}->{VTXPATH}\//; - $console->datei($request, $typ); - } else { - $obj->ModulNotLoaded($console,'VTX'); - } } elsif($request =~ /tempimages\//) { my $tmp = $userMod->userTmp; $request =~ s/.*tempimages\//$tmp\//; @@ -322,12 +306,11 @@ sub communicator } else { $console->datei(sprintf('%s%s', $htmlRootDir, $request), $typ); } - } elsif( $cgi->param('binary') ) { - # Send multimedia files (if param binary) - $obj->handleInput($watcher, $console, $cgi); } else { $obj->handleInput($watcher, $console, $cgi); - $console->footer() unless($console->typ eq 'AJAX' or $console->{noFooter}); + $console->footer() + unless($console->typ eq 'AJAX' + or $console->{noFooter}); } } else { @@ -487,6 +470,12 @@ sub handleInput { my ($cmdobj, $cmdname, $shorterr, $err) = $u->checkCommand($console, $ucmd); $console->{call} = $cmdname; if($cmdobj and not $shorterr) { + + if($cmdobj->{binary}) { + $console->{NoFooter} = 1; + $console->{nocache} = 1 + if($cmdobj->{binary} eq 'nocache'); + } $cmdobj->{callback}($watcher, $console, $udata, $result ); } elsif($shorterr eq 'noperm' or $shorterr eq 'noactive') { $console->status403($err); diff --git a/lib/XXV/MODULES/MEDIALIB.pm b/lib/XXV/MODULES/MEDIALIB.pm index 193b84c..9a9e379 100644 --- a/lib/XXV/MODULES/MEDIALIB.pm +++ b/lib/XXV/MODULES/MEDIALIB.pm @@ -130,6 +130,7 @@ sub module { short => 'mlca', callback => sub{ $obj->mediacache(@_) }, DenyClass => 'media', + binary => 'cache' }, mlsave => { description => gettext('Save media'), diff --git a/lib/XXV/MODULES/MUSIC.pm b/lib/XXV/MODULES/MUSIC.pm index 4181d84..e0d94e7 100644 --- a/lib/XXV/MODULES/MUSIC.pm +++ b/lib/XXV/MODULES/MUSIC.pm @@ -117,6 +117,7 @@ sub module { short => 'm3', callback => sub{ $obj->playlist(@_) }, DenyClass => 'stream', + binary => 'nocache' }, mlist => { description => gettext("Shows music 'dir'"), @@ -135,12 +136,14 @@ sub module { short => 'mi', callback => sub{ $obj->coverimage(@_) }, DenyClass => 'mlist', + binary => 'cache' }, mgetfile => { description => gettext("Get music file 'fid'"), short => 'mg', callback => sub{ $obj->getfile(@_) }, DenyClass => 'mlist', + binary => 'cache' }, msuggest => { hidden => 'yes', @@ -453,7 +456,7 @@ sub play { ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" ) ); - $console->player("?cmd=mplaylist&data=${data}&binary=1"); + $console->player("?cmd=mplaylist&data=${data}"); } # ------------------ @@ -498,9 +501,7 @@ sub playlist { } if($output && $console->typ eq 'HTML') { - $console->{noFooter} = 1; $console->{nopack} = 1; - $console->{nocache} = 1; my $arg; $arg->{'attachment'} = "playlist.m3u"; @@ -700,7 +701,6 @@ sub list { artists => ($obj->{mdbh} ? $obj->GroupArray('artist', 'tracks', 'id'): $obj->GroupArray('ARTIST')), genres => $obj->GenreArray(), getCover => sub{ return $obj->_findcoverfromcache(@_, 'relative') }, - proxy => $obj->{proxy}, }; $console->table($erg, $params); diff --git a/lib/XXV/MODULES/RECORDS.pm b/lib/XXV/MODULES/RECORDS.pm index 567b5f2..fd2e95e 100644 --- a/lib/XXV/MODULES/RECORDS.pm +++ b/lib/XXV/MODULES/RECORDS.pm @@ -470,9 +470,8 @@ sub readData { $obj->{dbh}->do('DELETE FROM RECORDS'); my $msg = gettext('No recordings available!'); - $console->err($msg) - if(ref $console); - return error($msg); + con_err($console,$msg); + return; } # Get state from used harddrive (/video) @@ -625,7 +624,7 @@ sub readData { my $sql = sprintf('DELETE FROM RECORDS WHERE RecordMD5 IN (%s)', join(',' => ('?') x @todel)); my $sth = $obj->{dbh}->prepare($sql); $sth->execute(@todel) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); } my $removedData = $db_data ? scalar keys %$db_data : 0; @@ -650,7 +649,7 @@ sub readData { my @jobs = @{$obj->{JOBS}}; $obj->{JOBS} = []; - defined(my $child = fork()) or return error sprintf("Couldn't fork : %s",$!); + defined(my $child = fork()) or return con_err($console, sprintf("Couldn't fork : %s",$!)); if($child == 0) { $obj->{dbh}->{InactiveDestroy} = 1; @@ -690,15 +689,12 @@ DELETE FROM OLDEPG # last call of waiter $waiter->end() if(ref $waiter); - if(ref $console) { - $console->start() if(ref $waiter); - if(scalar @{$err} == 0) { - $console->message(sprintf(gettext("Write %d recordings to the database."), scalar @merkMD5)); - } else { - unshift(@{$err}, sprintf(gettext("Write %d recordings to the database. Couldn't assign %d recordings."), scalar @merkMD5 , scalar @{$err})); - lg join("\n", @$err); - $console->err($err); - } + $console->start() if(ref $waiter && ref $console); + if(scalar @{$err} == 0) { + $console->message(sprintf(gettext("Write %d recordings to the database."), scalar @merkMD5)) if(ref $console); + } else { + unshift(@{$err}, sprintf(gettext("Write %d recordings to the database. Couldn't assign %d recordings."), scalar @merkMD5 , scalar @{$err})); + con_err($console,$err); } return (scalar @{$err} == 0); } @@ -733,19 +729,20 @@ sub refresh { my $console = shift; my $waiter; - if(ref $console) { - if($console->typ eq 'HTML') { - $waiter = $console->wait(gettext("Get information on recordings ..."),0,1000,'no'); - } else { - $console->msg(gettext("Get information on recordings ...")); - } + if(ref $console && $console->typ eq 'HTML') { + $waiter = $console->wait(gettext("Get information on recordings ..."),0,1000,'no'); + } else { + con_msg($console,gettext("Get information on recordings ...")); } - if($obj->readData($watcher,$console,$waiter,'force') - && ref $console) { - $console->redirect({url => '?cmd=rlist', wait => 1}) - if($console->typ eq 'HTML'); + if($obj->readData($watcher,$console,$waiter,'force')) { + + $console->redirect({url => '?cmd=rlist', wait => 1}) + if(ref $console and $console->typ eq 'HTML'); + + return 1; } + return 0; } # ------------------ @@ -1214,8 +1211,7 @@ sub display { my $recordid = shift; unless($recordid) { - $console->{call} = 'message'; #reset default widget, avoid own widget - $console->err(gettext("No recording defined for display! Please use rdisplay 'rid'")); + con_err($console,gettext("No recording defined for display! Please use rdisplay 'rid'")); return; } @@ -1253,8 +1249,7 @@ where my $sth = $obj->{dbh}->prepare($sql); if(!$sth->execute($recordid) || !($rec = $sth->fetchrow_hashref())) { - $console->{call} = 'message'; - $console->err(sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); + con_err($console,sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); return; } @@ -1279,20 +1274,22 @@ sub play { my $obj = shift || return error('No object defined!'); my $watcher = shift || return error('No watcher defined!'); my $console = shift || return error('No console defined!'); - my $recordid = shift || return $console->err(gettext("No recording defined for playback! Please use rplay 'rid'.")); + my $recordid = shift || return con_err($console,gettext("No recording defined for playback! Please use rplay 'rid'.")); my $sql = qq|SELECT SQL_CACHE RecordID,RecordMD5 FROM RECORDS WHERE RecordMD5 = ?|; my $sth = $obj->{dbh}->prepare($sql); my $rec; if(!$sth->execute($recordid) || !($rec = $sth->fetchrow_hashref())) { - return $console->err(sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); + return con_err($console,sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); } my $cmd = sprintf('PLAY %d begin', $rec->{RecordID}); if($obj->{svdrp}->scommand($watcher, $console, $cmd)) { + $console->redirect({url => sprintf('?cmd=rdisplay&data=%s',$rec->{RecordMD5}), wait => 1}) if(ref $console and $console->typ eq 'HTML'); + return 1; } return 0; @@ -1304,20 +1301,22 @@ sub cut { my $obj = shift || return error('No object defined!'); my $watcher = shift || return error('No watcher defined!'); my $console = shift || return error('No console defined!'); - my $recordid = shift || return $console->err(gettext("No recording defined for playback! Please use rplay 'rid'.")); + my $recordid = shift || return con_err($console,gettext("No recording defined for playback! Please use rplay 'rid'.")); my $sql = qq|SELECT SQL_CACHE RecordID,RecordMD5 FROM RECORDS WHERE RecordMD5 = ?|; my $sth = $obj->{dbh}->prepare($sql); my $rec; if(!$sth->execute($recordid) || !($rec = $sth->fetchrow_hashref())) { - return $console->err(sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); + return con_err($console,sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); } my $cmd = sprintf('EDIT %d', $rec->{RecordID}); if($obj->{svdrp}->scommand($watcher, $console, $cmd)) { + $console->redirect({url => sprintf('?cmd=rdisplay&data=%s',$rec->{RecordMD5}), wait => 1}) if(ref $console and $console->typ eq 'HTML'); + return 1; } return 0; @@ -1473,7 +1472,7 @@ WHERE my $sth = $obj->{dbh}->prepare($sql); $sth->execute(@{$term}) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $erg = $sth->fetchall_arrayref(); unshift(@$erg, $fields); @@ -1495,7 +1494,7 @@ sub delete { my $obj = shift || return error('No object defined!'); my $watcher = shift || return error('No watcher defined!'); my $console = shift || return error('No console defined!'); - my $record = shift || return $console->err(gettext("No recording defined for deletion! Please use rdelete 'id'.")); + my $record = shift || return con_err($console,gettext("No recording defined for deletion! Please use rdelete 'id'.")); my $answer = shift || 0; my @rcs = split(/_/, $record); @@ -1518,7 +1517,7 @@ sub delete { my $sql = sprintf("SELECT SQL_CACHE r.RecordId,CONCAT_WS('~',e.title,e.subtitle),r.RecordMD5 FROM RECORDS as r,OLDEPG as e WHERE e.eventid = r.eventid and r.RecordMD5 IN (%s) ORDER BY r.RecordId desc", join(',' => ('?') x @recordings)); my $sth = $obj->{dbh}->prepare($sql); $sth->execute(@recordings) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); my $data = $sth->fetchall_arrayref(); # Query as array to hold ordering ! foreach my $recording (@$data) { @@ -1561,8 +1560,10 @@ sub delete { } } - $console->err(sprintf(gettext("Recording '%s' does not exist in the database!"), - join('\',\'',@recordings))) if(ref $console and scalar @recordings); + con_err($console, + sprintf(gettext("Recording '%s' does not exist in the database!"), + join('\',\'',@recordings))) + if(scalar @recordings); if($obj->{svdrp}->queue_cmds('COUNT')) { @@ -1572,21 +1573,19 @@ sub delete { my $waiter; if($obj->{svdrp}->err) { - $console->err($erg) if(ref $console); + con_err($console,$erg); } else { - if(ref $console) { - if($console->typ eq 'HTML' && !$obj->{inotify}) { - $waiter = $console->wait($msg,0,1000,'no'); - }else { - $console->msg($msg); - } + if(ref $console && $console->typ eq 'HTML' && !$obj->{inotify}) { + $waiter = $console->wait($msg,0,1000,'no'); + }else { + con_msg($console,$msg); } my $dsql = sprintf("DELETE FROM RECORDS WHERE RecordMD5 IN (%s)", join(',' => ('?') x @md5delete)); my $dsth = $obj->{dbh}->prepare($dsql); $sth->execute(@md5delete) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console, sprintf("Couldn't execute query: %s.",$sth->errstr)); } @@ -1603,7 +1602,7 @@ sub delete { } } } else { - $console->err(gettext("No recording to delete!")); + con_err($console,gettext("No recording to delete!")); } return 1; @@ -1629,7 +1628,7 @@ sub redit { my $obj = shift || return error('No object defined!'); my $watcher = shift || return error('No watcher defined!'); my $console = shift || return error('No console defined!'); - my $recordid = shift || return $console->err(gettext("No recording defined for editing!")); + my $recordid = shift || return con_err($console,gettext("No recording defined for editing!")); my $data = shift || 0; my $rec; @@ -1651,7 +1650,7 @@ WHERE my $sth = $obj->{dbh}->prepare($sql); if(!$sth->execute($recordid) || !($rec = $sth->fetchrow_hashref())) { - return $console->err(sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); + return con_err($console,sprintf(gettext("Recording '%s' does not exist in the database!"),$recordid)); } } @@ -1663,8 +1662,7 @@ WHERE my $audio; if(-r $file) { - my $text = load_file($file) - or $console->err(sprintf(gettext("Couldn't open file '%s' : %s!"),$file,$!)); + my $text = load_file($file) || ""; foreach my $zeile (split(/[\r\n]/, $text)) { if($zeile =~ /^D\s+(.+)/s) { @@ -1775,11 +1773,6 @@ WHERE my $dropEPGEntry = 0; my $ChangeRecordingData = 0; - debug sprintf('Recording "%s" has changed%s', - $rec->{title}, - ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" ) - ); - if($data->{summary} ne $desc or $data->{channel} ne $channel or $data->{video} ne $video @@ -1790,8 +1783,7 @@ WHERE $data->{summary} =~ s/^\s+//; # no leading white space $data->{summary} =~ s/\s+$//; # no trailing white space if(-r $file) { - my $text = load_file($file) - or $console->err(sprintf(gettext("Couldn't open file '%s' : %s!"),$file,$!)); + my $text = load_file($file) || ""; foreach my $zeile (split(/[\r\n]/, $text)) { $zeile =~ s/^\s+//; $zeile =~ s/\s+$//; @@ -1854,13 +1846,13 @@ WHERE } save_file($file, $out) - or return $console->err(sprintf(gettext("Couldn't write file '%s' : %s"),$file,$!)); + or return con_err($console,sprintf(gettext("Couldn't write file '%s' : %s"),$file,$!)); $dropEPGEntry = 1; } if($data->{marks} ne $marks) { save_file($marksfile, $data->{marks}) - or return $console->err(sprintf(gettext("Couldn't write file '%s' : %s"),$marksfile,$!)); + or return con_err($console,sprintf(gettext("Couldn't write file '%s' : %s"),$marksfile,$!)); $ChangeRecordingData = 1; } @@ -1879,14 +1871,14 @@ WHERE my $newPath = join('.', @options); move($rec->{Path}, $newPath) - or return $console->err(sprintf(gettext("Recording: '%s', couldn't move to '%s' : %s"),$rec->{title},$newPath,$!)); + or return con_err($console,sprintf(gettext("Recording: '%s', couldn't move to '%s' : %s"),$rec->{title},$newPath,$!)); $rec->{Path} = $newPath; $ChangeRecordingData = 1; } - $data->{title} =~s#~+#~#g; - $data->{title} =~s#^~##g; + $data->{title} =~s#~+#~#g; + $data->{title} =~s#^~##g; $data->{title} =~s#~$##g; if($data->{title} ne $rec->{title}) { @@ -1897,18 +1889,18 @@ WHERE my $parentnew = dirname($newPath); unless( -d $parentnew) { mkpath($parentnew) - or return $console->err(sprintf(gettext("Recording: '%s', couldn't mkpath: '%s' : %s"),$rec->{title},$parentnew,$!)); + or return con_err($console,sprintf(gettext("Recording: '%s', couldn't mkpath: '%s' : %s"),$rec->{title},$parentnew,$!)); } move($rec->{Path},$newPath) - or return $console->err(sprintf(gettext("Recording: '%s', couldn't move to '%s' : %s"),$rec->{title},$data->{title},$!)); + or return con_err($console,sprintf(gettext("Recording: '%s', couldn't move to '%s' : %s"),$rec->{title},$data->{title},$!)); my $parentold = dirname($rec->{Path}); if($obj->{videodir} ne $parentold and -d $parentold and is_empty_dir($parentold)) { rmdir($parentold) - or return $console->err(sprintf(gettext("Recording: '%s', couldn't remove '%s' : %s"),$rec->{title},$parentold,$!)); + or return con_err($console,sprintf(gettext("Recording: '%s', couldn't remove '%s' : %s"),$rec->{title},$parentold,$!)); } $ChangeRecordingData = 1; @@ -1923,28 +1915,32 @@ WHERE if($dropEPGEntry) { # Delete EpgOld Entrys my $sth = $obj->{dbh}->prepare('DELETE FROM OLDEPG WHERE eventid = ?'); $sth->execute($rec->{EventId}) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console,sprintf("Couldn't execute query: %s.",$sth->errstr)); } if($ChangeRecordingData) { my $sth = $obj->{dbh}->prepare('DELETE FROM RECORDS WHERE RecordMD5 = ?'); $sth->execute($recordid) - or return error sprintf("Couldn't execute query: %s.",$sth->errstr); + or return con_err($console,sprintf("Couldn't execute query: %s.",$sth->errstr)); } - my $waiter; - if(ref $console) { - if($console->typ eq 'HTML') { - $waiter = $console->wait(gettext('Recording edited!'),0,1000,'no'); - }else { - $console->msg(gettext('Recording edited!')); - } - } - sleep(1); + if($dropEPGEntry || $ChangeRecordingData) { + my $waiter; - $obj->readData($watcher,$console,$waiter) - unless($obj->{inotify}); + if(ref $console && $console->typ eq 'HTML' && !($obj->{inotify})) { + $waiter = $console->wait(gettext('Recording edited!'),0,1000,'no'); + }else { + con_msg($console,gettext('Recording edited!')); + } + sleep(1); + + $obj->readData($watcher,$console,$waiter) + unless($obj->{inotify}); + } else { + con_msg($console,gettext("Recording was'nt changed!")); + } + $console->redirect({url => sprintf('?cmd=rdisplay&data=%s',md5_hex($rec->{Path})), wait => 1}) if(ref $console and $console->typ eq 'HTML'); } @@ -1981,20 +1977,20 @@ sub conv { $obj->_loadreccmds; unless(scalar @{$obj->{reccmds}}) { - $console->err(gettext('No reccmds.conf on your system!')); + con_err($console,gettext('No reccmds.conf on your system!')); return 1; } unless($data) { - $console->err(gettext("Please use rconvert 'cmdid_rid'")); + con_err($console,gettext("Please use rconvert 'cmdid_rid'")); unshift(@{$obj->{reccmds}}, ['Descr.', 'Command']); $console->table($obj->{reccmds}); $obj->list($watcher, $console); } my ($cmdid, $recid) = split(/[\s_]/, $data); - my $cmd = (split(':', $obj->{reccmds}->[$cmdid-1]))[-1] || return $console->err(gettext("Couldn't find this command ID!")); - my $path = $obj->IdToPath($recid) || return $console->err(sprintf(gettext("Recording '%s' does not exist in the database!"),$recid)); + my $cmd = (split(':', $obj->{reccmds}->[$cmdid-1]))[-1] || return con_err($console,gettext("Couldn't find this command ID!")); + my $path = $obj->IdToPath($recid) || return con_err($console,sprintf(gettext("Recording '%s' does not exist in the database!"),$recid)); my $command = sprintf("%s %s",$cmd,qquote($path)); debug sprintf('Call command %s%s', @@ -2014,7 +2010,7 @@ sub conv { $console->message($output); } } else { - $console->err(sprintf(gettext("Sorry! Couldn't call %s '%s'! %s"), $cmd, $path, $!)); + con_err($console,sprintf(gettext("Sorry! Couldn't call %s '%s'! %s"), $cmd, $path, $!)); } $console->link({ diff --git a/lib/XXV/MODULES/REPORT.pm b/lib/XXV/MODULES/REPORT.pm index 9aafd8d..d1cc0ec 100644 --- a/lib/XXV/MODULES/REPORT.pm +++ b/lib/XXV/MODULES/REPORT.pm @@ -51,6 +51,7 @@ sub module { description => gettext("Display the actual news site 'typ'"), short => 'req', callback => sub{ $obj->request(@_) }, + binary => 'nocache' }, }, }; @@ -255,8 +256,6 @@ sub request { return $console->err(gettext("Sorry, but this module is not active!")) unless($obj->{NEWSMODS}->{$mod}->{active} eq 'y'); - $console->{noFooter} = 1; - return $console->out( $obj->{NEWSMODS}->{$mod}->req($params), $obj->{NEWSMODS}->{$mod}->{TYP} diff --git a/lib/XXV/MODULES/STREAM.pm b/lib/XXV/MODULES/STREAM.pm index 1e9c01f..7a836f2 100644 --- a/lib/XXV/MODULES/STREAM.pm +++ b/lib/XXV/MODULES/STREAM.pm @@ -48,12 +48,14 @@ sub module { short => 'pre', callback => sub{ $obj->play_record(@_) }, DenyClass => 'stream', + binary => 'nocache' }, livestream => { description => gettext("Stream a channel 'cid'. This required the streamdev plugin!"), short => 'lst', callback => sub{ $obj->live_stream(@_) }, DenyClass => 'stream', + binary => 'nocache' }, }, }; @@ -114,9 +116,7 @@ sub live_stream { ); if($channel && $console->typ eq 'HTML') { - $console->{nocache} = 1; $console->{nopack} = 1; - $console->{noFooter} = 1; my $data; $data = "#EXTM3U\r\n"; @@ -164,9 +164,7 @@ sub play_record { } if($data && $console->typ eq 'HTML') { - $console->{nocache} = 1; $console->{nopack} = 1; - $console->{noFooter} = 1; my $arg; $arg->{'attachment'} = sprintf("%s.m3u", $recid); diff --git a/lib/XXV/MODULES/TIMERS.pm b/lib/XXV/MODULES/TIMERS.pm index a4e797d..a927830 100644 --- a/lib/XXV/MODULES/TIMERS.pm +++ b/lib/XXV/MODULES/TIMERS.pm @@ -59,7 +59,7 @@ sub module { type => 'confirm', }, usevpstime => { - description => gettext('Use VPS start time'), + description => gettext('Use Programme Delivery Control (PDC) to control start time'), default => 'n', type => 'confirm', }, @@ -594,7 +594,7 @@ WHERE 'VPS' => { typ => 'confirm', def => (defined $timerData->{Status} and ($timerData->{Status} & 4) ? 'y' : 'n'), - msg => gettext('Enable VPS for this timer'), + msg => gettext('Use PDC time to control timer'), }, 'ChannelID' => { typ => 'list', @@ -1123,7 +1123,8 @@ FROM CHANNELS as c, EPG as e WHERE - t.ChannelID = c.Id + t.NextStopTime > NOW() + AND t.ChannelID = c.Id and (t.eventid = e.eventid) $search1 diff --git a/lib/XXV/MODULES/VTX.pm b/lib/XXV/MODULES/VTX.pm index d01184c..af68b5f 100644 --- a/lib/XXV/MODULES/VTX.pm +++ b/lib/XXV/MODULES/VTX.pm @@ -56,6 +56,12 @@ sub module { short => 'vs', callback => sub{ $self->search(@_) }, }, + vtximage => { + description => gettext("Display teletext image from block graphic font 'image'"), + short => 'vi', + callback => sub{ $self->image(@_) }, + binary => 'cache' + }, }, }; return $args; @@ -1016,10 +1022,10 @@ sub translate { $result .= $h; if ($graph == 1 || $c == 0x5f) #Block 0x5f = 0x7f - 0x20 { - my $pre = "<img class=\"vtx\" src=\"vtximages/"; + my $pre = "<img class=\"vtx\" src=\"?cmd=vi&data="; my $color = $colors[$fg]; - my $post = ".gif\" alt=\"\" title=\"\" /> "; - # set <img class="vtx" class="vtx" src="vtximages/black21.gif" alt="" title=""> + my $post = "\" alt=\"\" title=\"\" /> "; + # set <img class="vtx" class="vtx" src="?cmd=vi&data=black21" alt="" title=""> # vtx-image are locate inside skin folder $result =~ s/(image)\-(.+)/$pre.$color.$2.$post/eg; } @@ -1394,4 +1400,163 @@ sub search { return 1; } +# ------------------ +sub image { +# ------------------ + my $obj = shift || return error('No object defined!'); + my $watcher = shift || return error('No watcher defined!'); + my $console = shift || return error('No console defined!'); + my $data = shift || return error('No file defined!'); + + $console->err(gettext("Sorry, get image is'nt supported")) + if ($console->{TYP} ne 'HTML'); + + # data like black3F + $data =~ s/[^a-z0-9A-F]//g; # Remove unwantet character + + # Split data + my $color = $data; + $color =~ s/[^a-z]//g; + my $char = $data; + $char =~ s/[^0-9A-F]//g; + + # Get data + my $binary = $obj->_imagebinarydata($color,$char); + + # data lookup failed + return $console->status404(sprintf('%s.gif',$data),'Wrong image parameter') + unless($binary); + + # output data + my %args = (); + my $typ = "image/gif"; + + my $size = length($binary); + # header only if caching + $args{'ETag'} = sprintf('%s%s-%x',$color, $char, $size); + return $console->statusmsg(304,undef,undef,$typ) + if($console->{browser}->{'Match'} + && $args{'ETag'} eq $obj->{browser}->{'Match'}); + + $console->{nopack} = 1; + $args{'attachment'} = sprintf('%s%s.gif',$color, $char); + $args{'Content-Length'} = $size; + $args{'Last-Modified'} = "Sun, 16 Dec 2007 13:40:53 GMT"; + $console->out( $binary, $typ, %args ); +} + + +# ------------------ +# Build selected image from 2x6 vtx font +# in color, char | out binary data +sub _imagebinarydata { +# ------------------ + my $obj = shift || return error('No object defined!'); + my $color = shift || return error('No color defined!'); + my $char = shift || return error('No char defined!'); + + # File header + my $data = '47494638396108000C00F0'; + + # Color table + my $col = { + 'black' => '0100000000FFFFFF', + 'blue' => '00000000FF0000FF', + 'cyan' => '000000FFFF00FFFF', + 'green' => '0000008000008000', + 'magenta' => '0000FF00FFFF00FF', + 'red' => '0000FF0000FF0000', + 'white' => '0000FFFFFFFFFFFF', + 'yellow' => '0000FFFF00FFFF00' + }; + + if($char eq '20') { + $data .= '0000FFFFFFFFFFFF'; + } else { + return undef unless(exists $col->{$color}); + $data .= $col->{$color}; + } + + $data .= '21F904'; + if($char eq '7F') { + $data .= '000A0000'; + } else { + $data .= '010A0001'; + } + $data .= '002C0000000008000C00000'; + + # Pixel data + my $pixel = { + '20' => '2088C8FA9CBED0F632A003B', + '21' => '20D84111987CABA0E9CB4DA8BB32D003B', + '22' => '20E8C030987CABA0E64B4DA8BB36605003B', + '23' => '20C848FA98BE10FA39CB4DA5A00003B', + '24' => '20D8C8FA98BE0D05E7413B28B5901003B', + '25' => '21184111987CABA0E7C4E56332DDCBC7B5800003B', + '26' => '2118C030987CABA0E84CF496B28DBBCFB5D00003B', + '27' => '20E848FA9CBE1811E3C32CA8BB3BE05003B', + '28' => '20D8C8FA9CBE0801E3C323E86732A003B', + '29' => '21184111987CABA0E84CF496BE89DBC7B5800003B', + '2A' => '2118C030987CABA0E7C4E56336D62BCFB6F14003B', + '2B' => '20F848FA98BE1D15E74139E87B3DEBB00003B', + '2C' => '20C8C8FA98BE00FA39C90D99B0A003B', + '2D' => '21084111987CABA0E64B4DA6BA0DEBCA702003B', + '2E' => '20F8C030987CABA0E9CB45ACAB2DEDC14003B', + '2F' => '20C848FA9CBED1DA29CB4DA5900003B', + '30' => '20D8C8FA9CBED0D2240729E4A252A003B', + '31' => '21184111987CABA0E9CB45AFA9CD406E65400003B', + '32' => '2118C030987CABA0E64B4DA6BA6743B3D6E14003B', + '33' => '20E848FA98BE10FA39CB03DEB70D005003B', + '34' => '20F8C8FA98BE0D05E74139E670DAEFC14003B', + '35' => '21384111987CABA0E7C4E56336DA25B477C354901003B', + '36' => '2138C030987CABA0E84CF496BE84D95EF98614101003B', + '37' => '210848FA9CBE1811E3C323EEBF03495BE02003B', + '38' => '2108C8FA9CBE0801E3C32CA675D9EA69E02003B', + '39' => '21384111987CABA0E84CF496B28BBA9761E654A01003B', + '3A' => '2138C030987CABA0E7C4E56332D4C94EB885D4101003B', + '3B' => '20F848FA98BE1D15E7413AE670DAEB500003B', + '3C' => '20E8C8FA98BE00FA39CB43DEB304005003B', + '3D' => '21184111987CABA0E64B4DA5BA7743B3D5500003B', + '3E' => '2118C030987CABA0E9CB4DA1B0D7C4E765300003B', + '3F' => '20D848FA9CBED6F820C68D263EB2C003B', + '60' => '20D8C8FA9CBED6F800468D263EB2C003B', + '61' => '21184111987CABA0E9CB4DA1B0D7C4E765300003B', + '62' => '2118C030987CABA0E64B4DA5BA7743B3D5500003B', + '63' => '20E848FA98BE10FA39CB43DEB704005003B', + '64' => '20F8C8FA98BE0D05E7413AE670DAEB500003B', + '65' => '21384111987CABA0E7C4E56332D4C94EB885D4001003B', + '66' => '2138C030987CABA0E84CF496B28BBA9761E654A01003B', + '67' => '210848FA9CBE1811E3C32CA675D9EA69E02003B', + '68' => '2108C8FA9CBE0801E3C323EEBF03495BE02003B', + '69' => '21384111987CABA0E84CF496BE84D95EF98614001003B', + '6A' => '2138C030987CABA0E7C4E56336DA25B477C354901003B', + '6B' => '20F848FA98BE1D15E74139E670DAEFC14003B', + '6C' => '20E8C8FA98BE00FA39CB03DEB30D005003B', + '6D' => '21184111987CABA0E64B4DA6BA6743B3D6E14003B', + '6E' => '2118C030987CABA0E9CB45AFA9CD406E65400003B', + '6F' => '20D848FA9CBED1D6240729E4A252A003B', + '70' => '20C8C8FA9CBED0DA29CB4DA5900003B', + '71' => '20F84111987CABA0E9CB45ACAB2DEDC14003B', + '72' => '2108C030987CABA0E64B4DA6BA0DEBCA702003B', + '73' => '20C848FA98BE10FA39C90D99B0A003B', + '74' => '20F8C8FA98BE0D05E74139E87B3DEBB00003B', + '75' => '21184111987CABA0E7C4E56336D62BCFB6F14003B', + '76' => '2118C030987CABA0E84CF496BE89DBC7B5800003B', + '77' => '20D848FA9CBE1811E3C323E86732A003B', + '78' => '20E8C8FA9CBE0801E3C32CA8BB3BE05003B', + '79' => '21184111987CABA0E84CF496B28DBBCFB5D00003B', + '7A' => '2118C030987CABA0E7C4E56332DDCBC7B5800003B', + '7B' => '20D848FA98BE1D15E7413B28B5901003B', + '7C' => '20C8C8FA98BE00FA39CB4DA5A00003B', + '7D' => '20E84111987CABA0E64B4DA8BB36605003B', + '7E' => '20D8C030987CABA0E9CB4DA8BB32D003B', + '7F' => '208848FA9CBED0F632A003B', + }; + + return undef unless(exists $pixel->{$char}); + $data .= $pixel->{$char}; + + return pack("H*",$data); +} + 1; diff --git a/lib/XXV/OUTPUT/Console.pm b/lib/XXV/OUTPUT/Console.pm index 4358b88..9b756ac 100644 --- a/lib/XXV/OUTPUT/Console.pm +++ b/lib/XXV/OUTPUT/Console.pm @@ -541,6 +541,15 @@ sub hidden { } # ------------------ +sub datei { +# ------------------ + my $obj = shift || return error('No object defined!'); + my $data = shift || return error('No data defined!'); + + return $obj->message(gettext("Sorry, couldn't send files in this interface.")); +} + +# ------------------ sub image { # ------------------ my $obj = shift || return error('No object defined!'); |
