/usr/share/perl5/Net/UPnP/Device.pm is in libnet-upnp-perl 1.4.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | package Net::UPnP::Device;
#-----------------------------------------------------------------
# Net::UPnP::Device
#-----------------------------------------------------------------
use strict;
use warnings;
use Net::UPnP::HTTP;
use Net::UPnP::Service;
use vars qw($_SSDP $_DESCRIPTION $_SERVICELIST);
$_SSDP = 'ssdp';
$_DESCRIPTION = 'description';
$_SERVICELIST = 'serviceList';
#------------------------------
# new
#------------------------------
sub new {
my($class) = shift;
my($this) = {
$Net::UPnP::Device::_SSDP => '',
$Net::UPnP::Device::_DESCRIPTION => '',
@Net::UPnP::Device::_SERVICELIST => (),
};
bless $this, $class;
}
#------------------------------
# ssdp
#------------------------------
sub setssdp() {
my($this) = shift;
$this->{$Net::UPnP::Device::_SSDP} = $_[0];
}
sub getssdp() {
my($this) = shift;
$this->{$Net::UPnP::Device::_SSDP};
}
#------------------------------
# description
#------------------------------
sub setdescription() {
my($this) = shift;
my($description) = $_[0];
$this->{$Net::UPnP::Device::_DESCRIPTION} = $description;
$this->setservicefromdescription($description);
}
sub getdescription() {
my($this) = shift;
my %args = (
name => undef,
@_,
);
if ($args{name}) {
# Thanks for Tim Engler <engler at gmail.com> (2009/06/10)
unless ($this->{$Net::UPnP::Device::_DESCRIPTION} =~ m/<$args{name}>(.*?)<\/$args{name}>/i) {
return '';
}
return $1;
}
$this->{$Net::UPnP::Device::_DESCRIPTION};
}
#------------------------------
# service
#------------------------------
sub setservicefromdescription() {
my($this) = shift;
my(
$description,
$servicelist_description,
@serviceList,
$service,
);
$description = $_[0];
unless ($description =~ m/<serviceList>(.*)<\/serviceList>/si) {
return;
}
$servicelist_description = $1;
@{$this->{$Net::UPnP::Device::_SERVICELIST}} = ();
while ($servicelist_description =~ m/<service>(.*?)<\/service>/sgi) {
$service = Net::UPnP::Service->new();
$service->setdevicedescription($1);
$service->setdevice($this);
push (@{$this->{$Net::UPnP::Device::_SERVICELIST}}, $service);
}
}
#------------------------------
# serviceList
#------------------------------
sub getservicelist() {
my($this) = shift;
@{$this->{$Net::UPnP::Device::_SERVICELIST}};
}
#------------------------------
# getservicebyname
#------------------------------
sub getservicebyname() {
my($this) = shift;
my ($service_name) = @_;
my (
@serviceList,
$service,
$service_type,
);
@serviceList = $this->getservicelist();
foreach $service (@serviceList) {
$service_type = $service->getservicetype();
if ($service_type eq $service_name) {
return $service;
}
}
return undef;
}
#------------------------------
# getlocation
#------------------------------
sub getlocation() {
my($this) = shift;
unless ($this->{$Net::UPnP::Device::_SSDP} =~ m/LOCATION[ :]+(.*)\r/i) {
return '';
}
return $1;
}
#------------------------------
# getdevicetype
#------------------------------
sub getdevicetype() {
my($this) = shift;
$this->getdescription(name => 'deviceType');
}
#------------------------------
# getfriendlyname
#------------------------------
sub getfriendlyname() {
my($this) = shift;
$this->getdescription(name => 'friendlyName');
}
#------------------------------
# getmanufacturer
#------------------------------
sub getmanufacturer() {
my($this) = shift;
$this->getdescription(name => 'manufacturer');
}
#------------------------------
# getmanufacturerurl
#------------------------------
sub getmanufacturerurl() {
my($this) = shift;
$this->getdescription(name => 'manufacturerURL');
}
#------------------------------
# getmodeldescription
#------------------------------
sub getmodeldescription() {
my($this) = shift;
$this->getdescription(name => 'modelDescription');
}
#------------------------------
# getmodelname
#------------------------------
sub getmodelname() {
my($this) = shift;
$this->getdescription(name => 'modelName');
}
#------------------------------
# getmodelnumber
#------------------------------
sub getmodelnumber() {
my($this) = shift;
$this->getdescription(name => 'modelNumber');
}
#------------------------------
# getmodelurl
#------------------------------
sub getmodelurl() {
my($this) = shift;
$this->getdescription(name => 'modelURL');
}
#------------------------------
# getserialnumber
#------------------------------
sub getserialnumber() {
my($this) = shift;
$this->getdescription(name => 'serialNumber');
}
#------------------------------
# getudn
#------------------------------
sub getudn() {
my($this) = shift;
$this->getdescription(name => 'UDN');
}
#------------------------------
# getupc
#------------------------------
sub getupc() {
my($this) = shift;
$this->getdescription(name => 'UPC');
}
#------------------------------
# geturlbase
#------------------------------
sub geturlbase() {
my($this) = shift;
$this->getdescription(name => 'URLBase');
}
1;
__END__
=head1 NAME
Net::UPnP::Device - Perl extension for UPnP.
=head1 SYNOPSIS
use Net::UPnP::ControlPoint;
my $obj = Net::UPnP::ControlPoint->new();
@dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
$devNum= 0;
foreach $dev (@dev_list) {
$device_type = $dev->getdevicetype();
if ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') {
next;
}
print "[$devNum] : " . $dev->getfriendlyname() . "\n";
unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) {
next;
}
$condir_service = $dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1');
unless (defined(condir_service)) {
next;
}
%action_in_arg = (
'ObjectID' => 0,
'BrowseFlag' => 'BrowseDirectChildren',
'Filter' => '*',
'StartingIndex' => 0,
'RequestedCount' => 0,
'SortCriteria' => '',
);
$action_res = $condir_service->postcontrol('Browse', \%action_in_arg);
unless ($action_res->getstatuscode() == 200) {
next;
}
$actrion_out_arg = $action_res->getargumentlist();
unless ($actrion_out_arg->{'Result'}) {
next;
}
$result = $actrion_out_arg->{'Result'};
while ($result =~ m/<dc:title>(.*?)<\/dc:title>/sgi) {
print "\t$1\n";
}
$devNum++;
}
=head1 DESCRIPTION
The package is used a object of UPnP device.
=head1 METHODS
=over 4
=item B<getdescription> - get the description.
$description = $dev->getdescription(
name => $name # undef
);
Get the device description of the SSDP location header.
The function returns the all description when the name parameter is not specified, otherwise return a value the specified name.
=item B<getdevicetype> - get the device type.
$description = $dev->getdevicetype();
Get the device type from the device description.
=item B<getfriendlyname> - get the device type.
$friendlyname = $dev->getfriendlyname();
Get the friendly name from the device description.
=item B<getmanufacturer> - get the manufacturer.
$manufacturer = $dev->getmanufacturer();
Get the manufacturer name from the device description.
=item B<getmanufacturerrul> - get the manufacturer url.
$manufacturer_url = $dev->getmanufacturerrul();
Get the manufacturer url from the device description.
=item B<getmodeldescription> - get the model description.
$model_description = $dev->getmodeldescription();
Get the model description from the device description.
=item B<getmodelname> - get the model name.
$model_name = $dev->getmodelname();
Get the model name from the device description.
=item B<getmodelnumber> - get the model number.
$model_number = $dev->getmodelnumber();
Get the model number from the device description.
=item B<getmodelurl> - get the model url.
$model_url = $dev->getmodelurl();
Get the model url from the device description.
=item B<getserialnumber> - get the serialnumber.
$serialnumber = $dev->getserialnumber();
Get the model description from the device description.
=item B<getudn> - get the device UDN.
$udn = $dev->getudn();
Get the UDN from the device description.
=item B<getupc> - get the device UPC.
$upc = $dev->getupc();
Get the UPC from the device description.
=item B<getservicelist> - get the device type.
@service_list = $dev->getservicelist();
Get the service list in the device. Please see L<Net::UPnP::Service> too.
=back
=head1 SEE ALSO
L<Net::UPnP::Service>
=head1 AUTHOR
Satoshi Konno
skonno@cybergarage.org
CyberGarage
http://www.cybergarage.org
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2005 by Satoshi Konno
It may be used, redistributed, and/or modified under the terms of BSD License.
=cut
|