1 /* 2 * Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 */ 14 15 16 #ifndef CAPABILITIES_H 17 #define CAPABILITIES_H 18 19 #include "owncloudlib.h" 20 21 #include <QVariantMap> 22 #include <QStringList> 23 #include <QVersionNumber> 24 25 namespace OCC { 26 27 28 struct TusSupport 29 { 30 /** 31 <tus_support> 32 <version>1.0.0</version> 33 <resumable>1.0.0</resumable> 34 <extension>creation,creation-with-upload</extension> 35 <max_chunk_size>0</max_chunk_size> 36 <http_method_override/> 37 </tus_support> 38 */ 39 TusSupport(const QVariantMap &tus_support); 40 QVersionNumber version; 41 QVersionNumber resumable; 42 QStringList extensions; 43 quint64 max_chunk_size; 44 QString http_method_override; 45 46 bool isValid() const; 47 }; 48 49 /** 50 * @brief The Capabilities class represents the capabilities of an ownCloud 51 * server 52 * @ingroup libsync 53 */ 54 class OWNCLOUDSYNC_EXPORT Capabilities 55 { 56 public: 57 Capabilities(const QVariantMap &capabilities); 58 59 bool shareAPI() const; 60 bool sharePublicLink() const; 61 bool sharePublicLinkAllowUpload() const; 62 bool sharePublicLinkSupportsUploadOnly() const; 63 64 /** Whether read-only link shares require a password. 65 * 66 * Returns sharePublicLinkEnforcePassword() if the fine-grained 67 * permission isn't available. 68 */ 69 bool sharePublicLinkEnforcePasswordForReadOnly() const; 70 bool sharePublicLinkEnforcePasswordForReadWrite() const; 71 bool sharePublicLinkEnforcePasswordForUploadOnly() const; 72 73 bool sharePublicLinkDefaultExpire() const; 74 int sharePublicLinkDefaultExpireDateDays() const; 75 bool sharePublicLinkEnforceExpireDate() const; 76 bool sharePublicLinkMultiple() const; 77 bool shareResharing() const; 78 79 // TODO: return SharePermission 80 int defaultPermissions() const; 81 82 bool chunkingNg() const; 83 84 /// Wheter to use chunking 85 bool bigfilechunkingEnabled() const; 86 87 const TusSupport &tusSupport() const; 88 89 /// disable parallel upload in chunking 90 bool chunkingParallelUploadDisabled() const; 91 92 /// Whether the "privatelink" DAV property is available 93 bool privateLinkPropertyAvailable() const; 94 95 /// Whether the "privatelink" DAV property supports the 'details' param 96 bool privateLinkDetailsParamAvailable() const; 97 98 /// returns true if the capabilities report notifications 99 bool notificationsAvailable() const; 100 101 /// returns true if the capabilities are loaded already. 102 bool isValid() const; 103 104 /** 105 * Returns the checksum types the server understands. 106 * 107 * When the client uses one of these checksumming algorithms in 108 * the OC-Checksum header of a file upload, the server will use 109 * it to validate that data was transmitted correctly. 110 * 111 * Path: checksums/supportedTypes 112 * Default: [] 113 * Possible entries: "Adler32", "MD5", "SHA1" 114 */ 115 QList<QByteArray> supportedChecksumTypes() const; 116 117 /** 118 * The checksum algorithm that the server recommends for file uploads. 119 * This is just a preference, any algorithm listed in supportedTypes may be used. 120 * 121 * Path: checksums/preferredUploadType 122 * Default: empty, meaning "no preference" 123 * Possible values: empty or any of the supportedTypes 124 */ 125 QByteArray preferredUploadChecksumType() const; 126 127 /** 128 * Helper that returns the preferredUploadChecksumType() if set, or one 129 * of the supportedChecksumTypes() if it isn't. May return an empty 130 * QByteArray if no checksum types are supported. 131 */ 132 QByteArray uploadChecksumType() const; 133 134 /** 135 * List of HTTP error codes should be guaranteed to eventually reset 136 * failing chunked uploads. 137 * 138 * The resetting works by tracking UploadInfo::errorCount. 139 * 140 * Note that other error codes than the ones listed here may reset the 141 * upload as well. 142 * 143 * Motivation: See #5344. They should always be reset on 412 (possibly 144 * checksum error), but broken servers may also require resets on 145 * unusual error codes such as 503. 146 * 147 * Path: dav/httpErrorCodesThatResetFailingChunkedUploads 148 * Default: [] 149 * Example: [503, 500] 150 */ 151 QList<int> httpErrorCodesThatResetFailingChunkedUploads() const; 152 153 /** 154 * Regex that, if contained in a filename, will result in it not being uploaded. 155 * 156 * For servers older than 8.1.0 it defaults to [\\:?*"<>|] 157 * For servers >= that version, it defaults to the empty regex (the server 158 * will indicate invalid characters through an upload error) 159 * 160 * Note that it just needs to be contained. The regex [ab] is contained in "car". 161 */ 162 QString invalidFilenameRegex() const; 163 164 /** 165 * return the list of filename that should not be uploaded 166 */ 167 QStringList blacklistedFiles() const; 168 169 /** 170 * Whether conflict files should remain local (default) or should be uploaded. 171 */ 172 bool uploadConflictFiles() const; 173 174 /** Is versioning available? */ 175 bool versioningEnabled() const; 176 177 private: 178 QVariantMap _capabilities; 179 QVariantMap _fileSharingCapabilities; 180 QVariantMap _fileSharingPublicCapabilities; 181 TusSupport _tusSupport; 182 }; 183 } 184 185 #endif //CAPABILITIES_H 186