From 172db50375bdd0143d5b4de649606d90057317ca Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 28 Oct 2007 16:57:34 +0000 Subject: [PATCH] no functional changes, just cleanup of pod and re-order methods git-svn-id: https://perl-cwmp.googlecode.com/svn/trunk@173 836a5e1a-633d-0410-964b-294494ad4392 --- lib/CWMP/Methods.pm | 129 ++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 57 deletions(-) diff --git a/lib/CWMP/Methods.pm b/lib/CWMP/Methods.pm index f8bf3ae..e50b923 100644 --- a/lib/CWMP/Methods.pm +++ b/lib/CWMP/Methods.pm @@ -15,11 +15,11 @@ use Data::Dump qw/dump/; CWMP::Methods - generate SOAP meesages for CPE -=head2 METHODS +=head1 METHODS =head2 new - my $response = CWMP::Methods->new({ debug => 1 }); + my $method = CWMP::Methods->new({ debug => 1 }); =cut @@ -32,30 +32,45 @@ sub new { return $self; } +=head2 xml + +Used to implement methods which modify just body of soap message. +For examples, see source of this module. + +=cut my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ]; my $soap = [ soap => 'http://schemas.xmlsoap.org/soap/envelope/' ]; my $xsd = [ xsd => 'http://www.w3.org/2001/XMLSchema-instance' ]; -=head2 InformResponse +sub xml { + my $self = shift; - $response->InformResponse( $state ); + my ( $state, $closure ) = @_; -=cut + confess "no state?" unless ($state); + confess "no body closure" unless ( $closure ); -sub InformResponse { - my ( $self, $state ) = @_; - $self->xml( $state, sub { - my ( $X, $state ) = @_; - $X->InformResponse( $cwmp, - $X->MaxEnvelopes( $cwmp, 1 ) - ); - }); + confess "no ID in state ", dump( $state ) unless ( $state->{ID} ); + + #warn "state used to generate xml = ", dump( $state ) if $self->debug; + + my $X = XML::Generator->new(':pretty'); + + return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" }, + $X->Header( $soap, + $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ), + $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ), + ), + $X->Body( $soap, $closure->( $X, $state ) ), + ); } +=head1 CPE methods + =head2 GetRPCMethods - $response->GetRPCMethods( $state ); + $method->GetRPCMethods( $state ); =cut @@ -67,23 +82,39 @@ sub GetRPCMethods { }); }; -=head2 Reboot +=head2 SetParameterValues + +B + +=head2 GetParameterValues - $response->Reboot( $state ); + $method->GetParameterValues( $state, $ParameterNames ); =cut -sub Reboot { - my ( $self, $state ) = @_; +sub GetParameterValues { + my $self = shift; + my $state = shift; + my @ParameterNames = @_; + confess "need ParameterNames" unless @ParameterNames; + warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug; + $self->xml( $state, sub { my ( $X, $state ) = @_; - $X->Reboot(); + + $X->GetParameterValues( $cwmp, + $X->ParameterNames( $cwmp, + map { + $X->string( $xsd, $_ ) + } @ParameterNames + ) + ); }); } =head2 GetParameterNames - $response->GetParameterNames( $state, $ParameterPath, $NextLevel ); + $method->GetParameterNames( $state, $ParameterPath, $NextLevel ); =cut @@ -102,60 +133,44 @@ sub GetParameterNames { }); } -=head2 GetParameterValues +=head2 Reboot - $response->GetParameterValues( $state, $ParameterNames ); + $method->Reboot( $state ); =cut -sub GetParameterValues { - my $self = shift; - my $state = shift; - my @ParameterNames = @_; - confess "need ParameterNames" unless @ParameterNames; - warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug; - +sub Reboot { + my ( $self, $state ) = @_; $self->xml( $state, sub { my ( $X, $state ) = @_; - - $X->GetParameterValues( $cwmp, - $X->ParameterNames( $cwmp, - map { - $X->string( $xsd, $_ ) - } @ParameterNames - ) - ); + $X->Reboot(); }); } -=head2 xml -Used to implement methods which modify just body of soap message. -For examples, see source of this module. +=head1 Server methods -=cut -sub xml { - my $self = shift; +=head2 InformResponse - my ( $state, $closure ) = @_; + $method->InformResponse( $state ); - confess "no state?" unless ($state); - confess "no body closure" unless ( $closure ); +=cut - confess "no ID in state ", dump( $state ) unless ( $state->{ID} ); +sub InformResponse { + my ( $self, $state ) = @_; + $self->xml( $state, sub { + my ( $X, $state ) = @_; + $X->InformResponse( $cwmp, + $X->MaxEnvelopes( $cwmp, 1 ) + ); + }); +} - #warn "state used to generate xml = ", dump( $state ) if $self->debug; +=head1 BUGS - my $X = XML::Generator->new(':pretty'); +All other methods are unimplemented. - return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" }, - $X->Header( $soap, - $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ), - $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ), - ), - $X->Body( $soap, $closure->( $X, $state ) ), - ); -} +=cut 1; -- 2.20.1