Welcome to mirror list, hosted at ThFree Co, Russian Federation.

capabilities.h « libsync « src - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 09baf03ddd4c38f2c41bdd87778b4b002a851856 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
 * 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; 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.
 */


#ifndef CAPABILITIES_H
#define CAPABILITIES_H

#include "owncloudlib.h"

#include <QVariantMap>
#include <QStringList>
#include <QVersionNumber>

namespace OCC {

struct OWNCLOUDSYNC_EXPORT Status
{
    /**
     <installed>1</installed>
    <maintenance>0</maintenance>
    <needsDbUpgrade>0</needsDbUpgrade>
    <version>10.11.0.0</version>
    <versionstring>10.11.0</versionstring>
    <edition>Community</edition>
    <productname>Infinite Scale</productname>
    <product>Infinite Scale</product>
    <productversion>2.0.0-beta1+7c2e3201b</productversion>
    */

    Status(const QVariantMap &status);
    // legacy version
    QVersionNumber legacyVersion;
    // legacy version
    QString legacyVersionString;

    QString edition;
    QString productname;
    QString product;
    QString productversion;

    QVersionNumber version() const;
    QString versionString() const;
};

struct OWNCLOUDSYNC_EXPORT TusSupport
{
    /**
    <tus_support>
    <version>1.0.0</version>
    <resumable>1.0.0</resumable>
    <extension>creation,creation-with-upload</extension>
    <max_chunk_size>0</max_chunk_size>
    <http_method_override/>
    </tus_support>
    */
    TusSupport(const QVariantMap &tus_support);
    QVersionNumber version;
    QVersionNumber resumable;
    QStringList extensions;
    quint64 max_chunk_size;
    QString http_method_override;

    bool isValid() const;
};

struct OWNCLOUDSYNC_EXPORT SpaceSupport
{
    /**
        "spaces": {
          "version": "0.0.1",
          "enabled": true
        }
    */
    SpaceSupport(const QVariantMap &spaces_support);
    bool enabled = false;
    QVersionNumber version;

    bool isValid() const;
};

/**
 * @brief The Capabilities class represents the capabilities of an ownCloud
 * server
 * @ingroup libsync
 */
class OWNCLOUDSYNC_EXPORT Capabilities
{
public:
    Capabilities(const QVariantMap &capabilities);

    bool shareAPI() const;
    bool sharePublicLink() const;
    bool sharePublicLinkAllowUpload() const;
    bool sharePublicLinkSupportsUploadOnly() const;

    /** Whether read-only link shares require a password.
     *
     * Returns sharePublicLinkEnforcePassword() if the fine-grained
     * permission isn't available.
     */
    bool sharePublicLinkEnforcePasswordForReadOnly() const;
    bool sharePublicLinkEnforcePasswordForReadWrite() const;
    bool sharePublicLinkEnforcePasswordForUploadOnly() const;

    bool sharePublicLinkDefaultExpire() const;
    int sharePublicLinkDefaultExpireDateDays() const;
    bool sharePublicLinkEnforceExpireDate() const;
    bool sharePublicLinkMultiple() const;
    bool shareResharing() const;
    /** Remote Poll interval.
     *
     *  returns the requested poll interval in seconds to be used by the client.
     *  @returns 0 if no capability is set.
     */
    std::chrono::seconds remotePollInterval() const;

    // TODO: return SharePermission
    int defaultPermissions() const;

    bool chunkingNg() const;

    /// Wheter to use chunking
    bool bigfilechunkingEnabled() const;

    const Status &status() const;
    const TusSupport &tusSupport() const;
    const SpaceSupport &spacesSupport() const;

    /// disable parallel upload in chunking
    bool chunkingParallelUploadDisabled() const;

    /// Whether the "privatelink" DAV property is available
    bool privateLinkPropertyAvailable() const;

    /// Whether the "privatelink" DAV property supports the 'details' param
    bool privateLinkDetailsParamAvailable() const;

    /// returns true if the capabilities report notifications
    bool notificationsAvailable() const;

    /// returns true if the capabilities are loaded already.
    bool isValid() const;

    /**
     * Returns the checksum types the server understands.
     *
     * When the client uses one of these checksumming algorithms in
     * the OC-Checksum header of a file upload, the server will use
     * it to validate that data was transmitted correctly.
     *
     * Path: checksums/supportedTypes
     * Default: []
     * Possible entries: "Adler32", "MD5", "SHA1"
     */
    QList<QByteArray> supportedChecksumTypes() const;

    /**
     * The checksum algorithm that the server recommends for file uploads.
     * This is just a preference, any algorithm listed in supportedTypes may be used.
     *
     * Path: checksums/preferredUploadType
     * Default: empty, meaning "no preference"
     * Possible values: empty or any of the supportedTypes
     */
    QByteArray preferredUploadChecksumType() const;

    /**
     * Helper that returns the preferredUploadChecksumType() if set, or one
     * of the supportedChecksumTypes() if it isn't. May return an empty
     * QByteArray if no checksum types are supported.
     */
    QByteArray uploadChecksumType() const;

    /**
     * List of HTTP error codes should be guaranteed to eventually reset
     * failing chunked uploads.
     *
     * The resetting works by tracking UploadInfo::errorCount.
     *
     * Note that other error codes than the ones listed here may reset the
     * upload as well.
     *
     * Motivation: See #5344. They should always be reset on 412 (possibly
     * checksum error), but broken servers may also require resets on
     * unusual error codes such as 503.
     *
     * Path: dav/httpErrorCodesThatResetFailingChunkedUploads
     * Default: []
     * Example: [503, 500]
     */
    QList<int> httpErrorCodesThatResetFailingChunkedUploads() const;

    /**
     * Regex that, if contained in a filename, will result in it not being uploaded.
     *
     * For servers older than 8.1.0 it defaults to [\\:?*"<>|]
     * For servers >= that version, it defaults to the empty regex (the server
     * will indicate invalid characters through an upload error)
     *
     * Note that it just needs to be contained. The regex [ab] is contained in "car".
     */
    QString invalidFilenameRegex() const;

    /**
     * return the list of filename that should not be uploaded
     */
    QStringList blacklistedFiles() const;

    /**
     * Whether conflict files should remain local (default) or should be uploaded.
     */
    bool uploadConflictFiles() const;

    /** Is versioning available? */
    bool versioningEnabled() const;

    /** Are avatars (profile pictures) available? */
    bool avatarsAvailable() const;


    QVariantMap raw() const;

private:
    QVariantMap _capabilities;
    QVariantMap _fileSharingCapabilities;
    QVariantMap _fileSharingPublicCapabilities;
    TusSupport _tusSupport;
    SpaceSupport _spaces;
    Status _status;
};
}

#endif //CAPABILITIES_H