summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorkhoff <khoff>2005-03-08 18:15:09 +0000
committerkhoff <khoff>2005-03-08 18:15:09 +0000
commit68c43e49c834314e64b8c6929ba231feca151e7e (patch)
tree6a24e7175beb45e0abfb9ec9f59dca529bc714b8 /FS/FS
parentfffa50e1757bc57a5c062228f02a354cce58236d (diff)
Minor re-work to allow for pseudo methods, like 'version', and eventually config look-ups (next commit).
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/XMLRPC.pm81
1 files changed, 47 insertions, 34 deletions
diff --git a/FS/FS/XMLRPC.pm b/FS/FS/XMLRPC.pm
index c7f2d73..287a502 100644
--- a/FS/FS/XMLRPC.pm
+++ b/FS/FS/XMLRPC.pm
@@ -3,8 +3,12 @@ package FS::XMLRPC;
use strict;
use vars qw( @ISA $DEBUG );
use Frontier::RPC2;
-use FS::Record qw( qsearch qsearchs );
-use FS::cust_main qw( smart_search );
+
+# Instead of 'use'ing freeside modules on the fly below, just preload them now.
+use FS;
+use FS::CGI;
+use FS::Record;
+use FS::cust_main;
@ISA = qw( );
@@ -84,39 +88,48 @@ sub _serve { #Subroutine, not method
#die 'Called _serve without parameters' unless ref($params) eq 'ARRAY';
$params = [] unless (ref($params) eq 'ARRAY');
- my ($class, $sub) = split(/\./, $method_name);
- my $fssub = "FS::${class}::${sub}";
- warn "fssub: ${fssub}" if $DEBUG;
- warn "params: " . Dumper($params) if $DEBUG;
-
- unless (UNIVERSAL::can("FS::${class}", $sub)) {
- warn "FS::XMLRPC: Can't call undefined subroutine '${fssub}'";
- # Should we encode an error in the response,
- # or just break silently to the remote caller and complain locally?
- return [];
- }
-
- my @result;
- eval {
- no strict 'refs';
+ if ($method_name =~ /^(\w+)\.(\w+)/) {
+
+ #my ($class, $sub) = split(/\./, $method_name);
+ my ($class, $sub) = ($1, $2);
my $fssub = "FS::${class}::${sub}";
- @result = (&$fssub(@$params));
- };
-
- if ($@) {
- warn "FS::XMLRPC: Error while calling '${fssub}': $@";
- return [];
- }
-
- warn Dumper(@result);
-
- if (grep { UNIVERSAL::can($_, 'hashref') ? 0 : 1 } @result) {
- warn "FS::XMLRPC: One or more objects returned from '${fssub}' doesn't " .
- "support the 'hashref' method.";
- return [];
- } else {
- return [ map { $_->hashref } @result ];
- }
+ warn "fssub: ${fssub}" if $DEBUG;
+ warn "params: " . Dumper($params) if $DEBUG;
+
+ unless (UNIVERSAL::can("FS::${class}", $sub)) {
+ warn "FS::XMLRPC: Can't call undefined subroutine '${fssub}'";
+ # Should we encode an error in the response,
+ # or just break silently to the remote caller and complain locally?
+ return [];
+ }
+
+ my @result;
+ eval {
+ no strict 'refs';
+ my $fssub = "FS::${class}::${sub}";
+ @result = (&$fssub(@$params));
+ };
+
+ if ($@) {
+ warn "FS::XMLRPC: Error while calling '${fssub}': $@";
+ return [];
+ }
+
+ warn Dumper(@result);
+
+ if (grep { UNIVERSAL::can($_, 'hashref') ? 0 : 1 } @result) {
+ warn "FS::XMLRPC: One or more objects returned from '${fssub}' doesn't " .
+ "support the 'hashref' method.";
+ return [];
+ } else {
+ return [ map { $_->hashref } @result ];
+ }
+ } elsif ($method_name eq 'version') {
+ return [ $FS::VERSION ];
+ } # else...
+
+ warn "Unhandle XMLRPC request '${method_name}'";
+ return [];
}