WHen instantiating the client, can't get services because we havn't set credentials yet
This commit is contained in:
parent
783358c932
commit
5f702c1905
|
@ -74,40 +74,34 @@ my %soap_version_of :ATTR(:default<('1.1')>);
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
# private methods
|
# private methods
|
||||||
|
|
||||||
sub service
|
sub service {
|
||||||
{
|
|
||||||
my ($self, $serviceName, $attr) = @_;
|
my ($self, $serviceName, $attr) = @_;
|
||||||
#print "service: " . $services_of{${$self}}{$serviceName}{$attr} . "\n";
|
#print "service: " . $services_of{${$self}}{$serviceName}{$attr} . "\n";
|
||||||
# Please note that the Std::Class::Fast docs say not to use ident.
|
# Please note that the Std::Class::Fast docs say not to use ident.
|
||||||
$services_of{ident $self}{$serviceName}{$attr};
|
$services_of{ident $self}{$serviceName}{$attr};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_service
|
sub set_service {
|
||||||
{
|
|
||||||
my ($self, $serviceName, $attr, $value) = @_;
|
my ($self, $serviceName, $attr, $value) = @_;
|
||||||
$services_of{ident $self}{$serviceName}{$attr} = $value;
|
$services_of{ident $self}{$serviceName}{$attr} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub serializer
|
sub serializer {
|
||||||
{
|
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$serializer_of{ident $self};
|
$serializer_of{ident $self};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_serializer
|
sub set_serializer {
|
||||||
{
|
|
||||||
my ($self, $serializer) = @_;
|
my ($self, $serializer) = @_;
|
||||||
$serializer_of{ident $self} = $serializer;
|
$serializer_of{ident $self} = $serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub soap_version
|
sub soap_version {
|
||||||
{
|
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$soap_version_of{ident $self};
|
$soap_version_of{ident $self};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_soap_version
|
sub set_soap_version {
|
||||||
{
|
|
||||||
my ($self, $soap_version) = @_;
|
my ($self, $soap_version) = @_;
|
||||||
$soap_version_of{ident $self} = $soap_version;
|
$soap_version_of{ident $self} = $soap_version;
|
||||||
|
|
||||||
|
@ -138,7 +132,7 @@ sub get_service_urls {
|
||||||
# Some devices do not support getServices, so we have to try getCapabilities
|
# Some devices do not support getServices, so we have to try getCapabilities
|
||||||
|
|
||||||
$result = $self->service('device', 'ep')->GetCapabilities( {}, , );
|
$result = $self->service('device', 'ep')->GetCapabilities( {}, , );
|
||||||
if ( ! $result ) {
|
if ( !$result ) {
|
||||||
print "No results from GetCapabilities: $result\n";
|
print "No results from GetCapabilities: $result\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +141,7 @@ sub get_service_urls {
|
||||||
foreach my $capability ( 'PTZ', 'Media', 'Imaging', 'Events', 'Device' ) {
|
foreach my $capability ( 'PTZ', 'Media', 'Imaging', 'Events', 'Device' ) {
|
||||||
if ( my $function = $capabilities->can( "get_$capability" ) ) {
|
if ( my $function = $capabilities->can( "get_$capability" ) ) {
|
||||||
my $Services = $function->( $capabilities );
|
my $Services = $function->( $capabilities );
|
||||||
if ( ! $Services ) {
|
if ( !$Services ) {
|
||||||
print "Nothing returned ffrom get_$capability\n";
|
print "Nothing returned ffrom get_$capability\n";
|
||||||
} else {
|
} else {
|
||||||
foreach my $svc ( @{ $Services } ) {
|
foreach my $svc ( @{ $Services } ) {
|
||||||
|
@ -188,11 +182,7 @@ sub http_digest {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# =========================================================================
|
sub BUILD {
|
||||||
|
|
||||||
|
|
||||||
sub BUILD
|
|
||||||
{
|
|
||||||
my ($self, $ident, $args_ref) = @_;
|
my ($self, $ident, $args_ref) = @_;
|
||||||
|
|
||||||
my $url_svc_device = $args_ref->{'url_svc_device'};
|
my $url_svc_device = $args_ref->{'url_svc_device'};
|
||||||
|
@ -214,12 +204,11 @@ sub BUILD
|
||||||
|
|
||||||
$services_of{$ident}{'device'} = { url => $url_svc_device, ep => $svc_device };
|
$services_of{$ident}{'device'} = { url => $url_svc_device, ep => $svc_device };
|
||||||
|
|
||||||
$self->get_service_urls();
|
# Can't, don't have credentials yet
|
||||||
|
#$self->get_service_urls();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_users
|
sub get_users {
|
||||||
{
|
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my $result = $self->service('device', 'ep')->GetUsers( { },, );
|
my $result = $self->service('device', 'ep')->GetUsers( { },, );
|
||||||
|
@ -228,8 +217,7 @@ sub get_users
|
||||||
# print $result . "\n";
|
# print $result . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub create_user
|
sub create_user {
|
||||||
{
|
|
||||||
my ($self, $username, $password) = @_;
|
my ($self, $username, $password) = @_;
|
||||||
|
|
||||||
my $result = $self->service('device', 'ep')->CreateUsers( {
|
my $result = $self->service('device', 'ep')->CreateUsers( {
|
||||||
|
@ -245,11 +233,9 @@ sub create_user
|
||||||
|
|
||||||
die $result if not $result;
|
die $result if not $result;
|
||||||
# print $result . "\n";
|
# print $result . "\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_credentials
|
sub set_credentials {
|
||||||
{
|
|
||||||
my ($self, $username, $password, $create_if_not_exists) = @_;
|
my ($self, $username, $password, $create_if_not_exists) = @_;
|
||||||
|
|
||||||
# TODO: snyc device and client time
|
# TODO: snyc device and client time
|
||||||
|
@ -271,18 +257,19 @@ sub set_credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
# use this after set_credentials
|
# use this after set_credentials
|
||||||
sub create_services
|
sub create_services {
|
||||||
{
|
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
if(defined $self->service('media', 'url')) {
|
#$self->get_service_urls();
|
||||||
|
|
||||||
|
if ( defined $self->service('media', 'url') ) {
|
||||||
$self->set_service('media', 'ep', ONVIF::Media::Interfaces::Media::MediaPort->new({
|
$self->set_service('media', 'ep', ONVIF::Media::Interfaces::Media::MediaPort->new({
|
||||||
proxy => $self->service('media', 'url'),
|
proxy => $self->service('media', 'url'),
|
||||||
serializer => $self->serializer(),
|
serializer => $self->serializer(),
|
||||||
# transport => $transport
|
# transport => $transport
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if(defined $self->service('ptz', 'url')) {
|
if ( defined $self->service('ptz', 'url') ) {
|
||||||
$self->set_service('ptz', 'ep', ONVIF::PTZ::Interfaces::PTZ::PTZPort->new({
|
$self->set_service('ptz', 'ep', ONVIF::PTZ::Interfaces::PTZ::PTZPort->new({
|
||||||
proxy => $self->service('ptz', 'url'),
|
proxy => $self->service('ptz', 'url'),
|
||||||
serializer => $self->serializer(),
|
serializer => $self->serializer(),
|
||||||
|
@ -291,11 +278,11 @@ sub create_services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_endpoint
|
sub get_endpoint {
|
||||||
{
|
|
||||||
my ($self, $serviceType) = @_;
|
my ($self, $serviceType) = @_;
|
||||||
|
|
||||||
$self->service($serviceType, 'ep');
|
$self->service($serviceType, 'ep');
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
__END__
|
||||||
|
|
Loading…
Reference in New Issue