2009-05-08 07:58:50 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 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
|
2009-05-08 07:58:50 +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 --> */
|
2011-03-14 07:38:54 +00:00
|
|
|
#ifndef D_RPC_METHOD_H
|
|
|
|
#define D_RPC_METHOD_H
|
2009-05-08 07:58:50 +00:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "SharedHandle.h"
|
2010-06-19 17:54:54 +00:00
|
|
|
#include "ValueBase.h"
|
2009-05-08 07:58:50 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
|
|
|
|
|
|
|
class DownloadEngine;
|
|
|
|
class OptionParser;
|
|
|
|
class Option;
|
2009-12-26 10:16:56 +00:00
|
|
|
class Exception;
|
2009-05-08 07:58:50 +00:00
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
namespace rpc {
|
2009-05-08 07:58:50 +00:00
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
struct RpcRequest;
|
|
|
|
struct RpcResponse;
|
2009-05-08 07:58:50 +00:00
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
// This class offers abstract implementation of processing RPC
|
2009-09-14 12:54:14 +00:00
|
|
|
// request. You have to inherit this class and implement process()
|
2011-06-14 15:19:07 +00:00
|
|
|
// method to add new RPC API. The derived class must be stateless
|
|
|
|
// since we reuse the instances.
|
2009-09-14 12:54:14 +00:00
|
|
|
//
|
2011-03-14 07:38:54 +00:00
|
|
|
// There is RpcMethodFactory class which instantiates RpcMethod
|
|
|
|
// subclass. If you add new RpcMethod subclass, don't forget to add it
|
|
|
|
// to RpcMethodFactory.
|
|
|
|
class RpcMethod {
|
2010-06-12 14:14:47 +00:00
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
SharedHandle<OptionParser> optionParser_;
|
2010-06-12 14:14:47 +00:00
|
|
|
protected:
|
2011-03-14 07:38:54 +00:00
|
|
|
// Subclass must implement this function to fulfil RpcRequest req.
|
|
|
|
// The return value of this method is used as a return value of RPC
|
|
|
|
// request.
|
2010-06-19 17:54:54 +00:00
|
|
|
virtual SharedHandle<ValueBase> process
|
2011-03-14 07:38:54 +00:00
|
|
|
(const RpcRequest& req, DownloadEngine* e) = 0;
|
2009-05-08 07:58:50 +00:00
|
|
|
|
2011-10-22 10:08:20 +00:00
|
|
|
void gatherRequestOption(Option* option, const Dict* optionsDict);
|
2009-05-14 15:23:50 +00:00
|
|
|
|
2011-10-22 10:08:20 +00:00
|
|
|
void gatherChangeableOption(Option* option, const Dict* optionDict);
|
2009-05-14 15:44:59 +00:00
|
|
|
|
Options for -i list is now available in aria2.changeOption.
Options for -i list, except for PREF_CHECKSUM, PREF_DIR, PREF_DRY_RUN,
PREF_INDEX_OUT, PREF_LOWEST_SPEED_LIMIT,
PREF_MAX_CONNECTION_PER_SERVER, PREF_METALINK_BASE_URI, PREF_OUT,
PREF_PIECE_LENGTH, PREF_SELECT_FILE, PREF_SPLIT, PREF_PAUSE and
PREF_PARAMETERIZED_URI, are available in aria2.changeOption if the
download is waiting state, including paused downloads.
2011-10-29 09:50:52 +00:00
|
|
|
void gatherChangeableOptionForReserved
|
|
|
|
(Option* option, const Dict* optionsDict);
|
|
|
|
|
2011-10-22 10:08:20 +00:00
|
|
|
void gatherChangeableGlobalOption(Option* option, const Dict* optionDict);
|
2009-12-26 10:16:56 +00:00
|
|
|
|
2011-06-14 15:19:07 +00:00
|
|
|
SharedHandle<ValueBase> createErrorResponse
|
|
|
|
(const Exception& e, const RpcRequest& req);
|
2010-06-12 14:14:47 +00:00
|
|
|
|
|
|
|
const SharedHandle<OptionParser>& getOptionParser() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return optionParser_;
|
2010-06-12 14:14:47 +00:00
|
|
|
}
|
2009-05-08 07:58:50 +00:00
|
|
|
public:
|
2011-03-14 07:38:54 +00:00
|
|
|
RpcMethod();
|
2009-05-08 07:58:50 +00:00
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
virtual ~RpcMethod();
|
2009-05-10 16:37:34 +00:00
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
// Do work to fulfill RpcRequest req and returns its result as
|
|
|
|
// RpcResponse. This method delegates to process() method.
|
|
|
|
RpcResponse execute(const RpcRequest& req, DownloadEngine* e);
|
2009-05-08 07:58:50 +00:00
|
|
|
};
|
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
} // namespace rpc
|
2009-05-08 07:58:50 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|
|
|
|
|
2011-03-14 07:38:54 +00:00
|
|
|
#endif // D_RPC_METHOD_H
|