forked from owncloud/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocsjob.h
More file actions
131 lines (109 loc) · 3.24 KB
/
Copy pathocsjob.h
File metadata and controls
131 lines (109 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
*
* 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; version 2 of the License.
*
* 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.
*/
#ifndef OCSJOB_H
#define OCSJOB_H
#include "accountfwd.h"
#include "abstractnetworkjob.h"
#include <QVector>
#include <QList>
#include <QPair>
#include <QUrl>
namespace OCC {
/**
* @brief The OcsShareJob class
* @ingroup gui
*
* Base class for jobs that talk to the OCS endpoints on the server.
* All the communication logic is handled in this class.
*
* All OCS jobs (e.g. sharing) should extend this class.
*/
class OcsJob : public AbstractNetworkJob {
Q_OBJECT
protected:
explicit OcsJob(AccountPtr account);
/**
* Set the verb for the job
*
* @param verb currently supported PUT POST DELETE
*/
void setVerb(const QByteArray& verb);
/**
* Add a new parameter to the request.
* Depending on the verb this is GET or POST parameter
*
* @param name The name of the parameter
* @param value The value of the parameter
*/
void addParam(const QString& name, const QString &value);
/**
* Set the post parameters
*
* @param postParams list of pairs to add (urlEncoded) to the body of the
* request
*/
void setPostParams(const QList<QPair<QString, QString> >& postParams);
/**
* List of expected statuscodes for this request
* A warning will be printed to the debug log if a different status code is
* encountered
*
* @param code Accepted status code
*/
void addPassStatusCode(int code);
/**
* The base path for an OcsJob is always the same. But it could be the case that
* certain operations need to append something to the URL.
*
* This function appends the common id. so <PATH>/<ID>
*/
void appendPath(const QString &id);
public:
/**
* Parse the response and return the status code and the message of the
* reply (metadata)
*
* @param json The reply from OCS
* @param message The message that is set in the metadata
* @return The statuscode of the OCS response
*/
static int getJsonReturnCode(const QVariantMap &json, QString &message);
protected slots:
/**
* Start the OCS request
*/
void start() Q_DECL_OVERRIDE;
signals:
/**
* Result of the OCS request
*
* @param reply the reply
*/
void jobFinished(QVariantMap reply);
/**
* The status code was not one of the expected (passing)
* status code for this command
*
* @param statusCode The actual status code
* @param message The message provided by the server
*/
void ocsError(int statusCode, const QString &message);
private slots:
virtual bool finished() Q_DECL_OVERRIDE;
private:
QByteArray _verb;
QList<QPair<QString, QString> > _params;
QVector<int> _passStatusCodes;
};
}
#endif // OCSJOB_H