2007-05-20 13:57:56 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* 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 or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-05-20 13:57:56 +00:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
2010-10-31 07:23:53 +00:00
|
|
|
#ifndef D_MULTI_URL_REQUEST_INFO_H
|
|
|
|
#define D_MULTI_URL_REQUEST_INFO_H
|
2007-05-20 13:57:56 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "common.h"
|
2009-01-12 12:27:34 +00:00
|
|
|
|
2013-04-25 12:46:31 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
#include <vector>
|
2013-06-21 16:10:38 +00:00
|
|
|
#include <memory>
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2009-01-12 12:27:34 +00:00
|
|
|
#include "DownloadResult.h"
|
2013-04-25 12:46:31 +00:00
|
|
|
#include "util.h"
|
2009-01-12 12:27:34 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
2007-05-20 13:57:56 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
class RequestGroup;
|
|
|
|
class Option;
|
2012-02-05 09:57:16 +00:00
|
|
|
class UriListParser;
|
2013-04-25 12:46:31 +00:00
|
|
|
class DownloadEngine;
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
|
|
class MultiUrlRequestInfo {
|
2007-05-20 13:57:56 +00:00
|
|
|
private:
|
2015-12-27 09:39:47 +00:00
|
|
|
std::vector<std::shared_ptr<RequestGroup>> requestGroups_;
|
2007-05-20 13:57:56 +00:00
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<Option> option_;
|
2007-05-20 13:57:56 +00:00
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<UriListParser> uriListParser_;
|
2012-02-05 09:57:16 +00:00
|
|
|
|
2013-07-06 10:45:01 +00:00
|
|
|
std::unique_ptr<DownloadEngine> e_;
|
2013-04-25 12:46:31 +00:00
|
|
|
|
|
|
|
sigset_t mask_;
|
|
|
|
|
2013-05-04 14:56:19 +00:00
|
|
|
bool useSignalHandler_;
|
|
|
|
|
2007-10-13 15:47:22 +00:00
|
|
|
void printMessageForContinue();
|
2013-05-04 14:56:19 +00:00
|
|
|
void setupSignalHandlers();
|
2013-04-25 12:46:31 +00:00
|
|
|
void resetSignalHandlers();
|
2015-12-27 09:39:47 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
public:
|
2013-02-26 09:40:51 +00:00
|
|
|
/*
|
|
|
|
* MultiRequestInfo effectively takes ownership of the
|
|
|
|
* requestGroups.
|
|
|
|
*/
|
2015-12-27 09:39:47 +00:00
|
|
|
MultiUrlRequestInfo(std::vector<std::shared_ptr<RequestGroup>> requestGroups,
|
|
|
|
const std::shared_ptr<Option>& op,
|
|
|
|
const std::shared_ptr<UriListParser>& uriListParser);
|
2012-09-28 14:27:46 +00:00
|
|
|
|
2013-07-06 09:14:36 +00:00
|
|
|
~MultiUrlRequestInfo();
|
2007-05-20 13:57:56 +00:00
|
|
|
|
2013-04-26 14:55:51 +00:00
|
|
|
// Returns FINISHED if all downloads have completed, otherwise returns the
|
|
|
|
// last download result.
|
|
|
|
//
|
|
|
|
// This method actually calls prepare() and
|
|
|
|
// getDownloadEngine()->run(true) and getResult().
|
2010-11-28 07:52:02 +00:00
|
|
|
error_code::Value execute();
|
2013-04-25 12:46:31 +00:00
|
|
|
|
2013-04-26 14:55:51 +00:00
|
|
|
// Performs preparations for downloads, including creating
|
|
|
|
// DownloadEngine instance. This function returns 0 if it succeeds,
|
|
|
|
// or -1.
|
|
|
|
int prepare();
|
|
|
|
|
|
|
|
// Performs finalization of download process, including saving
|
|
|
|
// sessions. This function returns last error code in this session,
|
|
|
|
// in particular, this function returns FINISHED if all downloads
|
|
|
|
// have completed.
|
2013-04-25 12:46:31 +00:00
|
|
|
error_code::Value getResult();
|
2013-04-26 14:55:51 +00:00
|
|
|
|
2013-07-06 10:45:01 +00:00
|
|
|
const std::unique_ptr<DownloadEngine>& getDownloadEngine() const;
|
2013-05-04 14:56:19 +00:00
|
|
|
|
|
|
|
// Signal handlers are not prepared if false is given.
|
|
|
|
void setUseSignalHandler(bool useSignalHandler)
|
|
|
|
{
|
|
|
|
useSignalHandler_ = useSignalHandler;
|
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2010-10-31 07:23:53 +00:00
|
|
|
#endif // D_MULTI_URL_REQUEST_INFO_H
|