/*
- * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
+ * Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
%{
#include "glib-util.h"
#include "amxfer.h"
+#include "amanda.h"
+#include "sockaddr-util.h"
%}
/* The SWIGging of the transfer architecture.
void xfer_unref(Xfer *);
xfer_status xfer_get_status(Xfer *xfer);
char *xfer_repr(Xfer *xfer);
-void xfer_start(Xfer *xfer);
+void xfer_start(Xfer *xfer, gint64 offset, gint64 size);
void xfer_cancel(Xfer *xfer);
/* xfer_get_source is implemented below */
* passed to the GSource's set_callback */
%perlcode %{
sub xfer_start_with_callback {
- my ($xfer, $cb) = @_;
+ my ($xfer, $cb, $offset, $size) = @_;
if (defined $cb) {
my $releasing_cb = sub {
my ($src, $msg, $xfer) = @_;
};
$xfer->get_source()->set_callback($releasing_cb);
}
- xfer_start($xfer);
+ $offset = 0 if !defined $offset;
+ $size = 0 if !defined $size;
+ xfer_start($xfer, $offset, $size);
+}
+%}
+
+/* Change the callback */
+%perlcode %{
+sub xfer_set_callback {
+ my ($xfer, $cb) = @_;
+ if (defined $cb) {
+ my $releasing_cb = sub {
+ my ($src, $msg, $xfer) = @_;
+ my $done = $msg->{'type'} == $XMSG_DONE;
+ $src->remove() if $done;
+ $cb->(@_);
+ $cb = undef if $done; # break potential reference loop
+ };
+ $xfer->get_source()->set_callback($releasing_cb);
+ } else {
+ $xfer->get_source()->set_callback(undef);
+ }
}
%}
void xfer_element_unref(XferElement *elt); /* (wrap the macro, above) */
/* xfer_element_link_to -- private */
char *xfer_element_repr(XferElement *elt);
+/* xfer_element_set_size -- private */
/* xfer_element_start -- private */
/* xfer_element_cancel -- private */
XferElement *xfer_filter_process(
gchar **argv,
gboolean need_root);
+int get_err_fd(
+ XferElement *elt);
%newobject xfer_dest_null;
XferElement *xfer_dest_null(
DECLARE_METHOD(get_status, Amanda::Xfer::xfer_get_status);
DECLARE_METHOD(get_source, Amanda::Xfer::xfer_get_amglue_source);
DECLARE_METHOD(start, Amanda::Xfer::xfer_start_with_callback);
+DECLARE_METHOD(set_callback, Amanda::Xfer::xfer_set_callback);
DECLARE_METHOD(cancel, Amanda::Xfer::xfer_cancel);
/* ---- */
PACKAGE(Amanda::Xfer::Filter::Process)
XFER_ELEMENT_SUBCLASS()
DECLARE_CONSTRUCTOR(Amanda::Xfer::xfer_filter_process)
+DECLARE_METHOD(get_stderr_fd, Amanda::Xfer::get_err_fd)
/* ---- */
# try to load Amanda::XferServer, which is server-only. If it's not found, then
# its classes just remain undefined.
BEGIN {
- eval "use Amanda::XferServer;";
+ use Amanda::Util;
+ if (Amanda::Util::built_with_component("server")) {
+ eval "use Amanda::XferServer;";
+ }
}
%}