/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

google/trunk/lib/CWMP/Response.pm revision 141 by oleide, Sat Oct 27 17:57:40 2007 UTC google/trunk/lib/CWMP/Methods.pm revision 174 by dpavlin, Sun Oct 28 16:57:34 2007 UTC
# Line 1  Line 1 
1  package CWMP::Response;  package CWMP::Methods;
2    
3  use strict;  use strict;
4  use warnings;  use warnings;
# Line 13  use Data::Dump qw/dump/; Line 13  use Data::Dump qw/dump/;
13    
14  =head1 NAME  =head1 NAME
15    
16  CWMP::Response - generate SOAP meesage for response  CWMP::Methods - generate SOAP meesages for CPE
17    
18  =head2 METHODS  =head1 METHODS
19    
20  =head2 new  =head2 new
21    
22    my $response = CWMP::Response->new({ debug => 1 });    my $method = CWMP::Methods->new({ debug => 1 });
23    
24  =cut  =cut
25    
# Line 32  sub new { Line 32  sub new {
32          return $self;          return $self;
33  }  }
34    
35    =head2 xml
36    
37    Used to implement methods which modify just body of soap message.
38    For examples, see source of this module.
39    
40    =cut
41    
42  my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ];  my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ];
43  my $soap = [ soap => "http://schemas.xmlsoap.org/soap/envelope/" ];  my $soap = [ soap => 'http://schemas.xmlsoap.org/soap/envelope/' ];
44    my $xsd  = [ xsd  => 'http://www.w3.org/2001/XMLSchema-instance' ];
45    
46  =head2 InformResponse  sub xml {
47            my $self = shift;
48    
49    $response->InformResponse( $state );          my ( $state, $closure ) = @_;
50    
51  =cut          confess "no state?" unless ($state);
52            confess "no body closure" unless ( $closure );
53    
54  sub InformResponse {          confess "no ID in state ", dump( $state ) unless ( $state->{ID} );
55          my ( $self, $state ) = @_;  
56          $self->xml( $state, sub {          #warn "state used to generate xml = ", dump( $state ) if $self->debug;
57                  my ( $X, $state ) = @_;  
58                  $X->InformResponse( $cwmp,          my $X = XML::Generator->new(':pretty');
59                          $X->MaxEnvelopes( $cwmp, 1 )  
60                  );          return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" },
61          });                  $X->Header( $soap,
62                            $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ),
63                            $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ),
64                    ),
65                    $X->Body( $soap, $closure->( $X, $state ) ),
66            );
67  }  }
68    
69    =head1 CPE methods
70    
71  =head2 GetRPCMethods  =head2 GetRPCMethods
72    
73    $response->GetRPCMethods( $state );    $method->GetRPCMethods( $state );
74    
75  =cut  =cut
76    
# Line 66  sub GetRPCMethods { Line 82  sub GetRPCMethods {
82          });          });
83  };  };
84    
85  =head2 Reboot {  =head2 SetParameterValues
86    
87    B<not implemented>
88    
89    =head2 GetParameterValues
90    
91    $response->Reboot( $state );    $method->GetParameterValues( $state, $ParameterNames );
92    
93  =cut  =cut
94    
95  sub Reboot {  sub GetParameterValues {
96          my ( $self, $state ) = @_;          my $self = shift;
97            my $state = shift;
98            my @ParameterNames = @_;
99            confess "need ParameterNames" unless @ParameterNames;
100            warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug;
101    
102          $self->xml( $state, sub {          $self->xml( $state, sub {
103                  my ( $X, $state ) = @_;                  my ( $X, $state ) = @_;
104                  $X->Reboot();  
105                    $X->GetParameterValues( $cwmp,
106                            $X->ParameterNames( $cwmp,
107                                    map {
108                                            $X->string( $xsd, $_ )
109                                    } @ParameterNames
110                            )
111                    );
112          });          });
113  }  }
114    
115  =head2 GetParameterNames {  =head2 GetParameterNames
116    
117    $response->GetParameterNames( $state, $ParameterPath, $NextLevel );    $method->GetParameterNames( $state, $ParameterPath, $NextLevel );
118    
119  =cut  =cut
120    
# Line 101  sub GetParameterNames { Line 133  sub GetParameterNames {
133          });          });
134  }  }
135    
136  =head2 GetParameterValues {  =head2 Reboot
137    
138    $response->GetParameterValues( $state, $ParameterPath, $NextLevel );    $method->Reboot( $state );
139    
140  =cut  =cut
141    
142  sub GetParameterValues {  sub Reboot {
143          my ( $self, $state, $ParameterPath, $NextLevel ) = @_;          my ( $self, $state ) = @_;
         $ParameterPath ||= '';  # all  
         $NextLevel ||= 0;               # all  
         warn "# GetParameterValues( '$ParameterPath', $NextLevel )\n" if $self->debug;  
144          $self->xml( $state, sub {          $self->xml( $state, sub {
145                  my ( $X, $state ) = @_;                  my ( $X, $state ) = @_;
146                    $X->Reboot();
                 $X->GetParameterValues( $cwmp,  
                         $X->ParameterPath( $cwmp, $ParameterPath ),  
                         $X->NextLevel( $cwmp, $NextLevel ),  
                 );  
147          });          });
148  }  }
149    
 =head2 xml  
150    
151  Used to implement methods which modify just body of soap message.  =head1 Server methods
 For examples, see source of this module.  
152    
 =cut  
153    
154  sub xml {  =head2 InformResponse
         my $self = shift;  
155    
156          my ( $state, $closure ) = @_;    $method->InformResponse( $state );
157    
158          confess "no state?" unless ($state);  =cut
         confess "no body closure" unless ( $closure );  
159    
160          confess "no ID in state ", dump( $state ) unless ( $state->{ID} );  sub InformResponse {
161            my ( $self, $state ) = @_;
162            $self->xml( $state, sub {
163                    my ( $X, $state ) = @_;
164                    $X->InformResponse( $cwmp,
165                            $X->MaxEnvelopes( $cwmp, 1 )
166                    );
167            });
168    }
169    
170          #warn "state used to generate xml = ", dump( $state ) if $self->debug;  =head1 BUGS
171    
172          my $X = XML::Generator->new(':pretty');  All other methods are unimplemented.
173    
174          return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" },  =cut
                 $X->Header( $soap,  
                         $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ),  
                         $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ),  
                 ),  
                 $X->Body( $soap, $closure->( $X, $state ) ),  
         );  
 }  
175    
176  1;  1;

Legend:
Removed from v.141  
changed lines
  Added in v.174

  ViewVC Help
Powered by ViewVC 1.1.26