Net-UPnP

 view release on metacpan or  search on metacpan

lib/Net/UPnP/Service.pm  view on Meta::CPAN

package Net::UPnP::Service;

#-----------------------------------------------------------------
# Net::Net::UPnP::Service
#-----------------------------------------------------------------

use strict;
use warnings;

use Net::UPnP;
use Net::UPnP::ActionResponse;
use Net::UPnP::QueryResponse;

use vars qw($_DEVICE $_DEVICE_DESCRIPTION $SERVICETYPE $SERVICEID $SCPDURL $CONTROLURL $EVENTSUBURL);

$_DEVICE = 'device';
$_DEVICE_DESCRIPTION = 'device_description';

$SERVICETYPE = 'serviceType';
$SERVICEID = 'serviceId';
$SCPDURL = 'SCPDURL';
$CONTROLURL = 'controlURL';
$EVENTSUBURL = 'eventSubURL';

#------------------------------
# new
#------------------------------

sub new {
	my($class) = shift;
	my($this) = {
		$Net::UPnP::Service::_DEVICE  => undef,
		$Net::UPnP::Service::_DEVICE_DESCRIPTION => '',
	};
	bless $this, $class;
}

#------------------------------
# device
#------------------------------

sub setdevice() {
	my($this) = shift;
	if (@_) {
		$this->{$Net::UPnP::Service::_DEVICE} = $_[0];
	}
}

sub getdevice() {
	my($this) = shift;
	$this->{$Net::UPnP::Service::_DEVICE};
}

#------------------------------
# device description
#------------------------------

sub setdevicedescription() {
	my($this) = shift;
	$this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION} = $_[0];
 }

sub getdevicedescription() {
	my($this) = shift;
	my %args = (
		name => undef,	
		@_,
	);
	if ($args{name}) {
		unless ($this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION} =~ m/<$args{name}>(.*)<\/$args{name}>/i) {
			return '';
		}
	 	return $1;
	}
	$this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION};
 }

#------------------------------
# getservicetype
#------------------------------

sub getservicetype() {
	my($this) = shift;
	$this->getdevicedescription(name => $Net::UPnP::Service::SERVICETYPE);
 }

#------------------------------
# getserviceid
#------------------------------

sub getserviceid() {
	my($this) = shift;
	$this->getdevicedescription(name => $Net::UPnP::Service::SERVICEID);
 }

#------------------------------
# getscpdurl
#------------------------------

sub getscpdurl() {
	my($this) = shift;
	$this->getdevicedescription(name => $Net::UPnP::Service::SCPDURL);
 }

#------------------------------
# getcontrolurl
#------------------------------

sub getcontrolurl() {
	my($this) = shift;
	$this->getdevicedescription(name => $Net::UPnP::Service::CONTROLURL);
 }

#------------------------------
# geteventsuburl
#------------------------------

sub geteventsuburl() {
	my($this) = shift;
	$this->getdevicedescription(name => $Net::UPnP::Service::EVENTSUBURL);
 }

#------------------------------
# getposturl
#------------------------------

sub getposturl() {
	my($this) = shift;
	my ($ctrl_url) = @_;
	my (
		$dev,
		$location_url,
		$url_base,
	);
	
	$dev = $this->getdevice();
	
	$location_url = $dev->getlocation();
	$url_base = $dev->geturlbase();
	$ctrl_url = $this->getcontrolurl();

	#print "$location_url\n";
	#print "$url_base\n";
	#print "$ctrl_url\n";



( run in 2.039 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )