~ubuntu-branches/debian/experimental/nzbget/experimental

« back to all changes in this revision

Viewing changes to XmlRpc.h

  • Committer: Package Import Robot
  • Author(s): Andreas Moog
  • Date: 2014-12-25 12:58:06 UTC
  • mfrom: (1.2.1) (3.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20141225125806-vnzgajhm7mju9933
Tags: 14.1+dfsg-1
* New Upstream release (Closes: #768863)
* debian/patches:
  - Remove 0010_unnecessary_gcryptdep.patch, included upstream
  - Refresh remaining patches
* debian/control:
  - Remove no longer needed build-depends on libpar2-dev and libsigc++-dev
* debian/nzbget.conf
  - Update sample configuration file to include new options introduced by
    new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  This file is part of nzbget
3
 
 *
4
 
 *  Copyright (C) 2007-2010 Andrey Prygunkov <hugbug@users.sourceforge.net>
5
 
 *
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.
10
 
 *
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.
15
 
 *
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.
19
 
 *
20
 
 * $Revision: 629 $
21
 
 * $Date: 2013-04-15 22:06:05 +0200 (Mon, 15 Apr 2013) $
22
 
 *
23
 
 */
24
 
 
25
 
 
26
 
#ifndef XMLRPC_H
27
 
#define XMLRPC_H
28
 
 
29
 
#include "Connection.h"
30
 
#include "Util.h"
31
 
 
32
 
class XmlCommand;
33
 
 
34
 
class XmlRpcProcessor
35
 
{
36
 
public:
37
 
        enum ERpcProtocol
38
 
        {
39
 
                rpUndefined,
40
 
                rpXmlRpc,
41
 
                rpJsonRpc,
42
 
                rpJsonPRpc
43
 
        };
44
 
 
45
 
        enum EHttpMethod
46
 
        {
47
 
                hmPost,
48
 
                hmGet
49
 
        };
50
 
 
51
 
private:
52
 
        char*                           m_szRequest;
53
 
        const char*                     m_szContentType;
54
 
        ERpcProtocol            m_eProtocol;
55
 
        EHttpMethod                     m_eHttpMethod;
56
 
        char*                           m_szUrl;
57
 
        StringBuilder           m_cResponse;
58
 
 
59
 
        void                            Dispatch();
60
 
        XmlCommand*                     CreateCommand(const char* szMethodName);
61
 
        void                            MutliCall();
62
 
        void                            BuildResponse(const char* szResponse, const char* szCallbackFunc, bool bFault);
63
 
 
64
 
public:
65
 
                                                XmlRpcProcessor();
66
 
                                                ~XmlRpcProcessor();
67
 
        void                            Execute();
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);
74
 
};
75
 
 
76
 
class XmlCommand
77
 
{
78
 
protected:
79
 
        char*                           m_szRequest;
80
 
        char*                           m_szRequestPtr;
81
 
        char*                           m_szCallbackFunc;
82
 
        StringBuilder           m_StringBuilder;
83
 
        bool                            m_bFault;
84
 
        XmlRpcProcessor::ERpcProtocol   m_eProtocol;
85
 
        XmlRpcProcessor::EHttpMethod    m_eHttpMethod;
86
 
 
87
 
        void                            BuildErrorResponse(int iErrCode, const char* szErrText, ...);
88
 
        void                            BuildBoolResponse(bool bOK);
89
 
        void                            AppendResponse(const char* szPart);
90
 
        bool                            IsJson();
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);
98
 
 
99
 
public:
100
 
                                                XmlCommand();
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; }
110
 
};
111
 
 
112
 
class ErrorXmlCommand: public XmlCommand
113
 
{
114
 
private:
115
 
        int                                     m_iErrCode;
116
 
        const char*                     m_szErrText;
117
 
 
118
 
public:
119
 
                                                ErrorXmlCommand(int iErrCode, const char* szErrText);
120
 
        virtual void            Execute();
121
 
};
122
 
 
123
 
class PauseUnpauseXmlCommand: public XmlCommand
124
 
