X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2FCWMP%2FMethods.pm;h=585dcebfe4bfc57cb291b5d7e8939ac420a26b0a;hb=0096fa526f2bff8da10e3c81d14daa03efc6aef2;hp=e50b9232881d8c0769ed7fe7a7f9a2b0ec7e12f2;hpb=172db50375bdd0143d5b4de649606d90057317ca;p=perl-cwmp.git diff --git a/lib/CWMP/Methods.pm b/lib/CWMP/Methods.pm index e50b923..585dceb 100644 --- a/lib/CWMP/Methods.pm +++ b/lib/CWMP/Methods.pm @@ -84,19 +84,64 @@ sub GetRPCMethods { =head2 SetParameterValues -B + $method->SetParameterValues( $state, { + param1 => 'value1', + param2 => 'value2', + ... + }); + +It doesn't support base64 encoding of values yet. + +To preserve data, it does support repeatable parametar names. +Behaviour on this is not defined in protocol. + +=cut + +sub SetParameterValues { + my $self = shift; + my $state = shift; + + confess "SetParameterValues needs parameters" unless @_; + + my $params = shift || return; + + warn "# SetParameterValues = ", dump( $params ), "\n" if $self->debug; + + $self->xml( $state, sub { + my ( $X, $state ) = @_; + + $X->SetParameterValues( $cwmp, + $X->ParameterList( $cwmp, + $X->ParameterNames( $cwmp, + map { + $X->ParameterValueStruct( $cwmp, + $X->Name( $cwmp, $_ ), + $X->Value( $cwmp, $params->{$_} ) + ) + } sort keys %$params + ) + ) + ); + }); +} + =head2 GetParameterValues - $method->GetParameterValues( $state, $ParameterNames ); + $method->GetParameterValues( $state, [ 'ParameterName', ... ] ); =cut +sub _array_param { + my $v = shift; + confess "array_mandatory(",dump($v),") isn't ARRAY" unless ref($v) eq 'ARRAY'; + return @$v; +} + sub GetParameterValues { my $self = shift; my $state = shift; - my @ParameterNames = @_; - confess "need ParameterNames" unless @ParameterNames; + my @ParameterNames = _array_param(shift); warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug; $self->xml( $state, sub { @@ -114,14 +159,16 @@ sub GetParameterValues { =head2 GetParameterNames - $method->GetParameterNames( $state, $ParameterPath, $NextLevel ); + $method->GetParameterNames( $state, [ $ParameterPath, $NextLevel ] ); =cut sub GetParameterNames { - my ( $self, $state, $ParameterPath, $NextLevel ) = @_; - $ParameterPath ||= ''; # all - $NextLevel ||= 0; # all + my ( $self, $state, $param ) = @_; + # default: all, all + my ( $ParameterPath, $NextLevel ) = _array_param( $param ); + $ParameterPath ||= ''; + $NextLevel ||= 0; warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug; $self->xml( $state, sub { my ( $X, $state ) = @_; @@ -133,6 +180,31 @@ sub GetParameterNames { }); } +=head2 GetParameterAttributes + + $method->GetParameterAttributes( $state, [ $ParametarNames, ... ] ); + +=cut + +sub GetParameterAttributes { + my ( $self, $state, $param ) = @_; + my @ParameterNames = _array_param($param); + + warn "# GetParameterAttributes", dump( @ParameterNames ), "\n" if $self->debug; + + $self->xml( $state, sub { + my ( $X, $state ) = @_; + + $X->GetParameterAttributes( $cwmp, + $X->ParameterNames( $cwmp, + map { + $X->string( $xsd, $_ ) + } @ParameterNames + ) + ); + }); +} + =head2 Reboot $method->Reboot( $state );