1 # ---------------------------------------------------------------
2 # Copyright © 2014 Jason J.A. Stephenson <jason@sigio.com>
4 # This file is part of NCIPServer.
6 # NCIPServer is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # NCIPServer is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with NCIPServer. If not, see <http://www.gnu.org/licenses/>.
18 # ---------------------------------------------------------------
28 my $class = ref $invocant || $invocant;
29 my $self = bless {@_}, $class;
33 # Methods required for SHAREit:
38 sub cancelrequestitem {
56 # Other methods, just because.
58 # Handle a LookupVersion Request. You probably want to just call this
59 # one from your subclasses rather than reimplement it.
64 my $response = NCIP::Response->new({type => "LookupVersionResponse"});
65 $response->header($self->make_header($request));
67 versions => [ NCIP::Const::SUPPORTED_VERSIONS ]
69 $response->data($payload);
74 # A few helper methods:
76 # All subclasses will possibly want to create a ResponseHeader and the
77 # code for that would be highly redundant. We supply a default
78 # implementation here that can retrieve the agency information from
79 # the InitiationHeader of the message, swap their values, and return a
88 for my $key (keys %$request) {
89 if (ref $request->{$key} eq 'HASH'
90 && $request->{$key}->{InitiationHeader}) {
91 $initheader = $request->{$key}->{InitiationHeader};
96 if ($initheader && $initheader->{FromAgencyId}
97 && $initheader->{ToAgencyId}) {
98 $header = NCIP::Header->new({
99 FromAgencyId => $initheader->{ToAgencyId},
100 ToAgencyId => $initheader->{FromAgencyId}