/[cwmp]/google/trunk/lib/CWMP/Request.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/Request.pm

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

revision 185 by dpavlin, Fri Oct 26 11:42:39 2007 UTC revision 186 by dpavlin, Tue Oct 30 15:26:41 2007 UTC
# Line 10  use Carp qw/confess cluck/; Line 10  use Carp qw/confess cluck/;
10    
11  =head1 NAME  =head1 NAME
12    
13  CWMP::Request - parse SOAP request  CWMP::Request - parse SOAP request metods
14    
15  =head1 METHODS  =head1 METHODS
16    
# Line 45  sub _tag { Line 45  sub _tag {
45          }          }
46  }  }
47    
48    =head2 parse
49    
50      my $state = CWMP::Request->parse( "<soap>request</soap>" );
51    
52    =cut
53    
54    sub parse {
55            my $self = shift;
56    
57            my $xml = shift || confess "no xml?";
58    
59            $state = {};
60            $parser->parsestring( $xml );
61            return $state;
62    }
63    
64    =head1 CPE metods
65    
66    =cut
67    
68  our $state;     # FIXME check this!  our $state;     # FIXME check this!
69    
70  my $tree = CWMP::Tree->new({ debug => 0 });  my $tree = CWMP::Tree->new({ debug => 0 });
# Line 70  my $parser = XML::Rules->new( Line 90  my $parser = XML::Rules->new(
90                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
91                          $state->{ID} = $tag_hash->{_content};                          $state->{ID} = $tag_hash->{_content};
92                  },                  },
93                  #  
94                  # Inform  =head2 Inform
95                  #  
96    Generate InformResponse to CPE
97    
98    =cut
99    
100                  'Inform' => sub {                  'Inform' => sub {
101                          $state->{_dispatch} = 'InformResponse';         # what reponse to call                          $state->{_dispatch} = 'InformResponse';         # what reponse to call
102                  },                  },
# Line 99  my $parser = XML::Rules->new( Line 123  my $parser = XML::Rules->new(
123                          my $value = (grep( /value/i, keys %$tag_hash ))[0];                          my $value = (grep( /value/i, keys %$tag_hash ))[0];
124                          $state->{Parameter}->{ _tag($tag_hash, 'Name', '_content') } = _tag($tag_hash, 'Value', '_content' );                          $state->{Parameter}->{ _tag($tag_hash, 'Name', '_content') } = _tag($tag_hash, 'Value', '_content' );
125                  },                  },
126                  #  
127                  # GetRPCMethodsResponse  =head2 GetRPCMethodsResponse
128                  #  
129    =cut
130                  qr/^(?:^\w+:)*string$/ => 'content array',                  qr/^(?:^\w+:)*string$/ => 'content array',
131                  'MethodList' => sub {                  'MethodList' => sub {
132                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
133                          $state->{MethodList} = _tag( $tag_hash, 'string' );                          $state->{MethodList} = _tag( $tag_hash, 'string' );
134                  },                  },
135                  #  
136                  # GetParameterNamesResponse  =head2 GetParameterNamesResponse
137                  #  
138    =cut
139    
140                  'ParameterInfoStruct' => sub {                  'ParameterInfoStruct' => sub {
141                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
142                          my $name = _tag($tag_hash, 'Name', '_content');                          my $name = _tag($tag_hash, 'Name', '_content');
# Line 124  my $parser = XML::Rules->new( Line 151  my $parser = XML::Rules->new(
151    
152                          #warn "## state = dump( $state ), "\n";                          #warn "## state = dump( $state ), "\n";
153                  },                  },
154                  #          
155                  # Fault  =head2 Fault
156                  #  
157    =cut
158    
159                  'Fault' => sub {                  'Fault' => sub {
160                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
161                          $state->{Fault} = {                          $state->{Fault} = {
# Line 138  my $parser = XML::Rules->new( Line 167  my $parser = XML::Rules->new(
167          ]          ]
168  );  );
169    
 =head2 parse  
   
   my $state = CWMP::Request->parse( "<soap>request</soap>" );  
   
 =cut  
   
 sub parse {  
         my $self = shift;  
   
         my $xml = shift || confess "no xml?";  
   
         $state = {};  
         $parser->parsestring( $xml );  
         return $state;  
 }  
   
170  1;  1;

Legend:
Removed from v.185  
changed lines
  Added in v.186

  ViewVC Help
Powered by ViewVC 1.1.26