2 ###################################################
6 # This file is part of Shutter.
8 # Shutter is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Shutter is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Shutter; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ###################################################
26 use lib $ENV{'SHUTTER_ROOT'}.'/share/shutter/resources/modules';
30 use POSIX qw/setlocale/;
32 use Glib qw/TRUE FALSE/;
34 use Shutter::Upload::Shared;
35 our @ISA = qw(Shutter::Upload::Shared);
37 my $d = Locale::gettext->domain("shutter-upload-plugins");
38 $d->dir( $ENV{'SHUTTER_INTL'} );
40 my %upload_plugin_info = (
44 'description' => $d->get( "Copy photos via scp. Use user as remote path, password as URL base" ),
45 'supports_anonymous_upload' => FALSE,
46 'supports_authorized_upload' => TRUE,
49 binmode( STDOUT, ":utf8" );
50 if ( exists $upload_plugin_info{$ARGV[ 0 ]} ) {
51 print $upload_plugin_info{$ARGV[ 0 ]};
55 ###################################################
60 #call constructor of super class (host, debug_cparam, shutter_root, gettext_object, main_gtk_window, ua)
61 my $self = $class->SUPER::new( shift, shift, shift, shift, shift, shift );
74 my ( $self, $upload_filename, $username, $password ) = @_;
77 $self->{_filename} = $upload_filename;
79 utf8::encode $upload_filename;
80 utf8::encode $password;
81 utf8::encode $username;
83 $upload_filename =~ m/\/([^\/]*$)/;
86 my $target_filename = $username . "/" . $file;
87 $target_filename =~ s/ /\\ /g;
89 my @args = ("scp", $upload_filename, $target_filename);
93 $self->{_links}{'status'} = 200;
94 $self->{_links}{'url'} = $password . uri_escape($file);
97 $self->{_links}{'status'} = "exec failed: @args / $?";
100 return %{ $self->{_links} };