|
1 # Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of the License "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 # |
|
16 |
|
17 package RemoteSite; |
|
18 |
|
19 use strict; |
|
20 use File::Basename; |
|
21 use Utils; |
|
22 |
|
23 # |
|
24 # Constructor |
|
25 # |
|
26 |
|
27 sub New { |
|
28 my $invocant = shift; |
|
29 my $class = ref($invocant) || $invocant; |
|
30 my $self = { |
|
31 host => undef, |
|
32 verbose => 0 |
|
33 }; |
|
34 bless $self, $class; |
|
35 $self->Initialize(@_); |
|
36 return $self; |
|
37 } |
|
38 |
|
39 sub Initialize { |
|
40 my $self = shift; |
|
41 |
|
42 my %args = @_; |
|
43 $self->{host} = $args{host}; |
|
44 $self->{verbose} = $args{verbose}; |
|
45 } |
|
46 |
|
47 # |
|
48 # Public getters/setters |
|
49 # |
|
50 |
|
51 sub Host { |
|
52 my $self = shift; |
|
53 if (defined $_[0]) {$self->{host} = shift;} |
|
54 return $self->{host}; |
|
55 } |
|
56 |
|
57 # |
|
58 # Private Methods |
|
59 # |
|
60 |
|
61 sub HandleError { |
|
62 my $self = shift; |
|
63 my $errorString = shift; |
|
64 |
|
65 die "Error: $errorString\n"; |
|
66 } |
|
67 |
|
68 # |
|
69 # Abstract methods (must be implemented in a subclass) |
|
70 # |
|
71 |
|
72 sub SendFile { |
|
73 die "Error: Call to unimplemented abstract method ".ref($_[0])."::SendFile.\n"; |
|
74 } |
|
75 |
|
76 sub GetFile { |
|
77 die "Error: Call to unimplemented abstract method ".ref($_[0])."::GetFile.\n"; |
|
78 } |
|
79 |
|
80 sub FileExists { |
|
81 die "Error: Call to unimplemented abstract method ".ref($_[0])."::FileExists.\n"; |
|
82 } |
|
83 |
|
84 sub DirList { |
|
85 die "Error: Call to unimplemented abstract method ".ref($_[0])."::DirList.\n"; |
|
86 } |
|
87 |
|
88 sub MakeDir { |
|
89 die "Error: Call to unimplemented abstract method ".ref($_[0])."::MakeDir.\n"; |
|
90 } |
|
91 |
|
92 sub FileSize { |
|
93 die "Error: Call to unimplemented abstract method ".ref($_[0])."::FileSize.\n"; |
|
94 } |
|
95 |
|
96 sub DeleteFile { |
|
97 die "Error: Call to unimplemented abstract method ".ref($_[0])."::DeleteFile.\n"; |
|
98 } |
|
99 |
|
100 sub MoveFile { |
|
101 die "Error: Call to unimplemented abstract method ".ref($_[0])."::MoveFile.\n"; |
|
102 } |
|
103 |
|
104 sub FileModifiedTime { |
|
105 die "Error: Call to unimplemented abstract method ".ref($_[0])."::FileModifiedTime.\n"; |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 1; |
|
111 |
|
112 =head1 NAME |
|
113 |
|
114 RemoteSite.pm - Abstract base module for remote site access |
|
115 |
|
116 =head1 DESCRIPTION |
|
117 |
|
118 C<RemoteSite> is the abstract base module to a family of modules of the form C<RemoteSite::>F<HostType> which are used to transfer files to and from a remote site. Each module in the C<RemoteSite> directory must implement the following abstract interface... |
|
119 |
|
120 =over 4 |
|
121 |
|
122 =item * SendFile($localFile, $remoteFile) |
|
123 |
|
124 Should copy C<$localFile> from the local drive to C<$remoteFile> on the remote site. |
|
125 |
|
126 =item * GetFile($remoteFile, $localFile) |
|
127 |
|
128 Should copy C<$remoteFile> from the remote site to C<$localFile> on the local drive. |
|
129 |
|
130 =item * bool FileExists($remoteFile) |
|
131 |
|
132 Should return a non zero value if C<$remoteFile> exists or zero if not. |
|
133 |
|
134 =back |
|
135 |
|
136 If no connection can be made to the remote site then the module must throw an error containing the words C<"cannot connect"> |
|
137 |
|
138 =head1 KNOWN BUGS |
|
139 |
|
140 None. |
|
141 |
|
142 =head1 COPYRIGHT |
|
143 |
|
144 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
145 All rights reserved. |
|
146 This component and the accompanying materials are made available |
|
147 under the terms of the License "Eclipse Public License v1.0" |
|
148 which accompanies this distribution, and is available |
|
149 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
150 |
|
151 Initial Contributors: |
|
152 Nokia Corporation - initial contribution. |
|
153 |
|
154 Contributors: |
|
155 |
|
156 Description: |
|
157 |
|
158 |
|
159 =cut |