InfoSys-FreeDB
view release on metacpan or search on metacpan
lib/InfoSys/FreeDB/Connection/CDDBP.pm view on Meta::CPAN
) );
}
sub proto {
my $self = shift;
my $level = shift;
# Send command and wait for reply
my $cmd = 'proto';
$cmd .= " $level" if ($level);
my $content_ref = $self->_wait_command_reply($cmd, {
200 => $FINAL_EOL_RX,
201 => $FINAL_EOL_RX,
501 => $FINAL_EOL_RX,
502 => $FINAL_EOL_RX,
} );
# Parse result
require InfoSys::FreeDB::Response::Proto;
my $res = InfoSys::FreeDB::Response::Proto->new_from_content_ref(
$content_ref
);
# Remember current protocol level
$self->set_proto_level( $res->get_cur_level() );
# Return the result
return($res);
}
sub quit {
my $self = shift;
# Send command and wait for reply
my $cmd = 'quit';
my $content_ref = $self->_wait_command_reply($cmd, {
230 => $FINAL_EOL_RX,
} );
# Clear the connection
$self->set__connection_();
# Parse the result and return it
require InfoSys::FreeDB::Response::Quit;
return( InfoSys::FreeDB::Response::Quit->new_from_content_ref(
$content_ref
) );
}
sub set_sign_on_response {
my $self = shift;
my $val = shift;
# Check if isa/ref/rx/value is allowed
&_value_is_allowed( 'sign_on_response', $val ) || throw Error::Simple("ERROR: InfoSys::FreeDB::Connection::CDDBP::set_sign_on_response, the specified value '$val' is not allowed.");
# Assignment
$self->{InfoSys_FreeDB_Connection_CDDBP}{sign_on_response} = $val;
}
sub update {
throw Error::Simple("ERROR: InfoSys::FreeDB::Connection::CDDBP::update, THIS METHOD IS NOT YET IMPLEMENTED.");
}
sub write {
my $self = shift;
my $entry = shift;
my $cat = shift;
# Throw exception if no cat
( $cat ) ||
throw Error::Simple("ERROR: InfoSys::FreeDB::Connection::CDDBP::write, no category specified.");
# Get the discid
my $res = $self->discid($entry);
# Throw exception if error
$res->get_code() == 200 ||
throw Error::Simple('ERROR: InfoSys::FreeDB::Connection::CDDBP::write, ' . $res->get_result() . '.');
# Send command and wait for reply
my $cmd = "cddb write $cat " . $res->get_discid();
my $content_ref = $self->_wait_command_reply($cmd, {
320 => $FINAL_EOL_RX,
401 => $FINAL_EOL_RX,
402 => $FINAL_EOL_RX,
409 => $FINAL_EOL_RX,
501 => $FINAL_EOL_RX,
} );
# Parse the result
require InfoSys::FreeDB::Response::Write::1;
my $pass1 = InfoSys::FreeDB::Response::Write::1->new_from_content_ref(
$content_ref
);
# Return result if error
$pass1->is_error() &&
return($pass1);
# Send entry and wait for reply
$content_ref = $self->_wait_write_reply(
$entry->write_array_ref(),
{
200 => $FINAL_EOL_RX,
401 => $FINAL_EOL_RX,
}
);
# Parse the result and return it
require InfoSys::FreeDB::Response::Write::2;
return( InfoSys::FreeDB::Response::Write::2->new_from_content_ref(
$content_ref
) );
}
( run in 0.589 second using v1.01-cache-2.11-cpan-39bf76dae61 )