2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#ifndef _FILE_XFER_
|
|
|
|
#define _FILE_XFER_
|
|
|
|
|
2006-01-18 21:07:04 +00:00
|
|
|
// A FILE_XFER object represents a file transfer "episode"
|
|
|
|
// (see pers_file_xfer.h), i.e. an HTTP transaction with a
|
|
|
|
// particular data server.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-01 20:26:21 +00:00
|
|
|
#include "client_types.h"
|
2005-08-09 22:01:28 +00:00
|
|
|
#include "http_curl.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2006-01-18 21:07:04 +00:00
|
|
|
#define MIN_DOWNLOAD_INCREMENT 5000
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
class FILE_XFER : public HTTP_OP {
|
|
|
|
public:
|
|
|
|
FILE_INFO* fip;
|
2002-07-05 05:33:40 +00:00
|
|
|
char pathname[256];
|
|
|
|
char header[4096];
|
2002-08-21 19:12:42 +00:00
|
|
|
bool file_size_query;
|
2003-05-10 00:52:36 +00:00
|
|
|
bool is_upload;
|
2006-01-18 21:07:04 +00:00
|
|
|
double starting_size;
|
|
|
|
// File size at start of transfer.
|
|
|
|
// This is used to to implement a "minimum download increment"
|
|
|
|
// that rejects partial downloads of less than 5K,
|
|
|
|
// since these may be error messages from proxies.
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
FILE_XFER();
|
|
|
|
~FILE_XFER();
|
|
|
|
|
2003-09-30 18:09:58 +00:00
|
|
|
int parse_upload_response(double &offset);
|
2002-07-05 05:33:40 +00:00
|
|
|
int init_download(FILE_INFO&);
|
|
|
|
int init_upload(FILE_INFO&);
|
2002-04-30 22:22:54 +00:00
|
|
|
bool file_xfer_done;
|
|
|
|
int file_xfer_retval;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FILE_XFER_SET {
|
|
|
|
HTTP_OP_SET* http_ops;
|
|
|
|
public:
|
2005-11-25 18:17:09 +00:00
|
|
|
bool up_active, down_active;
|
|
|
|
// has there been transfer activity since last call to check_active()?
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<FILE_XFER*> file_xfers;
|
2002-04-30 22:22:54 +00:00
|
|
|
FILE_XFER_SET(HTTP_OP_SET*);
|
|
|
|
int insert(FILE_XFER*);
|
|
|
|
int remove(FILE_XFER*);
|
2005-06-07 19:22:50 +00:00
|
|
|
bool poll();
|
2005-11-25 18:17:09 +00:00
|
|
|
void check_active(bool&, bool&);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|