{
125
 
public:
126
 
        enum EPauseAction
127
 
        {
128
 
                paDownload,
129
 
                paDownload2,
130
 
                paPostProcess,
131
 
                paScan
132
 
        };
133
 
 
134
 
private:
135
 
        bool                    m_bPause;
136
 
        EPauseAction    m_eEPauseAction;
137
 
 
138
 
public:
139
 
                                                PauseUnpauseXmlCommand(bool bPause, EPauseAction eEPauseAction);
140
 
        virtual void            Execute();
141
 
};
142
 
 
143
 
class ScheduleResumeXmlCommand: public XmlCommand
144
 
{
145
 
public:
146
 
        virtual void            Execute();
147
 
};
148
 
 
149
 
class ShutdownXmlCommand: public XmlCommand
150
 
{
151
 
public:
152
 
        virtual void            Execute();
153
 
};
154
 
 
155
 
class ReloadXmlCommand: public XmlCommand
156
 
{
157
 
public:
158
 
        virtual void            Execute();
159
 
};
160
 
 
161
 
class VersionXmlCommand: public XmlCommand
162
 
{
163
 
public:
164
 
        virtual void            Execute();
165
 
};
166
 
 
167
 
class DumpDebugXmlCommand: public XmlCommand
168
 
{
169
 
public:
170
 
        virtual void            Execute();
171
 
};
172
 
 
173
 
class SetDownloadRateXmlCommand: public XmlCommand
174
 
{
175
 
public:
176
 
        virtual void            Execute();
177
 
};
178
 
 
179
 
class StatusXmlCommand: public XmlCommand
180
 
{
181
 
public:
182
 
        virtual void            Execute();
183
 
};
184
 
 
185
 
class LogXmlCommand: public XmlCommand
186
 
{
187
 
public:
188
 
        virtual void            Execute();
189
 
};
190
 
 
191
 
class ListFilesXmlCommand: public XmlCommand
192
 
{
193
 
public:
194
 
        virtual void            Execute();
195
 
};
196
 
 
197
 
class ListGroupsXmlCommand: public XmlCommand
198
 
{
199
 
public:
200
 
        virtual void            Execute();
201
 
};
202
 
 
203
 
class EditQueueXmlCommand: public XmlCommand
204
 
{
205
 
public:
206
 
        virtual void            Execute();
207
 
};
208
 
 
209
 
class DownloadXmlCommand: public XmlCommand
210
 
{
211
 
public:
212
 
        virtual void            Execute();
213
 
};
214
 
 
215
 
class PostQueueXmlCommand: public XmlCommand
216
 
{
217
 
public:
218
 
        virtual void            Execute();
219
 
};
220
 
 
221
 
class WriteLogXmlCommand: public XmlCommand
222
 
{
223
 
public:
224
 
        virtual void            Execute();
225
 
};
226
 
 
227
 
class ClearLogXmlCommand: public XmlCommand
228
 
{
229
 
public:
230
 
        virtual void            Execute();
231
 
};
232
 
 
233
 
class ScanXmlCommand: public XmlCommand
234
 
{
235
 
public:
236
 
        virtual void            Execute();
237
 
};
238
 
 
239
 
class HistoryXmlCommand: public XmlCommand
240
 
{
241
 
public:
242
 
        virtual void            Execute();
243
 
};
244
 
 
245
 
class DownloadUrlXmlCommand: public XmlCommand
246
 
{
247
 
public:
248
 
        virtual void            Execute();
249
 
};
250
 
 
251
 
class UrlQueueXmlCommand: public XmlCommand
252
 
{
253
 
public:
254
 
        virtual void            Execute();
255
 
};
256
 
 
257
 
class ConfigXmlCommand: public XmlCommand
258
 
{
259
 
public:
260
 
        virtual void            Execute();
261
 
};
262
 
 
263
 
class LoadConfigXmlCommand: public XmlCommand
264
 
{
265
 
public:
266
 
        virtual void            Execute();
267
 
};
268
 
 
269
 
class SaveConfigXmlCommand: public XmlCommand
270
 
{
271
 
public:
272
 
        virtual void            Execute();
273
 
};
274
 
 
275
 
class ConfigTemplatesXmlCommand: public XmlCommand
276
 
{
277
 
public:
278
 
        virtual void            Execute();
279
 
};
280
 
 
281
 
#endif