/[cwmp]/google/trunk/lib/CWMP/Methods.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /google/trunk/lib/CWMP/Methods.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 112 - (show annotations)
Fri Oct 26 11:42:39 2007 UTC (16 years, 7 months ago) by dpavlin
Original Path: google/trunk/lib/CWMP/Response.pm
File size: 2503 byte(s)
reorg source code tree to make trunk
1 package CWMP::Response;
2
3 use strict;
4 use warnings;
5
6
7 use base qw/Class::Accessor/;
8 __PACKAGE__->mk_accessors( qw/debug/ );
9
10 use XML::Generator;
11 use Carp qw/confess/;
12 use Data::Dump qw/dump/;
13
14 =head1 NAME
15
16 CWMP::Response - generate SOAP meesage for response
17
18 =head2 METHODS
19
20 =head2 new
21
22 my $response = CWMP::Response->new({ debug => 1 });
23
24 =cut
25
26 sub new {
27 my $class = shift;
28 my $self = $class->SUPER::new( @_ );
29
30 warn "created XML::Generator object\n" if $self->debug;
31
32 return $self;
33 }
34
35
36 my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ];
37 my $soap = [ soap => "http://schemas.xmlsoap.org/soap/envelope/" ];
38
39 =head2 InformResponse
40
41 $response->InformResponse( $state );
42
43 =cut
44
45 sub InformResponse {
46 my ( $self, $state ) = @_;
47 $self->xml( $state, sub {
48 my ( $X, $state ) = @_;
49 $X->InformResponse( $cwmp,
50 $X->MaxEnvelopes( $cwmp, 1 )
51 );
52 });
53 }
54
55 =head2 GetRPCMethods
56
57 $response->GetRPCMethods( $state );
58
59 =cut
60
61 sub GetRPCMethods {
62 my ( $self, $state ) = @_;
63 $self->xml( $state, sub {
64 my ( $X, $state ) = @_;
65 $X->GetRPCMethods();
66 });
67 };
68
69 =head2 Reboot {
70
71 $response->Reboot( $state );
72
73 =cut
74
75 sub Reboot {
76 my ( $self, $state ) = @_;
77 $self->xml( $state, sub {
78 my ( $X, $state ) = @_;
79 $X->Reboot();
80 });
81 }
82
83 =head2 GetParameterNames {
84
85 $response->GetParameterNames( $state, $ParameterPath, $NextLevel );
86
87 =cut
88
89 sub GetParameterNames {
90 my ( $self, $state, $ParameterPath, $NextLevel ) = @_;
91 $ParameterPath ||= ''; # all
92 $NextLevel ||= 0; # all
93 warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug;
94 $self->xml( $state, sub {
95 my ( $X, $state ) = @_;
96
97 $X->GetParameterNames( $cwmp,
98 $X->ParameterPath( $cwmp, $ParameterPath ),
99 $X->NextLevel( $cwmp, $NextLevel ),
100 );
101 });
102 }
103
104 =head2 xml
105
106 Used to implement methods which modify just body of soap message.
107 For examples, see source of this module.
108
109 =cut
110
111 sub xml {
112 my $self = shift;
113
114 my ( $state, $closure ) = @_;
115
116 confess "no state?" unless ($state);
117 confess "no body closure" unless ( $closure );
118
119 confess "no ID in state ", dump( $state ) unless ( $state->{ID} );
120
121 #warn "state used to generate xml = ", dump( $state ) if $self->debug;
122
123 my $X = XML::Generator->new(':pretty');
124
125 return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" },
126 $X->Header( $soap,
127 $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ),
128 $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ),
129 ),
130 $X->Body( $soap, $closure->( $X, $state ) ),
131 );
132 }
133
134 1;

  ViewVC Help
Powered by ViewVC 1.1.26