Agent-TCLI

 view release on metacpan or  search on metacpan

lib/Agent/TCLI/Package/Base.pm  view on Meta::CPAN

				$request->Respond($kernel,  "Invalid: $attr !", 400);
				return;
			}
			$txt .= "Set ".$attr." to ".$param->{$attr}." \n";
			$code = 200;
		}
	}

  	if (!defined($txt) || $txt eq '' )
  	{
  		$txt = "Invalid: ".join(', ',keys %{$param} );
  		$code = 404;
  	}

	$request->Respond($kernel, $txt, $code);
}

sub GetControl {
	my ($self, $id ) = @_;
	return ( $controls[$$self]->{$id}{'control'} )
		if defined( $controls[$$self]->{$id}{'control'} );
	return (0);
}

sub SetControl {
	my ($self, $control) = @_;
	if ( ref($control) =~ /control/ )
	{
		$controls[$$self]->{$control->id}{'control'} = $control;
	}
	else
	{
		delete ($controls[$$self]->{$control}{'control'} );
		delete ($controls[$$self]->{$control} );
	}
	return
}

sub GetControlKey {
	my ($self, $control, $key) = @_;
	if ( ref($control) =~ /control/ )
	{
		return ( $controls[$$self]->{$control->id}{$key} );
	}
	else
	{
		return ( $controls[$$self]->{$control}{$key} );
	}
}

sub SetControlKey {
	my ($self, $control, $key, $value) = @_;
	$controls[$$self]->{$control->id}{$key} = $value;
	return
}

sub GetWheel {
	my ($self, $id, $sp) = @_;
	return ( $wheels[$$self]->{$id}{'wheel'},
			 $wheels[$$self]->{$id}{'sender'},
			 $wheels[$$self]->{$id}{'postback'} )
		if (defined( $wheels[$$self]->{$id}{'wheel'}) && $sp );

	return ( $wheels[$$self]->{$id}{'wheel'} )
		if ( defined( $wheels[$$self]->{$id}{'wheel'} ) );

	return (0);
}

sub SetWheel {
	my ($self, $wheel) = @_;
	if ( ref($wheel) =~ /POE::Wheel/ )
	{
		$wheels[$$self]->{$wheel->ID}{'wheel'} = $wheel;
	}
	else # it is just a wheel ID
	{
		delete ($wheels[$$self]{$wheel}{'wheel'} );
		delete ($wheels[$$self]{$wheel} );
	}
	return
}

sub GetWheelKey {
	my ($self, $wheel, $key) = @_;
	if ( ref($wheel) =~ /POE::Wheel/ )
	{
		return ( $wheels[$$self]->{$wheel->ID}{$key} );
	}
	else
	{
		return ( $wheels[$$self]->{$wheel}{$key} );
	}
}

sub SetWheelKey {
	my ($self, $wheel, $key, $value) = @_;
	if ( ref($wheel) =~ /POE::Wheel/ )
	{
		$wheels[$$self]->{$wheel->ID}{$key} = $value;
	}
	else
	{
		$wheels[$$self]->{$wheel}{$key} = $value;
	}
	return 1;
}


# Input validation methods. Returns false or error message.
# These are all deprecated. Use Contraints and Command->Validator instead.

sub NotPosInt {
	my ($self,$value,$name,$set) = @_;
	$name = "Parameter" unless defined($name);
	return ('') unless (defined ($value) && $value ne '');
	return($name." is not a number: got '$value'  \n") unless (Scalar::Util::looks_like_number($value) );
    return($name." is not an integer: got '$value'  \n") unless(int($value) == $value);
    return($name." is not positive: got '$value'  \n") unless ( $value >= 0);
	if (defined($set))
	{



( run in 0.571 second using v1.01-cache-2.11-cpan-97f6503c9c8 )