Skip to content

Commit

Permalink
Fix for JSON::RPC::Client module name change
Browse files Browse the repository at this point in the history
  • Loading branch information
Phill committed Oct 9, 2014
1 parent d3bf850 commit 4c826ca
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions squeezy
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ my $conf_file = $conf_file[0];
#
# some globals
#
my $module = "JSON::RPC::Client";
my $json_module = "JSON::RPC::Client";
my $my_name = "/$0";
$my_name =~ s:^.*/::;
my $server = 'localhost';
Expand Down Expand Up @@ -102,17 +102,24 @@ sub json_support {
my $soft = shift;

# check whether module is already loaded
return 1 if defined $INC{'JSON/RPC/Client.pm'};
return 1 if (defined $INC{'JSON/RPC/Client.pm'} or defined $INC{'JSON/RPC/Legacy/Client.pm'});

eval {
require JSON::RPC::Client;
JSON::RPC::Client->import();
};
if ($@) {
eval {
$json_module = 'JSON::RPC::Legacy::Client';
require JSON::RPC::Legacy::Client;
JSON::RPC::Legacy::Client->import();
};
}

if ($@) {
warn "Install JSON support: sudo apt-get install libjson-rpc-perl" if ( -r "/etc/debian_version" );
die "JSON features not supported: JSON::RPC::Client not available" if not $soft;
warn "JSON features not supported: JSON::RPC::Client not available... Trying to cope." if $soft > 1;
die "JSON features not supported: JSON::RPC::(Legacy::)Client not available" if not $soft;
warn "JSON features not supported: JSON::RPC::(Legacy::)Client not available... Trying to cope." if $soft > 1;
return 0;
}
return 1;
Expand Down Expand Up @@ -237,7 +244,7 @@ sub slimrequest {
my ($server, $player, $command_and_ags) = @_;
json_support();

my $client = $server->{JSONC} ? $server->{JSONC} : new JSON::RPC::Client;
my $client = $server->{JSONC} ? $server->{JSONC} : new $json_module;
my $uri = $json_api_uri_pre.($server->{IP}||$server->{HOST}).":".($server->{JSON}||$json).$json_api_uri_post;

my $callobj = {
Expand Down

0 comments on commit 4c826ca

Please sign in to comment.