File Coverage

blib/lib/JOAP/Proxy/Package/Server.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             # JOAP::Proxy::Package::Server -- Base Class for Proxies of JOAP Server
2             #
3             # Copyright (c) 2003, Evan Prodromou
4             #
5             # This library is free software; you can redistribute it and/or
6             # modify it under the terms of the GNU Lesser General Public
7             # License as published by the Free Software Foundation; either
8             # version 2.1 of the License, or (at your option) any later version.
9             #
10             # This library is distributed in the hope that it will be useful,
11             # but WITHOUT ANY WARRANTY; without even the implied warranty of
12             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13             # Lesser General Public License for more details.
14             #
15             # You should have received a copy of the GNU Lesser General Public
16             # License along with this library; if not, write to the Free Software
17             # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18              
19             # tag: JOAP server proxy base class
20              
21             package JOAP::Proxy::Package::Server;
22 1     1   2731 use JOAP;
  0            
  0            
23             use JOAP::Proxy::Package;
24             use JOAP::Proxy::Server;
25             use base qw/JOAP::Proxy::Package JOAP::Proxy::Server/;
26              
27             use 5.008;
28             use strict;
29             use warnings;
30              
31             our %EXPORT_TAGS = ( 'all' => [ qw// ] );
32             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
33             our @EXPORT = qw//;
34              
35             our $VERSION = $JOAP::VERSION;
36              
37             JOAP::Proxy::Package::Server->mk_classdata('Address');
38             JOAP::Proxy::Package::Server->mk_classdata('Classes');
39             JOAP::Proxy::Package::Server->mk_classdata('ClassProxy');
40              
41             JOAP::Proxy::Package::Server->Address('');
42             JOAP::Proxy::Package::Server->Classes([]);
43             JOAP::Proxy::Package::Server->ClassProxy({});
44              
45             sub classes {
46             my $self = shift;
47             return $self->Classes(@_);
48             }
49              
50             sub address {
51             my $self = shift;
52             return $self->Address(@_);
53             }
54              
55             sub _describe {
56              
57             my $self = shift;
58             my $resp = $self->SUPER::_describe(@_);
59              
60             # Need to get the classes, too.
61              
62             my @classes = $resp->GetQuery->GetClass;
63             $self->Classes(\@classes);
64              
65             # XXX: update addresses for classes in classmap
66              
67             return $resp;
68             }
69              
70             sub proxy_class {
71              
72             my $self = shift;
73             my $class_address = shift;
74              
75             my $jid = new Net::Jabber::JID($class_address);
76              
77             if ($jid->GetServer ne $self->address) {
78             return undef;
79             }
80              
81             my $class_id = $jid->GetUserID;
82              
83             if (!$class_id) {
84             return undef;
85             }
86              
87             my $class = $self->ClassProxy->{$class_id};
88              
89             if (!$class) {
90             return undef;
91             }
92              
93             $class->Address($class_address);
94              
95             $class->refresh;
96              
97             return $class;
98             }
99              
100             sub method {
101             my $self = shift;
102             my $name = shift;
103              
104             my $desc = $self->_method_descriptor($name);
105             my $method = $self->_proxy_method($desc);
106              
107             return $method;
108             }
109              
110             sub accessor {
111             my $self = shift;
112             my $name = shift;
113              
114             my $desc = $self->_attribute_descriptor($name);
115             my $accessor = $self->_proxy_accessor($desc);
116              
117             return $accessor;
118             }
119              
120             1; # gotta return something true
121              
122             __END__