2
* This file is part of nzbget
4
* Copyright (C) 2007-2010 Andrey Prygunkov <hugbug@users.sourceforge.net>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
* $Date: 2013-04-15 22:06:05 +0200 (Mon, 15 Apr 2013) $
29
#include "Connection.h"
53
const char* m_szContentType;
54
ERpcProtocol m_eProtocol;
55
EHttpMethod m_eHttpMethod;
57
StringBuilder m_cResponse;
60
XmlCommand* CreateCommand(const char* szMethodName);
62
void BuildResponse(const char* szResponse, const char* szCallbackFunc, bool bFault);
68
void SetHttpMethod(EHttpMethod eHttpMethod) { m_eHttpMethod = eHttpMethod; }
69
void SetUrl(const char* szUrl);
70
void SetRequest(char* szRequest) { m_szRequest = szRequest; }
71
const char* GetResponse() { return m_cResponse.GetBuffer(); }
72
const char* GetContentType() { return m_szContentType; }
73
static bool IsRpcRequest(const char* szUrl);
81
char* m_szCallbackFunc;
82
StringBuilder m_StringBuilder;
84
XmlRpcProcessor::ERpcProtocol m_eProtocol;
85
XmlRpcProcessor::EHttpMethod m_eHttpMethod;
87
void BuildErrorResponse(int iErrCode, const char* szErrText, ...);
88
void BuildBoolResponse(bool bOK);
89
void AppendResponse(const char* szPart);
91
bool CheckSafeMethod();
92
bool NextParamAsInt(int* iValue);
93
bool NextParamAsBool(bool* bValue);
94
bool NextParamAsStr(char** szValueBuf);
95
const char* BoolToStr(bool bValue);
96
char* EncodeStr(const char* szStr);
97
void DecodeStr(char* szStr);
101
virtual ~XmlCommand() {}
102
virtual void Execute() = 0;
103
void PrepareParams();
104
void SetRequest(char* szRequest) { m_szRequest = szRequest; m_szRequestPtr = m_szRequest; }
105
void SetProtocol(XmlRpcProcessor::ERpcProtocol eProtocol) { m_eProtocol = eProtocol; }
106
void SetHttpMethod(XmlRpcProcessor::EHttpMethod eHttpMethod) { m_eHttpMethod = eHttpMethod; }
107
const char* GetResponse() { return m_StringBuilder.GetBuffer(); }
108
const char* GetCallbackFunc() { return m_szCallbackFunc; }
109
bool GetFault() { return m_bFault; }
112
class ErrorXmlCommand: public XmlCommand
116
const char* m_szErrText;
119
ErrorXmlCommand(int iErrCode, const char* szErrText);
120
virtual void Execute();
123
class PauseUnpauseXmlCommand: public XmlCommand
136
EPauseAction m_eEPauseAction;
139
PauseUnpauseXmlCommand(bool bPause, EPauseAction eEPauseAction);
140
virtual void Execute();
143
class ScheduleResumeXmlCommand: public XmlCommand
146
virtual void Execute();
149
class ShutdownXmlCommand: public XmlCommand
152
virtual void Execute();
155
class ReloadXmlCommand: public XmlCommand
158
virtual void Execute();
161
class VersionXmlCommand: public XmlCommand
164
virtual void Execute();
167
class DumpDebugXmlCommand: public XmlCommand
170
virtual void Execute();
173
class SetDownloadRateXmlCommand: public XmlCommand
176
virtual void Execute();
179
class StatusXmlCommand: public XmlCommand
182
virtual void Execute();
185
class LogXmlCommand: public XmlCommand
188
virtual void Execute();
191
class ListFilesXmlCommand: public XmlCommand
194
virtual void Execute();
197
class ListGroupsXmlCommand: public XmlCommand
200
virtual void Execute();
203
class EditQueueXmlCommand: public XmlCommand
206
virtual void Execute();
209
class DownloadXmlCommand: public XmlCommand
212
virtual void Execute();
215
class PostQueueXmlCommand: public XmlCommand
218
virtual void Execute();
221
class WriteLogXmlCommand: public XmlCommand
224
virtual void Execute();
227
class ClearLogXmlCommand: public XmlCommand
230
virtual void Execute();
233
class ScanXmlCommand: public XmlCommand
236
virtual void Execute();
239
class HistoryXmlCommand: public XmlCommand
242
virtual void Execute();
245
class DownloadUrlXmlCommand: public XmlCommand
248
virtual void Execute();
251
class UrlQueueXmlCommand: public XmlCommand
254
virtual void Execute();
257
class ConfigXmlCommand: public XmlCommand
260
virtual void Execute();
263
class LoadConfigXmlCommand: public XmlCommand
266
virtual void Execute();
269
class SaveConfigXmlCommand: public XmlCommand
272
virtual void Execute();
275
class ConfigTemplatesXmlCommand: public XmlCommand
278
virtual void Execute();