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