~ubuntu-branches/ubuntu/raring/octopussy/raring

« back to all changes in this revision

Viewing changes to usr/share/perl5/Octopussy/Device.pm

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-09-25 10:27:37 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120925102737-1hgntjl557w3sjqh
Tags: 1.0.6-0ubuntu1
* New upstream release (LP: #1056016).
* d/control: bumped Standards-Version: 3.9.3, no changes.
* d/{copyright,control}: Updated upstream URL.
* d/README.Debian: Fixed minor typo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# $HeadURL$
2
 
# $Revision: 446 $
3
 
# $Date: 2011-02-14 00:59:15 +0000 (Mon, 14 Feb 2011) $
 
2
# $Revision: 598 $
 
3
# $Date: 2012-09-04 00:13:19 +0100 (Tue, 04 Sep 2012) $
4
4
# $Author: sebthebert $
5
5
 
6
6
=head1 NAME
567
567
      my $data = $cache_parser->get($k);
568
568
      foreach my $s (@{$data})
569
569
      {
570
 
        if ($s->{id} eq 'TOTAL')
 
570
        if ($s->{id} eq '_TOTAL_')
571
571
        {
572
572
          $stats{$s->{service}} = (
573
573
            defined $stats{$s->{service}}
655
655
sub Models
656
656
{
657
657
  my $type = shift;
 
658
        $type ||= 'Unknown';
658
659
  my $conf = AAT::XML::Read(Octopussy::FS::File($FILE_DEVICEMODELS));
659
660
  my @list = ();
660
661
 
793
794
  return ($device);
794
795
}
795
796
 
796
 
=head2 Set_Service_Statistics($device, $service, $action)
797
 
 
798
 
=cut
799
 
 
800
 
sub Set_Service_Statistics
801
 
{
802
 
  my ($device, $service, $action) = @_;
803
 
 
804
 
  my $status   = ($action eq 'enable' ? 1 : 0);
805
 
  my $conf     = Configuration($device);
806
 
  my @services = ();
807
 
  foreach my $s (ARRAY($conf->{service}))
808
 
  {
809
 
    $s->{statistics} = $status if ($s->{sid} eq $service);
810
 
    push @services, $s;
811
 
  }
812
 
  $conf->{service}         = \@services;
813
 
  $conf->{reload_required} = 1;
814
 
  $dir_devices ||= Octopussy::FS::Directory($DIR_DEVICE);
815
 
  AAT::XML::Write("$dir_devices/$conf->{name}.xml", $conf, $XML_ROOT);
816
 
 
817
 
  return ($status);
 
797
=head2 Set_Service_Option($device, $service, $option, $action)
 
798
 
 
799
Set Service Option (compression or statistics) to enable or disable
 
800
 
 
801
=cut
 
802
 
 
803
sub Set_Service_Option
 
804
{
 
805
        my ($device, $service, $option, $action) = @_;
 
806
 
 
807
        my $status   = ($action eq 'enable' ? 1 : 0);
 
808
        my $conf     = Configuration($device);
 
809
        my @services = ();
 
810
        foreach my $s (ARRAY($conf->{service}))
 
811
        {
 
812
        $s->{$option} = $status if ($s->{sid} eq $service);
 
813
        push @services, $s;
 
814
        }
 
815
        $conf->{service}         = \@services;
 
816
        $conf->{reload_required} = 1;
 
817
        $dir_devices ||= Octopussy::FS::Directory($DIR_DEVICE);
 
818
        AAT::XML::Write("$dir_devices/$conf->{name}.xml", $conf, $XML_ROOT);
 
819
 
 
820
        return ($status);
 
821
}
 
822
 
 
823
=head2 Valid_Name($name)
 
824
 
 
825
Checks that '$name' is valid for a Device name
 
826
 
 
827
=cut
 
828
 
 
829
sub Valid_Name
 
830
{
 
831
    my $name = shift;
 
832
 
 
833
    return (1)  
 
834
                if ((NOT_NULL($name)) && (($name =~ /^[a-z][a-z0-9_\.-]*$/i) 
 
835
                        || ($name =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)));
 
836
 
 
837
    return (0);
818
838
}
819
839
 
820
840
1;